The easiest way to write a nagios script is something like this (if you want to monitor processes)
# This is the variable which contains the first argument passed to the bash script.
# Check to see if the process is found in the process list
ps aux |grep -i "$proc" &> /dev/null
# Grep returns 0 if something is found and returns 1 if not.
if [ $? -eq 0 ]; then
echo "Process $proc found."
echo "Process $proc not found"
Usage: ./script.sh httpd
This will only check if the process is found or not, and it will return whichever return code that follows an "exit". I know that Nagios have some diffrent supports for this.
I believe that return code 1 is "normal" and return code 0 is "ok". So you might have to change the "exit 1" to 2 or 3 (2 is warning, 3 is critical).
(Atleast this is what I had to do last time I wrote nagios scripts, thou that was for OpenVMS using perl)