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

2011-03-15 Thread Jordi Sanfeliu
Hello Sean,

strumm...@thestrings.com wrote:
[...]
 
 it appears that the format of the netstat -i output changed in FreeBSD 
 8 to include that 'Idrop' column.
 
 So, perhaps an easy way to fix this is to use different code to process 
 the output for netstat -nibd based on the version of FreeBSD used? I've 
 attached a patch which seems to do the trick for me.
 

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.

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 will ensure that even versions prior 7 could be supported assuming 
they still have the same column layout as the 7 version. So they should 
work without any problem.

Also it ensures that assuming the 'Idrop' column will exist in newer 
versions, they will be covered as long as the FreeBSD guys don't include 
an extra column.

Let me know what do you think about all of this.
Many thanks.

-- 
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
https://lists.sourceforge.net/lists/listinfo/monitorix-general


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


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