Page 1 of 1

ifIndex to be display in Bandwidth check

Posted: Fri Jan 30, 2015 3:05 pm
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

Re: ifIndex to be display in Bandwidth check

Posted: Fri Jan 30, 2015 3:17 pm
by scottwilkerson
Can you share which plugin you are trying to modify?

Re: ifIndex to be display in Bandwidth check

Posted: Sat Jan 31, 2015 3:57 am
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

Re: ifIndex to be display in Bandwidth check

Posted: Mon Feb 02, 2015 12:08 pm
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.

Re: ifIndex to be display in Bandwidth check

Posted: Tue Feb 03, 2015 1:22 pm
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