Now the client/bin/nagcollecttest script can be used as a "nagios plugin
wrapper", for example you can use
define command {
command_name nagcollect
command_line /usr/local/sbin/nagcollecttest $ARG1$
}
define command {
command_name ssh_nagcollect
command_line /usr/lib/nagios/plugins/check_by_ssh -t 60 -l root \
-H '$HOSTADDRESS$' -C '/usr/local/sbin/nagcollecttest $ARG1$'
}
in your Nagios configuration to define check commands that use the
NagCollect plugins on the local and remote hosts.
+if [ "$1" = "-v" ]; then
+ VERBOSE=1
+ shift
+fi
- echo "Usage: $NAME <scriptname>"
- exit 2
+ echo "Usage: $NAME [-v] <scriptname>"
+ exit 3
fi
if [ `id -u` -ne 0 ]; then
echo "$NAME must be run as root!"
fi
if [ `id -u` -ne 0 ]; then
echo "$NAME must be run as root!"
fi
if [ -r /usr/local/lib/nagcollect/"$1.tst" ]; then
fi
if [ -r /usr/local/lib/nagcollect/"$1.tst" ]; then
tst=/usr/local/lib/nagcollect/`uname`/"$1.tst"
else
echo "$NAME: script \"$1\" not found!"
tst=/usr/local/lib/nagcollect/`uname`/"$1.tst"
else
echo "$NAME: script \"$1\" not found!"
fi
SERVICE=""; STATUS=""; TEXT=""
fi
SERVICE=""; STATUS=""; TEXT=""
-echo "Checking \"$tst\" ..."
+[ -n "$VERBOSE" ] && echo "Checking \"$tst\" ..."
-[ -n "$STATUS" -o -n "$TEXT" ] \
- && echo "RESULT: $SERVICE=$STATUS \"$TEXT\"" \
- || echo "NO result ..."
+if [ "$VERBOSE" ]; then
+ [ -n "$STATUS" -o -n "$TEXT" ] \
+ && echo "RESULT: $SERVICE=$STATUS \"$TEXT\"" \
+ || echo "NO result ..."
+else
+ [ -n "$TEXT" ] \
+ && echo "$TEXT" \
+ || echo "$NAME: \"$1\" returned no result?"
+fi
+
+[ -n "$STATUS" ] \
+ && exit "$STATUS" \
+ || exit 3