Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenBSD net plugin only reporting in/out bytes #12977

Closed
amarinderca opened this issue Mar 29, 2023 · 7 comments · Fixed by #15272
Closed

OpenBSD net plugin only reporting in/out bytes #12977

amarinderca opened this issue Mar 29, 2023 · 7 comments · Fixed by #15272
Labels
bug unexpected problem or unintended behavior upstream bug or issues that rely on dependency fixes

Comments

@amarinderca
Copy link
Contributor

Relevant telegraf.conf

[[inputs.net]]

  [inputs.net.tags]

    bucket = "telegraf"

Logs from Telegraf

Mar 29 04:14:33 fw3a telegraf[54810]: 2023-03-29T04:14:33Z I! [agent] Hang on, flushing any cached metrics before shutdown
Mar 29 04:14:33 fw3a telegraf[54810]: 2023-03-29T04:14:33Z I! [agent] Stopping running outputs
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z I! Using config file: /etc/telegraf/telegraf.conf
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z I! Starting Telegraf
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z I! Loaded inputs: cpu (2x) disk (2x) diskio (2x) mem (2x) net (2x) processes (2x) swap (2x) system (2x)
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z I! Loaded aggregators:
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z I! Loaded processors:
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z I! Loaded outputs: influxdb_v2 (2x)
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z I! Tags enabled: host=<snip>
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"<snip>", Flush Interval:10s
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z D! [agent] Initializing plugins
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z D! [agent] Connecting outputs
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z D! [agent] Attempting connection to [outputs.influxdb_v2]
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z D! [agent] Successfully connected to outputs.influxdb_v2
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z D! [agent] Attempting connection to [outputs.influxdb_v2]
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z D! [agent] Successfully connected to outputs.influxdb_v2
Mar 29 04:14:34 fw3a telegraf[52778]: 2023-03-29T04:14:34Z D! [agent] Starting service inputs
Mar 29 04:14:45 fw3a telegraf[52778]: 2023-03-29T04:14:45Z D! [outputs.influxdb_v2] Wrote batch of 99 metrics in 707.846005ms
Mar 29 04:14:45 fw3a telegraf[52778]: 2023-03-29T04:14:45Z D! [outputs.influxdb_v2] Buffer fullness: 10 / 10000 metrics
Mar 29 04:14:45 fw3a telegraf[52778]: 2023-03-29T04:14:45Z D! [outputs.influxdb_v2] Wrote batch of 89 metrics in 869.87493ms
Mar 29 04:14:45 fw3a telegraf[52778]: 2023-03-29T04:14:45Z D! [outputs.influxdb_v2] Buffer fullness: 20 / 10000 metrics
Mar 29 04:14:54 fw3a telegraf[52778]: 2023-03-29T04:14:54Z D! [outputs.influxdb_v2] Wrote batch of 98 metrics in 9.895004ms
Mar 29 04:14:54 fw3a telegraf[52778]: 2023-03-29T04:14:54Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
Mar 29 04:14:54 fw3a telegraf[52778]: 2023-03-29T04:14:54Z D! [outputs.influxdb_v2] Wrote batch of 108 metrics in 6.329166ms
Mar 29 04:14:54 fw3a telegraf[52778]: 2023-03-29T04:14:54Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
Mar 29 04:15:05 fw3a telegraf[52778]: 2023-03-29T04:15:05Z D! [outputs.influxdb_v2] Wrote batch of 105 metrics in 24.687494ms
Mar 29 04:15:05 fw3a telegraf[52778]: 2023-03-29T04:15:05Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
Mar 29 04:15:05 fw3a telegraf[52778]: 2023-03-29T04:15:05Z D! [outputs.influxdb_v2] Wrote batch of 136 metrics in 16.152451ms
Mar 29 04:15:05 fw3a telegraf[52778]: 2023-03-29T04:15:05Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics

System info

OpenBSD 7.1 and 7.2, telegraf 1.22.0 and telegraf 1.22.4

Docker

No response

Steps to reproduce

  1. Enable net plugin
  2. Check data in infliuxdb, it creates: packets_sent, packets_recv, err_in, err_out, drop_in, drop_out with datapoints consisting of only one value: 0. while bytes_recv and bytes_sent have accurate data

Expected behavior

We should get same data from netstat -ibden as freebsd with error, dropped, bytes, and packets in/out reported.

Actual behavior

We only get bytes in/out. OpenBSD behaves differently where netstat -ibn should be used for bytes in/out and -idn used for dropped and packets in/out, and -ien used for errors and packers in/out, and -in reports packets and fail in/out

Additional info

# netstat -ien
Name    Mtu   Network     Address              Ipkts Ierrs    Opkts Oerrs Colls
# netstat -idn
Name    Mtu   Network     Address              Ipkts Idrop    Opkts Odrop Colls
# netstat -ibn
Name    Mtu   Network     Address               Ibytes     Obytes
# netstat -in
Name    Mtu   Network     Address              Ipkts Ifail    Opkts Ofail Colls
# netstat -ibden
Name    Mtu   Network     Address               Ibytes     Obytes

@amarinderca amarinderca added the bug unexpected problem or unintended behavior label Mar 29, 2023
@powersj
Copy link
Contributor

powersj commented Mar 29, 2023

Hi,

If you look at the net plugin readme it says the following:

Different platforms gather the data above with different mechanisms. Telegraf
uses the gopsutil package, which under Linux reads the /proc/net/dev file.
Under freebsd/openbsd and darwin the plugin uses netstat.

Additionally, for the time being _only under Linux_, the plugin gathers system
wide stats for different network protocols using /proc/net/snmp (tcp, udp, icmp,
etc.).

The plugin in telegraf, does not shell out to call netstat, instead it relies on gopsutil to collect and return the data. It does look like darwin uses netstat -ibdnW, as does freebsd and something similar with openbsd.

My suggestion is to go file a bug on gopsutil asking for an enhancement to what is returned. If that gets fixed or changed, then Telegraf would also benefit.

Thanks!

@amarinderca
Copy link
Contributor Author

Okay I have opened a bug report there. Thanks!

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Mar 29, 2023
@powersj powersj added the upstream bug or issues that rely on dependency fixes label Mar 30, 2023
@amarinderca
Copy link
Contributor Author

@powersj Hi, My pull request has been merged to the upstream library. This issue should be resolved when the changes make it to telegraf. Thanks!

@powersj
Copy link
Contributor

powersj commented Apr 10, 2024

@amarinderca thank you for taking the time to put up a PR and getting that fixed. gopsutil usually does a monthly release. I'll put a reminder on my calendar to grab the update at the end of the month. If I forget or you see it released before then, please feel free to remind me ;)

@powersj
Copy link
Contributor

powersj commented May 1, 2024

@amarinderca,

I have put up #15272 which includes an update to gopsutil library. It includes the release with the bug fix from your issue. Could you please download artifacts from that PR, which will be attached as a comment ~30mins from this message. Could you please confirm it resolves the original issue?

Thanks!

@powersj powersj added the waiting for response waiting for response from contributor label May 1, 2024
@amarinderca
Copy link
Contributor Author

@powersj I can confirm that the issue is now resolved. I was able to compile the package from the git commit you mentioned on OpenBSD 7.5 via ports system. I had to modify the port Makefile and update the MODGO_MODULES in modules.inc with the current version numbers of go mods. See the small demo attached.

Thanks!

obsd_telegraf

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label May 6, 2024
@powersj
Copy link
Contributor

powersj commented May 6, 2024

@amarinderca thank you very much for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior upstream bug or issues that rely on dependency fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants