6
# Program: Process running check plugin for Nagios
8
# Copyright (c) 2002 Jerome Tytgat (j.tytgat@sioban.net)
10
# check_procr.sh,v 1.0 2002/09/18 15:28
14
# This plugin check if at least one process is running
18
# check_procr.sh -p process_name
22
# To know if snort is running
23
# check_procr.sh -p snort
24
# > OK - total snort running : PID=23441
31
echo " $0 -p <process_name>"
32
echo " $0 (-v | --version)"
33
echo " $0 (-h | --help)"
37
echo "check_procr.sh (nagios-plugins) 1.0"
38
echo "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute"
39
echo "copies of the plugins under the terms of the GNU General Public License."
40
echo "For more information about these matters, see the file named COPYING."
41
echo "Copyright (c) 2002 Jerome Tytgat - j.tytgat@sioban.net"
42
echo "Greetings goes to Websurg which kindly let me took time to develop this"
43
echo " Manu Feig and Jacques Kern who were my beta testers, thanks to them !"
47
needed="bash cut egrep expr grep let ps sed sort tail test tr wc"
48
for i in `echo $needed`
50
type $i > /dev/null 2>&1 /dev/null
53
echo "I am missing an important component : $i"
54
echo "Cannot continue, sorry, try to find the missing one..."
64
if [ "$1" = "-h" -o "$1" = "--help" ]
68
echo "This plugin will check if a process is running."
72
echo "Required Arguments:"
73
echo " -p, --process STRING"
74
echo " process name we want to verify"
79
if [ "$1" = "-v" -o "$1" = "--version" ]
85
if [ `echo $@|tr "=" " "|wc -w` -lt 2 ]
87
echo "Bad arguments number (need two)!"
94
exclude_process_name=""
98
# Test of the command lines arguments
104
if [ -n "$process_name" ]
106
echo "Only one --process argument is useful..."
111
process_name="`echo $1|tr \",\" \"|\"`"
114
echo "Unknown argument $1"
122
# ps line construction set...
123
for i in `ps ho pid -C $process_name`
125
pid_list="$pid_list $i"
128
if [ -z "$pid_list" ]
135
# Finally Inform Nagios of what we found...
138
echo "CRITICAL - process $process_name is not running !"
141
echo "OK - process $process_name is running : PID=$pid_list "
145
# Hey what are we doing here ???