[Xymon] FreeBSD [ifstat] processing

Nico nicolas at lienard.name
Tue Dec 15 09:19:59 CET 2015


Sorry my mail was sent to early. There were also a missing column on the initial regexp.

here the good one:

--- do_ifstat.c	2015-10-01 16:42:42.000000000 +0200
+++ /root/do_ifstat.c.fix.freebsd.ifstat	2015-12-15 09:16:38.584712442 +0100
@@ -28,7 +28,7 @@
 /* Name MTU  Network        IP            Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll */
 /* lnc0 1500 172.16.10.0/24 172.16.10.151 26    -     1818   26    -     1802   -    */
 static const char *ifstat_freebsd_exprs[] = {
-	"^([a-z0-9]+)\\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- <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->]+"
+	"^([a-z0-9]+)\\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- <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->]+"
 };

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



Now ifstat graphs are OK on my FreeBSD boxes.

regards
Nico



> Le 14 déc. 2015 à 18:24, Nico <nicolas at lienard.name <mailto:nicolas at lienard.name>> a écrit :
> 
> Hello
> 
> 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.
> 
> # netstat -ibn | egrep "<Link|Name" | grep -v ^lo
> Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
> em0    1500 <Link#1>      00:22:4d:ad:fe:35 893691871     0     0 1135451821124 497735825     0 107868664606     0
> pflog 33160 <Link#5>                               0     0     0          0   697354     0   69531302     0
> tap0   1500 <Link#3>      00:bd:c4:41:4e:00 448130087     0     0 584819922588 250814356     0 43739464436     0
> bridg  1500 <Link#4>      02:f7:58:d9:cb:00        0     0     0          0        0     0          0     0
> vlan1  1496 <Link#9>      00:bd:c4:41:4e:00 58827595     0     0 61939630719 46134046  3255 29559453921     0
> vlan2  1300 <Link#10>     00:bd:c4:41:4e:00   450450     0     0   34627817   456686   110   36271656     0
> tap30  1500 <Link#7>      00:bd:24:27:3a:1e   109129     0     0    7518832   171580     0  231138481     0
> bridg  1500 <Link#8>      02:f7:58:d9:cb:1e        0     0     0          0        0     0          0     0
> vlan3  1496 <Link#12>     00:bd:24:27:3a:1e      143     0     0      10409       73     0       3893     0
> 
> It was matching only pflog0 interface with the regexp where the mac address part is in bold :
> 
> "^([a-z0-9]+)\\s+\\d+\\s+<Link#\\d+>\\s+ <smb://s+//d+//s+<Link#//d+>//s+>[:0-9]+\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+[0-9- <smb://s+//d+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+[0-9->]+"
>  };
> 
> Here a functional one (in bold the replacement)
> 
> rrd/do_ifstat.c  [line 31]
> 
> /* Name MTU  Network        IP            Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll */
> /* lnc0 1500 172.16.10.0/24 172.16.10.151 26    -     1818   26    -     1802   -    */
> static const char *ifstat_freebsd_exprs[] = {
>         "^([a-z0-9]+)\\s+\\d+\\s+<Link#\\d+>\\s+ <smb://s+//d+//s+<Link#//d+>//s+>[a-z0123456789.:]+\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+[0-9- <smb://s+//d+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+[0-9->]+"
> };
> 
> The part on client is working fine.
> 
> Thanks and long life to Xymon !
> 
> 
> regards,
> 
> Nico
> 
> 
> 
> From: Xymon [mailto:xymon-bounces at xymon.com <http://lists.xymon.com/mailman/listinfo/xymon>] On Behalf Of Jeremy Laidman
> Sent: Thursday, 20 February 2014 1:46 PM
> To: xymon at xymon.com <http://lists.xymon.com/mailman/listinfo/xymon>
> Subject: Re: [Xymon] FreeBSD [ifstat] processing
> 
> On 17 February 2014 23:24, Jeremy Laidman <jlaidman at rebel-it.com.au <http://lists.xymon.com/mailman/listinfo/xymon><mailto:jlaidman at rebel-it.com.au <http://lists.xymon.com/mailman/listinfo/xymon>>> wrote:
> On 17 February 2014 18:48, Jeremy Laidman <jlaidman at rebel-it.com.au <http://lists.xymon.com/mailman/listinfo/xymon><mailto:jlaidman at rebel-it.com.au <http://lists.xymon.com/mailman/listinfo/xymon>>> 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<http://0.0.0.0/0 <http://0.0.0.0/0>>; 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<http://172.16.10.0/24 <http://172.16.10.0/24>> 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]+)\\s+\\d+\\s+[0-9.\\/]+\\s+[0-9.]+\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+ <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-<file:///\\s+\d+\s+%5b0-9.\%5d+\s+%5b0-9.%5d+\s+\d+\s+%5b0-9-%5d+\s+(\d+ <file:///s+/d+/s+%5b0-9./%5d+/s+%5b0-9.%5d+/s+/d+/s+%5b0-9-%5d+/s+(/d+>)\s+\d+\s+%5b0-9-%5d+\s+(\d+)\s+%5b0-9->]+"
> +       "^([a-z0-9]+)\\s+\\d+\\s+<Link#\\d+>\\s+[:0-9]+\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+\\d+\\s+[0-9-]+\\s+(\\d+)\\s+ <smb://s+//d+//s+<Link#//d+>//s+[:0-9]+//s+//d+//s+[0-9-]+//s+(//d+)//s+//d+//s+[0-9-]+//s+(//d+)//s+>[0-9-<file:///\\s+\d+\s+%3cLink%23\d+%3e\s+%5b:0-9%5d+\s+\d+\s+%5b0-9-%5d+\s+(\d+ <file:///s+/d+/s+%3cLink%23/d+%3e/s+%5b:0-9%5d+/s+/d+/s+%5b0-9-%5d+/s+(/d+>)\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.
> **********************************************************************
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20151215/9440ddd7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20151215/9440ddd7/attachment.sig>


More information about the Xymon mailing list