<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Sorry my mail was sent to early. There were also a missing column on the initial regexp.<div class=""><br class=""></div><div class="">here the good one: </div><div class=""><br class=""><div class=""><div class="">--- do_ifstat.c<span class="Apple-tab-span" style="white-space:pre">    </span>2015-10-01 16:42:42.000000000 +0200</div><div class="">+++ /root/do_ifstat.c.fix.freebsd.ifstat<span class="Apple-tab-span" style="white-space:pre">       </span>2015-12-15 09:16:38.584712442 +0100</div><div class="">@@ -28,7 +28,7 @@</div><div class=""> /* Name MTU  Network        IP            Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll */</div><div class=""> /* lnc0 1500 172.16.10.0/24 172.16.10.151 26    -     1818   26    -     1802   -    */</div><div class=""> static const char *ifstat_freebsd_exprs[] = {</div><div class="">-<span class="Apple-tab-span" style="white-space:pre">     </span>"^([a-z0-9]+)<a href="smb://s+//d+//s+[0-9.///]+//s+[0-9.]+//s+//d+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+[0-9-" class="">\\s+\\d+\\s+[0-9.\\/]+\\s+[0-9.]+\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+[0-9-</a>]+"</div><div class="">+<span class="Apple-tab-span" style="white-space:pre">   </span>"^([a-z0-9]+)<a href="smb://s+//d+//s+<Link#//d+>//s+[a-f0123456789.:]+//s+//d+//s+[0-9-]+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+[0-9-" class="">\\s+\\d+\\s+<Link#\\d+>\\s+[a-f0123456789.:]+\\s+\\d+\\s+[0-9-]+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+[0-9-</a>]+"</div><div class=""> };</div><div class=""><br class=""></div><div class=""> /* Name    Mtu Network       Address         Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll */</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Now ifstat graphs are OK on my FreeBSD boxes.</div><div class=""><br class=""></div><div class="">regards</div><div class="">Nico</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 14 déc. 2015 à 18:24, Nico <<a href="mailto:nicolas@lienard.name" class="">nicolas@lienard.name</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hello</div><div class=""><br class=""></div><div class="">Having same issue with my FreeBSD 10.2 devices, i tried this patch on server side but it was not matching successfully all the interfaces due to bad regular expression matching on the mac addresses part.</div><div class=""><br class=""></div><div class=""><div class=""># netstat -ibn | egrep "<Link|Name" | grep -v ^lo</div><div class="">Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll</div><div class="">em0    1500 <Link#1>      00:22:4d:ad:fe:35 893691871     0     0 1135451821124 497735825     0 107868664606     0</div><div class="">pflog 33160 <Link#5>                               0     0     0          0   697354     0   69531302     0</div><div class="">tap0   1500 <Link#3>      00:bd:c4:41:4e:00 448130087     0     0 584819922588 250814356     0 43739464436     0</div><div class="">bridg  1500 <Link#4>      02:f7:58:d9:cb:00        0     0     0          0        0     0          0     0</div><div class="">vlan1  1496 <Link#9>      00:bd:c4:41:4e:00 58827595     0     0 61939630719 46134046  3255 29559453921     0</div><div class="">vlan2  1300 <Link#10>     00:bd:c4:41:4e:00   450450     0     0   34627817   456686   110   36271656     0</div><div class="">tap30  1500 <Link#7>      00:bd:24:27:3a:1e   109129     0     0    7518832   171580     0  231138481     0</div><div class="">bridg  1500 <Link#8>      02:f7:58:d9:cb:1e        0     0     0          0        0     0          0     0</div><div class="">vlan3  1496 <Link#12>     00:bd:24:27:3a:1e      143     0     0      10409       73     0       3893     0</div></div><div class=""><br class=""></div><div class="">It was matching only pflog0 interface with the regexp where the mac address part is in bold : </div><div class=""><br class=""></div><div class=""><pre style="white-space: pre-wrap; line-height: normal; widows: 1;" class="">"^([a-z0-9]+)<a href="smb://s+//d+//s+<Link#//d+>//s+" class="">\\s+\\d+\\s+<Link#\\d+>\\s+</a><b class="">[:0-9]+</b><a href="smb://s+//d+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+[0-9-" class="">\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+[0-9-</a>]+"
 };</pre></div><div class=""><br class=""></div><div class="">Here a functional one (in bold the replacement)</div><div class=""><br class=""></div><div class="">rrd/do_ifstat.c  [line 31]</div><div class=""><br class=""></div><div class=""><div class="">/* Name MTU  Network        IP            Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll */</div><div class="">/* lnc0 1500 172.16.10.0/24 172.16.10.151 26    -     1818   26    -     1802   -    */</div><div class="">static const char *ifstat_freebsd_exprs[] = {</div><div class="">        "^([a-z0-9]+)<a href="smb://s+//d+//s+<Link#//d+>//s+" class="">\\s+\\d+\\s+<Link#\\d+>\\s+</a><b class="">[a-z0123456789.:]+</b><a href="smb://s+//d+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+[0-9-" class="">\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+[0-9-</a>]+"</div><div class="">};</div></div><div class=""><br class=""></div><div class="">The part on client is working fine.</div><div class=""><br class=""></div><div class="">Thanks and long life to Xymon !</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">regards,</div><div class=""><br class=""></div><div class="">Nico</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><pre style="white-space: pre-wrap; line-height: normal; widows: 1;" class="">From: Xymon [mailto:<a href="http://lists.xymon.com/mailman/listinfo/xymon" class="">xymon-bounces at xymon.com</a>] On Behalf Of Jeremy Laidman
Sent: Thursday, 20 February 2014 1:46 PM
To: <a href="http://lists.xymon.com/mailman/listinfo/xymon" class="">xymon at xymon.com</a>
Subject: Re: [Xymon] FreeBSD [ifstat] processing

On 17 February 2014 23:24, Jeremy Laidman <<a href="http://lists.xymon.com/mailman/listinfo/xymon" class="">jlaidman at rebel-it.com.au</a><mailto:<a href="http://lists.xymon.com/mailman/listinfo/xymon" class="">jlaidman at rebel-it.com.au</a>>> wrote:
On 17 February 2014 18:48, Jeremy Laidman <<a href="http://lists.xymon.com/mailman/listinfo/xymon" class="">jlaidman at rebel-it.com.au</a><mailto:<a href="http://lists.xymon.com/mailman/listinfo/xymon" class="">jlaidman at rebel-it.com.au</a>>> wrote:
For this reason, it seems to make sense that the "link" lines are probably the best for this, as I would think that they would show packets contained only in physical frames (ethernet or some other medium).

So I'm proposing that the FreeBSD client be adjusted from this:

echo "[ifstat]"
netstat -i -b -n | egrep -v "^lo|<Link"

To this:

echo "[ifstat]"
netstat -i -b -n | egrep "<Link"

Seem reasonable?  Would anyone be adversely impacted by this suggested change?

Anyone?  Nobody else using FreeBSD?

I've implemented a work-around that works for me, by using the following line in xymonclient-freebsd.sh:

netstat -ibn|egrep "<Link|Name"| grep -v ^lo | while read A B C D E F G; do [ $A = "Name" ] || { C=0.0.0.0/0<<a href="http://0.0.0.0/0" class="">http://0.0.0.0/0</a>>; D=0.0.0.0; }; printf "%-5s %5s %-13s %-17s %12s %6s %14s %14s %6s %14s %6s\n" $A $B $C $D $E $F $G; done

The output now only includes interface lines with "<Link" that are not loopback devices (thus ignoring all the non-physical entries), and the "<Link#1>" and MAC address lines have been replaced with dummy values that parse correctly on the server.  I now have useful interface graphs for my FreeBSD systems.

This is an ugly hack, and I only want this in place until a proper solution can be implemented.

So, I'm proposing that the xymonclient-freebsd.sh script be modified to use this line for [ifstat]:

  netstat -ibn | egrep "<Link|Name"|grep -v ^lo

(This could leave the loopback addresses in place, and I don't think anyone would mind.)

Then, the following (untested) patch to do_ifstat.c.

What say ye all?

Cheers
Jeremy

--- do_ifstat.c.orig    2014-02-20 13:35:33.000000000 +1100
+++ do_ifstat.c 2014-02-20 13:42:32.000000000 +1100
@@ -27,8 +27,10 @@

 /* Name MTU  Network        IP            Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll */
 /* lnc0 1500 172.16.10.0/24<<a href="http://172.16.10.0/24" class="">http://172.16.10.0/24</a>> 172.16.10.151 26    -     1818   26    -     1802   -    */
+/* Name MTU  Network  Address             Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll */
+/* em0  1500 <Link#1> 00:11:22:33:44:55   26    -     1818   26    -     1802   -    */
 static const char *ifstat_freebsd_exprs[] = {
-       "^([a-z0-9]+)<a href="smb://s+//d+//s+[0-9.///]+//s+[0-9.]+//s+//d+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+" class="">\\s+\\d+\\s+[0-9.\\/]+\\s+[0-9.]+\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+</a>[0-9-<<a href="file:///s+/d+/s+%5b0-9./%5d+/s+%5b0-9.%5d+/s+/d+/s+%5b0-9-%5d+/s+(/d+" class="">file:///\\s+\d+\s+%5b0-9.\%5d+\s+%5b0-9.%5d+\s+\d+\s+%5b0-9-%5d+\s+(\d+</a>)\s+\d+\s+%5b0-9-%5d+\s+(\d+)\s+%5b0-9->]+"
+       "^([a-z0-9]+)<a href="smb://s+//d+//s+<Link#//d+>//s+[:0-9]+//s+//d+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+" class="">\\s+\\d+\\s+<Link#\\d+>\\s+[:0-9]+\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+</a>[0-9-<<a href="file:///s+/d+/s+%3cLink%23/d+%3e/s+%5b:0-9%5d+/s+/d+/s+%5b0-9-%5d+/s+(/d+" class="">file:///\\s+\d+\s+%3cLink%23\d+%3e\s+%5b:0-9%5d+\s+\d+\s+%5b0-9-%5d+\s+(\d+</a>)\s+\d+\s+%5b0-9-%5d+\s+(\d+)\s+%5b0-9->]+"
 };

 /* Name    Mtu Network       Address         Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll */


**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************</pre><div class=""><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></body></html>