[Nagiosplug-devel] New plugin
mraus at evkhamm.de
mraus at evkhamm.de
Tue Jan 13 19:01:02 CET 2004
Hi list,
following is a plugin that checks for digital snmp states. I am checking
fans, doors, rooms (movement) and fire-sensors with it. Maybe it is of any
use for you, too.
Greetings,
M.Raus
Germany
---snip---
#! /bin/sh
#
# check_digital (uses check_snmp)
#
# This plugin checks a digital SNMP value. The user may define which numeric
# value should be considered OK and which should be considered as critical.
# Comparison is only done with the critical value. All other values are
# taken to be non-critical.
#
# The user may also define strings to be returned on the OK and CRITICAL
states.
#
# This plugin is usefull for checking doors, rooms, fire-sensors, lights,
fans etc.
#
# Written by Michael H.Raus for KDT Systems Luenen Germany 01/2004
#
PATH=""
ECHO="/bin/echo"
GREP="/bin/grep"
DIFF="/usr/bin/diff"
TAIL="/usr/bin/tail"
CAT="/bin/cat"
RM="/bin/rm"
PROGNAME=`/bin/basename $0`
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 0.1 $' | /bin/sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME -H <hostaddress> -o <SNMP OID> -c <critical
state> -u <OK string> -U <critical string>"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
support
}
# Make sure the correct number of command line
# arguments have been supplied
if [ $# -lt 1 ]; then
print_usage
exit $STATE_UNKNOWN
fi
# Grab the command line arguments
#logfile=$1
#oldlog=$2
#query=$3
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
--version)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
-V)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
-H)
hostadr=$2
shift
;;
-o)
oid=$2
shift
;;
-u)
userok=$2
shift
;;
-U)
usercrit=$2
shift
;;
-c)
critstate=$2
shift
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
exit $STATE_OK
;;
-H)
hostadr=$2
shift
;;
-o)
oid=$2
shift
;;
-u)
userok=$2
shift
;;
-U)
usercrit=$2
shift
;;
-c)
critstate=$2
shift
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
state=`check_snmp -H $hostadr -C public -o $oid`
#echo ergebnis="$state"
case "$state" in
"SNMP OK - "$critstate)
echo $usercrit
exit $STATE_CRITICAL
;;
*)
echo $userok
exit $STATE_OK
;;
esac
exit $exitstatus
---snap---
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: InterScan_Disclaimer.txt
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20040113/d23927ca/attachment.txt>
More information about the Devel
mailing list