diff options
Diffstat (limited to 'examples/Nagios/cleware_nagios_script')
-rwxr-xr-x | examples/Nagios/cleware_nagios_script | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/Nagios/cleware_nagios_script b/examples/Nagios/cleware_nagios_script new file mode 100755 index 0000000..812cce7 --- /dev/null +++ b/examples/Nagios/cleware_nagios_script @@ -0,0 +1,34 @@ +#!/bin/sh + +if [ -z "$1" -o -z "$2" ] ; then + echo "CRITICAL - Parameter(s) missing (Warning Critical)." + exit 2 +fi + +PARAM1=`echo $1 | tr -c -d [:digit:]` +PARAM2=`echo $2 | tr -c -d [:digit:]` + +if [ "$1" != "$PARAM1" -o "$2" != "$PARAM2" ] ; then + echo "CRITICAL - invalid parameter(s), only integers allowed." + exit 2 +fi + +MEASURED_TEMPERATURE=`/usr/bin/clewarecontrol -rt 2> /dev/null | grep 'Temperature' | awk '{ print $2; }'` + +NAGIOS_TEMPERATURE=`echo $MEASURED_TEMPERATURE | sed -e "s/^\([0-9]*\).*$/\1/g"` +if [ -z "$NAGIOS_TEMPERATURE" ] ; then + echo CRITICAL - invalid temperature $MEASURED_TEMPERATURE + exit 2 +fi +if [ $NAGIOS_TEMPERATURE -gt $2 ] ; then + echo CRITICAL - temperature above $2 - $MEASURED_TEMPERATURE + exit 2 +fi + +if [ $NAGIOS_TEMPERATURE -gt $1 ] ; then + echo WARNING - temperature above $1 - $MEASURED_TEMPERATURE + exit 1 +fi + +echo OK - temperature is $MEASURED_TEMPERATURE +exit 0 |