#!/bin/bash # # Process monitor plugin for Nagios # Written by Thomas Sluyter (nagios@kilala.nl) # By request of KPN-IS, i-Provide, the Netherlands # Last Modified: 13-07-2006 # # Usage: ./check_solaris_processes # # Description: # This script couldn't be simpler than it is. It just checks to see # whether a predefined list of processes is up and running. # # Limitations: # This script should work properly on all implementations of Linux, Solaris # and Mac OS X. # # Output: # If there one of the processes is down, a CRIT is issued. # # You may have to change this, depending on where you installed your # Nagios plugins PROGNAME="check_linux_processes" PATH="/usr/bin:/usr/sbin:/bin:/sbin" LIBEXEC="/usr/local/nagios/libexec" . $LIBEXEC/utils.sh ### DEFINING THE PROCESS LIST ### LIST="init" ### REQUISITE NAGIOS COMMAND LINE STUFF ### print_usage() { echo "Usage: $PROGNAME" echo "Usage: $PROGNAME --help" } print_help() { echo "" print_usage echo "" echo "Basic processes list monitor plugin for Nagios" echo "" echo "This plugin not developped by the Nagios Plugin group." echo "Please do not e-mail them for support on this plugin, since" echo "they won't know what you're talking about :P" echo "" echo "For contact info, read the plugin itself..." } while test -n "$1" do case "$1" in --help) print_help; exit $STATE_OK;; -h) print_help; exit $STATE_OK;; *) print_usage; exit $STATE_UNKNOWN;; esac done ### FINALLY THE MAIN ROUTINE ### COUNT="0" DOWN="" for PROCESS in `echo $LIST` do if [ `ps -ef | grep -i $PROCESS | grep -v grep | wc -l` -lt 1 ] then let COUNT=$COUNT+1 DOWN="$DOWN $PROCESS" fi done if [ $COUNT -gt 0 ] then echo "NOK - $COUNT processes not running: $DOWN" exit $STATE_CRITICAL fi # Nothing caused us to exit early, so we're okay. echo "OK - All requisite processes running." exit $STATE_OK