ifIndex to be display in Bandwidth check

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

ifIndex to be display in Bandwidth check

Post by zaji_nms »

Dear Expert

When checking Service Status (IfOperStatus) in the result there is If-Index which is very helpful info, the same way we want to display in the Service Bandwidth (check_rrdtraf).

I tried as below but its giving full path of the file which is clumsy
echo -n "$FILE OK - Current BW

I want to show something as below if FILE = var/lib/mrtg/tst-7200-1_235.rrd
(ifindx 235) OK - Current BW <<< including braces(brackets) so ifINDEX will show as a separate entity.
need to manipulate $FILE and extract substring between _ and .

I tried googling but not very successful...Appreciate your solution (string manipulation).

Regards
Zajil NMS
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: ifIndex to be display in Bandwidth check

Post by scottwilkerson »

Can you share which plugin you are trying to modify?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
zaji_nms
Posts: 616
Joined: Tue Oct 16, 2012 12:28 am

Re: ifIndex to be display in Bandwidth check

Post by zaji_nms »

Dear scottwilkerson

I have mentioned, once again

check_xi_service_mrtgtraf
$USER1$/check_rrdtraf -f /var/lib/mrtg/$ARG1$ -w $ARG2$ -c $ARG3$ -l $ARG4$

$ARG1$=tst-7200-1_235.rrd

Previously I mentioned only part of last line, now please find some of last lines of CHECK_RRDTRAF

more /usr/local/nagios/libexec/check_rrdtraf

echo "out=$(echo "scale=6; ($VALUEOUT/$SDIVOUT)"| bc)$SLABELOUT""b/s;$OUTWARN;$OUTCRIT"
exit $STATE_WARNING
else
echo -n "OK - Current BW in: $(echo "scale=$SCALE; ($VALUEIN/$SDIVIN)"| bc)"$SLABELIN"bps Out: $(echo "scale=
$SCALE; ($VALUEOUT/$SDIVOUT)"| bc)"$SLABELOUT"bps"

echo -n "|in=$(echo "scale=6; ($VALUEIN/$SDIVIN)"| bc)$SLABELIN""b/s;$INWARN;$INCRIT "
echo "out=$(echo "scale=6; ($VALUEOUT/$SDIVOUT)"| bc)$SLABELOUT""b/s;$OUTWARN;$OUTCRIT"
exit $STATE_OK

Regards
Zajil NMS
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: ifIndex to be display in Bandwidth check

Post by tmcdonald »

You will need to use some sed/awk magic to get that value out. You will essentially be looking for an underscore, some number of digits, then ".rrd" and pulling out the digits.
Former Nagios employee
zaji_nms
Posts: 616
Joined: Tue Oct 16, 2012 12:28 am

Re: ifIndex to be display in Bandwidth check

Post by zaji_nms »

Thanks tmcdonald

done.....Please close the case.

ZUSSTRNG=`echo $FILE| cut -d'_' -f 2`
ZUSSTRNG=`echo $ZUSSTRNG| cut -d'.' -f 1`

Regards
Zajil NMS
Locked