We have written a script that monitors bandwidth usage on a lot of different ports on a lot of different hosts. In total we have 116 servicechecks now.
All of them have an output like this: OK: RX: 1% TX: 3%
The check allows us to give information on each switchport and the bandwidth used.
Now I would like to make a top 10 of the most busiest ports.
Is there anything available to create a top 10 on service chacks?
Best regards,
Rob Hassing
Top 10 bandwidth usage
Top 10 bandwidth usage
Rob Hassing


-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Top 10 bandwidth usage
Not with core by default. Are you using PNP or anything to store your performance data? You would almost definitely be able to poll those files for the needed information. You could probably rip it out of nagios logs or the last 12 checks out of retention.dat, but both of those are less than ideal solutions.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: Top 10 bandwidth usage
I found a way to get the information from all rrd files:
Code: Select all
for x in /var/spool/sflow/rrd/*.rrd; do
rrdtool graph /dev/null \
--start -360 --end -120 --step 20 \
DEF:bytesIn=$x:bytesIn:AVERAGE \
CDEF:bpsIn=bytesIn,8,* \
VDEF:bpsInmax=bpsIn,MAXIMUM \
PRINT:bpsInmax:$x=%lf
done \
| grep = \
| sort -t= -nrk 2 \
| head -10 > /tmp/top10in.txtCode: Select all
<?php
echo "<h1>Top 10</h1>";
echo "<table cellpadding=0 cellspacing=0 border=0>";
echo "<tr><td>Incoming:</td></tr>";
$lines = file('/tmp/top10in.txt');
foreach ($lines as $line_num => $line) {
preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $line, $ip);
preg_match("/\d{1,3}\.rrd/", $line, $ports);
preg_match("/\d{1,3}/", $ports[0], $port);
$host = exec("grep $ip[0] /etc/hosts | awk '{print $2}'");
echo "<tr><td><a href=\"http://10.35.3.244/sflow/index.php?hostname=$host&agent=$ip[0]&if=$port[0]\">$host - $port[0]</a><br></td></tr>\n";
}
?>Rob Hassing


Re: Top 10 bandwidth usage
Thanks for sharing your solution! Did that get you everything you needed? If so I'll close the thread.
Former Nagios employee