Page 1 of 1

Bandwidth Report in bits/s instead of bytes/s

Posted: Fri Jan 23, 2015 8:55 am
by logix88
I changed the options for a particular host in /etc/mrtg/conf.d/192.168.10.100.cfg

Options[_]: growright, bits

However the report (Bandwidth Usage report) in Nagios XI still seem to plot in Bytes/sec.

I thought it read cfg file in next sample, i.e. in 5 mins - or is there something else that needs to be changed?

Re: Bandwidth Report in bits/s instead of bytes/s

Posted: Fri Jan 23, 2015 10:56 am
by scottwilkerson
The Bandwidth report doesn't ready the MRTG config, it assumes the default and currently displays "Bytes/s".

Re: Bandwidth Report in bits/s instead of bytes/s

Posted: Fri Jan 23, 2015 11:00 am
by logix88
scottwilkerson wrote:The Bandwidth report doesn't ready the MRTG config, it assumes the default and currently displays "Bytes/s".
And there is no way/hack around this?

Re: Bandwidth Report in bits/s instead of bytes/s

Posted: Fri Jan 23, 2015 11:53 am
by scottwilkerson
You could download the bandwidthreport component, make the changes you like and then re-upload it..

The changes will be made in the index.php file.

Re: Bandwidth Report in bits/s instead of bytes/s

Posted: Fri Jan 23, 2015 12:11 pm
by tmcdonald
Is it actually displaying the bytes/second or is it displaying what appears to be the proper bits/second but the label just says bytes?

If you just need to change the label for one host, you might be able to do something like this:

/usr/local/nagiosxi/html/includes/components/bandwidthreport/index.php ~line 118:

Code: Select all

$fname = filename($name);
            header("content-type: image/png");
            if ($name='192.168.1.100') {
                $rrdcommand = "$rrdcommand graph - -v 'bits/s' -b 1024 -w 390 DEF:avgin=$fname:ds0:AVERAGE AREA:avgin#00CC00:'Traffic in' DEF:avgout=$fname:ds1:AVERAGE LINE2:avgout#0000FF:'Traffic out'";
            } else {
                $rrdcommand = "$rrdcommand graph - -v 'Bytes/s' -b 1024 -w 390 DEF:avgin=$fname:ds0:AVERAGE AREA:avgin#00CC00:'Traffic in' DEF:avgout=$fname:ds1:AVERAGE LINE2:avgout#0000FF:'Traffic out'";
            }
The $name variable I believe is just the name you have set in XI, but I am not 100% sure. I would need to defer to a developer on that.

Re: Bandwidth Report in bits/s instead of bytes/s

Posted: Fri Jan 23, 2015 3:24 pm
by logix88
tmcdonald wrote:Is it actually displaying the bytes/second or is it displaying what appears to be the proper bits/second but the label just says bytes?

If you just need to change the label for one host, you might be able to do something like this:

/usr/local/nagiosxi/html/includes/components/bandwidthreport/index.php ~line 118:

Code: Select all

$fname = filename($name);
            header("content-type: image/png");
            if ($name='192.168.1.100') {
                $rrdcommand = "$rrdcommand graph - -v 'bits/s' -b 1024 -w 390 DEF:avgin=$fname:ds0:AVERAGE AREA:avgin#00CC00:'Traffic in' DEF:avgout=$fname:ds1:AVERAGE LINE2:avgout#0000FF:'Traffic out'";
            } else {
                $rrdcommand = "$rrdcommand graph - -v 'Bytes/s' -b 1024 -w 390 DEF:avgin=$fname:ds0:AVERAGE AREA:avgin#00CC00:'Traffic in' DEF:avgout=$fname:ds1:AVERAGE LINE2:avgout#0000FF:'Traffic out'";
            }
The $name variable I believe is just the name you have set in XI, but I am not 100% sure. I would need to defer to a developer on that.
It's converting to Bytes/sec... and the services are in bits/s and that makes it inconsistent and confusing...

I will have a look at the php... It doesn't need to be for the one host, it could be for all - as all our stuff is in bits/s.

Re: Bandwidth Report in bits/s instead of bytes/s

Posted: Fri Jan 23, 2015 4:18 pm
by logix88
FYI, line 118 - replaced with below alterations to convert to bits/sec.

$rrdcommand = "$rrdcommand graph - -v 'Bits/s' -b 1024 -w 390 DEF:avgin=$fname:ds0:AVERAGE CDEF:avginbits=avgin,8,* AREA:avginbits#00CC00:'Traffic in' DEF:avgo ut=$fname:ds1:AVERAGE CDEF:avgoutbits=avgout,8,* LINE2:avgoutbits#0000FF:'Traffic out'";

Re: Bandwidth Report in bits/s instead of bytes/s

Posted: Mon Jan 26, 2015 10:47 am
by scottwilkerson
@logix88 - Thanks for posting this for others!