Check_vnstat small contribution + question ofcourse
Mestdagh Tommy
Tommy.Mestdagh at geosolutions.be
Tue Apr 24 11:27:19 CEST 2007
I know this is not the right place for this, but this is but i have made
a (my first ) nagios plugin.
Vnstat monitors networktraffic for a specified nic. And this plugins
notifies when the daily traffic gets to much.
I noticed one problem. When the traffic exceeds the 1Gb the numberformat
changes. I fixed that but when the vnstat returns exactly 1000 MB or
2000MB
The plugin fails tho add this traffic=$(($traffic + $mb)) because $MB
is zero, a hint from a scripting expert would be nice.
TM
#!/bin/bash
warn=$1
critical=$2
eth="eth0"
eth=$3
if [ "$1" -eq 0 ]
then
echo "invalid use no warn value"
fi
if [ "$2" -eq 0 ]
then
echo "invalid use no critical value"
fi
#if [ "${#$eth}" -eq 0 ]
# then
# eth="eth0"
#else
# eth=$3
#fi
line=`/usr/bin/vnstat -s -i $eth | grep today`
#echo $line
traffic=${line:44:9}
traffic=`echo ${traffic}`
#echo $traffic + "traffic gelezen"
gigabyte=`expr index $traffic ","`
if [ $gigabyte -gt 0 ]
then
#echo "more than a giga traffic "
giga=${traffic:0:1}
mb=${traffic:2}
mb=`echo ${mb}`
#echo "aantal giga :" + $giga
traffic=$(($giga * 1000))
#echo "aantal mb :" + $mb
traffic=$(($traffic + $mb))
#echo $traffic + " in MB"
fi
traffic=${traffic/.*}
#let traffic=$traffic /1
#echo "current traffic :" + $traffic
if [ "$traffic" -gt "$2" ]
then
echo "Critical;current = $traffic;" + $line
exit 2
fi
if [ "$traffic" -gt "$1" ]
then
echo "Warning;current = $traffic;" + $line
exit 1
else
echo "OK;current = $traffic;" + $line
exit 0
fi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20070424/8a1b74c2/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list