[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


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

2011-03-14 Thread Jordi Sanfeliu
Hello Sean,

Many thanks for using Monitorix and for your kind words about it.

Well, I think we have a problem of FreeBSD versions here. Let me show 
what I get issuing the same command as you:

$ netstat -nibd
NameMtu Network   Address  Ipkts Ierrs Ibytes 
  Opkts Oerrs Obytes  Coll Drop
le01500 Link#1  00:0c:29:10:ca:16 5985 0 822418 
   5321 03729407 00
le01500 192.168.1.0/2 192.168.1.162 5686 - 724874 
   5021 -3646513 --
plip0  1500 Link#2   0 0  0 
  0 0  0 00
lo0   16384 Link#36722 0 711434 
   6722 0 711434 00
lo0   16384 fe80:3::1/64  fe80:3::10 -  0 
  0 -  0 --
lo0   16384 ::1/128   ::1 44 -   4724 
 44 -   4724 --
lo0   16384 127.0.0.0/8   127.0.0.1 6678 - 706710 
   6678 - 706710 --

As you can see I don't have the 'Idrop' column in my output, and that's 
probably is the definitive cause of the problem.

I'm not an expert on FreeBSD, well I'm not even an advanced user, so 
perhaps I didn't get the right version of FreeBSD for my testing purposes.

This is the version I have used:
$ uname -a
FreeBSD freebsd.fibranet.lan 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May 
  1 08:49:13 UTC 2009 
r...@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

Please, let me know which you think would be the right steps to fix this 
situation.

Many thanks.
Best regards.



strumm...@thestrings.com wrote:
 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
 

-- 
Jordi Sanfeliu
FIBRANET Network Services Provider
http://www.fibranet.cat


--
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