Aggregate / consolidated graph of many links

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
zaji_nms
Posts: 616
Joined: Tue Oct 16, 2012 12:28 am

Aggregate / consolidated graph of many links

Post by zaji_nms »

Dear Forum/Expert

We were looking for long time as a single combined one utilization (performance) graph of many links. Me tried as below and its okay for us. If there is valuable feedback, most welcome.

FYI, the main three lines from check_rrdtraf

Its very basic just first level (me not an expert) and looking forward from NagiosXI to add as a robust feature.

As this is Host independent, can be added as a Service under any Host.

more /usr/local/nagios/libexec/all_stm16_bw

#!/bin/sh
let TOTALIN=0;TOTALOUT=0
fetchinoutval ()
{
DATASET=`rrdtool fetch $FILE AVERAGE -s-10minutes| grep -vi "nan"`
VALUEIN=`echo "$DATASET" | awk '{x=$2} END { printf("%f\n", x * 8) }'`
VALUEOUT=`echo "$DATASET" | awk '{x=$3} END { printf("%f\n", x * 8) }'`

TOTALIN=`echo $TOTALIN+$VALUEIN | bc`
TOTALOUT=`echo $TOTALOUT+$VALUEOUT | bc`
}
FILE="/var/lib/mrtg/lon-jnpr_111.rrd"
fetchinoutval

FILE="/var/lib/mrtg/tok-7600_222.rrd"
fetchinoutval

FILE="/var/lib/mrtg/nyc-jnpr_333.rrd"
fetchinoutval

TOTALIN=`echo "scale=3;$TOTALIN/1000000000" | bc -l`
TOTALOUT=`echo "scale=3;$TOTALOUT/1000000000" | bc -l`

echo ""Gb:In/Out = $TOTALIN / $TOTALOUT" | InGbps=$TOTALIN OutGbps=$TOTALOUT"

exit

Regards
Zajil NMS
cmerchant
Posts: 546
Joined: Wed Sep 24, 2014 11:19 am

Re: Aggregate / consolidated graph of many links

Post by cmerchant »

Zaji, thank you for your code suggestion. I understand this is a basic approach for your graph consolidation. Did you want this to feedback into a normal check?
I might suggest using an event handler. You could add a $BASEDIR for the /var/lib/mrtg/ and could add a parameter list of hosts or hostip addresses, and a check for if file exists. I'm not sure where you would add your virtual (consolidated) host/service. Will leave this open for further comments. Thanks.
zaji_nms
Posts: 616
Joined: Tue Oct 16, 2012 12:28 am

Re: Aggregate / consolidated graph of many links

Post by zaji_nms »

Dear Expert

Please close the Post.

The above script is robust from rrd however below manual script also working fine (tested) , last time I was trying but not giving correct result, two things I changes and its okay now.

In my previous script I took ifInOctets which was wrong as its Giga port and must use ifHCInOctets
Second mistake calculation , so subtraction & multiply/divide which I broke and its okay

If repeated code put in a function, script can be short.

more /usr/local/nagios/libexec/customer_52_53_inet
#!/bin/sh
oneIN1=`snmpwalk -v 2c -c public rtr1-jnpr-1 ifHCInOctets.52`
oneIN2=`snmpwalk -v 2c -c public rtr2-jnpr-2 ifHCInOctets.53`
oneOUT1=`snmpwalk -v 2c -c public rtr1-jnpr-1 ifHCOutOctets.52`
oneOUT2=`snmpwalk -v 2c -c public rtr2-jnpr-2 ifHCOutOctets.53`
let slptm=27
sleep $slptm
twoIN1=`snmpwalk -v 2c -c public rtr1-jnpr-1 ifHCInOctets.52`
twoIN2=`snmpwalk -v 2c -c public rtr2-jnpr-2 ifHCInOctets.53`
twoOUT1=`snmpwalk -v 2c -c public rtr1-jnpr-1 ifHCOutOctets.52`
twoOUT2=`snmpwalk -v 2c -c public rtr2-jnpr-2 ifHCOutOctets.53`
oneIN1=`echo $oneIN1| cut -d':' -f 4`
oneIN2=`echo $oneIN2| cut -d':' -f 4`
twoIN1=`echo $twoIN1| cut -d':' -f 4`
twoIN2=`echo $twoIN2| cut -d':' -f 4`
oneOUT1=`echo $oneOUT1| cut -d':' -f 4`
oneOUT2=`echo $oneOUT2| cut -d':' -f 4`
twoOUT1=`echo $twoOUT1| cut -d':' -f 4`
twoOUT2=`echo $twoOUT2| cut -d':' -f 4`
ZUSIN1=`echo $twoIN1-$oneIN1 | bc`
ZUSIN1=`echo $ZUSIN1*8/$slptm | bc`
ZUSIN2=`echo $twoIN2-$oneIN2 | bc`
ZUSIN2=`echo $ZUSIN2*8/$slptm | bc`
ZUSOUT1=`echo $twoOUT1-$oneOUT1 | bc`
ZUSOUT1=`echo $ZUSOUT1*8/$slptm | bc`
ZUSOUT2=`echo $twoOUT2-$oneOUT2 | bc`
ZUSOUT2=`echo $ZUSOUT2*8/$slptm | bc`
FINALIN=`echo $ZUSIN1+$ZUSIN2 | bc`
FINALIN=`echo $FINALIN/1000000 | bc`
FINALOUT=`echo $ZUSOUT1+$ZUSOUT2 | bc`
FINALOUT=`echo $FINALOUT/1000000 | bc`
echo ""Mbps:In/Out $FINALIN / $FINALOUT" | InMbps=$FINALIN OutMbps=$FINALOUT"
exit 0

Regards
Zajil NMS
Locked