Re: [Monitorix-general] Network Traffic and Usage Problem Graph, FreeBSD

2011-03-15 Thread strumming
Hello Jordi,

Quoting Jordi Sanfeliu jo...@fibranet.cat:

 I've looked the patch and it seems that only covers FreeBSD version 7.x
 and 8.x, but I'm not sure if FreeBSD versions prior to 7 (6.x, 5.x, ...)
 could be also covered under the 7 condition.

Sorry, I did not take those into account as I don't have those  
versions to test so I was not sure if they include the 'Idrop' field  
in their netstat output.

As a quick note, from what I know FreeBSD always has three versions  
supported at one time, at the moment, that is 7 (legacy), 8 (standard)  
and 9 (experimental, next generation). As far as I can tell, this  
means any version older than 7 is no longer supported by security  
patches or the ports system. So I'm not sure if you want to support  
versions earlier than 7, but it is up to you. It is easy to do it in  
this case but if there are other issues with FreeBSD that are version  
dependent, it might be an issue then.

 Also, assuming the 'Idrop' column will continue existing from now on,
 the next version 9 won't be covered by this patch forcing to add another
 patch to the code.

 I was thinking to use right now something like:

 if($kernel_branch  7.2) {
   # has 'Idrop' column
 } else {
   # don't has 'Idrop' column
 }

This makes sense. It should work for most future versions as well. I  
Should have taken that into account!

Best regards,
Sean



--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
Monitorix-general mailing list
Monitorix-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monitorix-general


[Monitorix-general] Network Traffic and Usage Problem Graph, FreeBSD

2011-03-14 Thread strumming

Hello,

First, thank you for creating monitorix. I've used to it monitor  
several CentOS servers I administered for a few years and it has  
proved to be very useful.


I have no idea if I this is the right way to report a bug so my  
apologies if this is the wrong way to go about doing it.


I also happen to administer some FreeBSD systems. I recently found  
what I think is a bug in the code for collecting network statistics  
under FreeBSD. I noticed that the main graph in the Network Traffic  
and Usage graph section is always blank. No traffic is ever logged.  
However, the traffic error section always logs data as if my network  
interface is continually generating packet errors.


I believe I have found the cause of the problem and enclose a patch for it.

I think some of the columns from netstat -nibd are being logged in the  
wrong order -


open(IN, netstat -nibd |);

while(IN) {
if(/Link/  /$NET_LIST[$n]/) {
(undef, undef, undef, undef, $net_packs_in[$n],  
$net_error_in[$n], $net_bytes_in[$n], $net_packs_out[$n],  
$net_error_out[$n], $net_bytes_out[$n]) = split(' ', $_);

}
}

compare this with the actual output of a netstat -nibd command :

NameMtu Network   Address  Ipkts Ierrs Idrop  
IbytesOpkts Oerrs Obytes  Coll Drop
ipfw0 65536 Link#1   0 0 0
   00 0  0 00
lo0   16384 Link#2   0 0 0
   00 0  0 00
lo0   16384 fe80:2::1/64  fe80:2::10 - -
   00 -  0 --
lo0   16384 ::1/128   ::1  0 - -
   00 -  0 --
lo0   16384 127.0.0.0/8   127.0.0.10 - -
   00 -  0 --
em01500 Link#3  08:00:27:09:3e:7c30976 0 0
4368417221128 01183551 00
em01500 192.168.10.0/24   192.168.10.15 30970 - -
4324873121126 - 887703 --


$net_packs_in[$n] = Ipkts (correct)
$net_packs_error_in[$n] = Ierrs (correct)
$net_bytes_in[$n] = Idrop (should be Ibytes, next column)
$net_packs_out[$n] = Ibytes (should be Opkts, next column)

etc

The solution is to add one more undef after $net_error_in[$n] thus :

if(/Link/  /$NET_LIST[$n]/) {
 (undef, undef, undef, undef, $net_packs_in[$n],  
$net_error_in[$n], undef, $net_bytes_in[$n], $net_packs_out[$n],  
$net_error_out[$n], $net_bytes_out[$n]) = split(' ', $_);

 }

I first noticed this on version 1.5.1 (FreeBSD ports) and it still  
appears to be there in v. 2.0.0 and 2.1.0 (source), which I am now  
running.


Best regards,
Sean
--- monitorix.org   2011-03-14 16:38:51.0 +0800
+++ monitorix   2011-03-14 16:38:22.0 +0800
@@ -1973,7 +1973,7 @@
open(IN, netstat -nibd |);
while(IN) {
if(/Link/  /$NET_LIST[$n]/) {
-   (undef, undef, undef, undef, 
$net_packs_in[$n], $net_error_in[$n], $net_bytes_in[$n], $net_packs_out[$n], 
$net_error_out[$n], $net_bytes_out[$n]) = split(' ', $_);
+   (undef, undef, undef, undef, 
$net_packs_in[$n], $net_error_in[$n], undef, $net_bytes_in[$n], 
$net_packs_out[$n], $net_error_out[$n], $net_bytes_out[$n]) = split(' ', $_);
last;
}
}
--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d___
Monitorix-general mailing list
Monitorix-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monitorix-general