OPNsense Forum

Archive => 18.7 Legacy Series => Topic started by: sco01 on August 04, 2018, 12:39:41 am

Title: Telegraf reporting incorrect value for net, bytes_sent on WAN interface
Post by: sco01 on August 04, 2018, 12:39:41 am
Hi. I just migrated over to OPNsense and this is the first problem I have encountered.

I have configured Telegraf to report net stats to InfluxDB. The stats for em1 (LAN) works great but the value for bytes_sent on em0 (WAN) is the same value over and over again. The problem seems to be related to the Telegraf package but I'm not sure if this is specific to OPNsense or the FreeBSD package. Another user reported the exact same problem in March: https://community.influxdata.com/t/telegraf-inputs-net-not-correctly-reporting-bytes-sent-on-single-interface-freebsd/4308 (https://community.influxdata.com/t/telegraf-inputs-net-not-correctly-reporting-bytes-sent-on-single-interface-freebsd/4308)

I'm on v18.7 (fresh install)
Title: Re: Telegraf reporting incorrect value for net, bytes_sent on WAN interface
Post by: mimugmail on August 04, 2018, 08:08:58 am
Normally you have to report to the telegraf team here:

https://github.com/influxdata/telegraf/issues

I asked a poweruser of Telegraf in IRC .. let's see
Title: Re: Telegraf reporting incorrect value for net, bytes_sent on WAN interface
Post by: sco01 on August 19, 2018, 02:12:37 pm
I think this may be a bug in FreeBSD but I'm not sure.

Telegraf uses netstat to pull the counters (see here: https://github.com/shirou/gopsutil/blob/master/net/net_freebsd.go#L19 (https://github.com/shirou/gopsutil/blob/master/net/net_freebsd.go#L19)). It runs netstat -ibdnW and it looks like it takes the first entry for each interface (Link). The problem is that the command returns the same value over and over again but only for the first device (em0 in my case)

Example:

Code: [Select]
root@OPNsense:~ # netstat -ibdnW
Name        Mtu Network                  Address                                    Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll  Drop
em0        1500 <Link#1>                 00:15:17:a0:6a:da                          44296   504     0 17680705579    10954     0    2005083     0     0
em0           - fe80::%em0/64            fe80::215:17ff:fea0:6ada%em0                   0     -     -          0        6     -        336     -     -
em0           - 82.209.187.128/27        82.209.187.149                           6051436     -     - 8874534492  6070280     -  322586433     -     -
em1        1500 <Link#2>                 00:15:17:a0:6a:db                        3562759     0     0  451479188 13284089     0 17642901362     0     0
em1           - fe80::%em1/64            fe80::215:17ff:fea0:6adb%em1                   0     -     -          0        1     -         96     -     -
em1           - 192.168.0.0/24           192.168.0.1                               435054     -     -   33502003  6951591     - 8825493425     -     -

root@OPNsense:~ # netstat -ibdnW
Name        Mtu Network                  Address                                    Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll  Drop
em0        1500 <Link#1>                 00:15:17:a0:6a:da                          44296   504     0 17688104362    10954     0    2005083     0     0
em0           - fe80::%em0/64            fe80::215:17ff:fea0:6ada%em0                   0     -     -          0        6     -        336     -     -
em0           - 82.209.187.128/27        82.209.187.149                           6051762     -     - 8874585001  6070515     -  322604505     -     -
em1        1500 <Link#2>                 00:15:17:a0:6a:db                        3564057     0     0  451623136 13289557     0 17650327129     0     0
em1           - fe80::%em1/64            fe80::215:17ff:fea0:6adb%em1                   0     -     -          0        1     -         96     -     -
em1           - 192.168.0.0/24           192.168.0.1                               435363     -     -   33524826  6952012     - 8825556416     -     -


You can see how Obytes stays at 2005083 for em0 between the calls while the counter increases from 17642901362 to 17650327129 for em1.

I'm not sure if telegraf is doing the right thing when it takes the Link value. What do you think?