Nagios – NRPE

20 Apr

An NRPE plugin script to monitor any process.
(I couldn’t find the one that did this – i’m pretty sure it must exist tho!)

#! /bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e ‘s,[\/][^\/][^\/]*$,,’`
REVISION=`echo ‘$Revision: 1.2 $’ | sed -e ‘s/[^0-9.]//g’`

. $PROGPATH/utils.sh

print_usage() {
echo “Usage: $PROGNAME”
}

print_help() {
print_revision $PROGNAME $REVISION
echo “”
print_usage
echo “”
echo “This plugin checks to see if a particular process is running.”
echo “”
support
exit 0
}

case “$1” in
–help)
print_help
exit 0
;;
-h)
print_help
exit 0
;;
–version)
print_revision $PROGNAME $REVISION
exit 0
;;
-V)
print_revision $PROGNAME $REVISION
exit 0
;;
*)
processrunning=`ps -ef | grep $1 | grep -v grep | grep -v check_ps | grep -c ${1}`
if [ ${processrunning} -ge 1 ];
then
echo “OK: ${1} running”
exit $STATE_OK
else
echo “CRITICAL: ${1} not running”
exit $STATE_CRITICAL
fi
;;
esac

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: