Monitoring a group of processes
Werner Flamme
werner.flamme at ufz.de
Thu Dec 15 12:52:13 CET 2005
Kevin Alford schrieb am 14.12.05 14:37:
> I am running nagios 2.0b5 on Fedora core 3. I wanted to know if it is
> capable of monitoring a group of processes?
> An example is smbd and nmbd. You need both of them to be running for
> Samba to be operational. I can use the command
> /usr/local/nagios/libexec/check_procs -C smbd to see that the smbd
> processes are running, and I can do the same thing
> For nmbd, but how do I look at them together? This is just an example.
> I am using this to monitor the project specific
> Application we run, but it involves multiple processes. I would like to
> monitor each process, and report on the application
> Being up as a whole. Your assistance in this matter is greatly
> appreciated.
>
>
>
> Kevin D. Alford
Kevin,
I used check_smb.sh (from the contrib dir in the nagios-plugins package)
and modified a bit. Maybe you can do so too. The modified script runs on
SuSE Linux Enterprise Server.
I had some definitions at the beginning:
BINGREP=`which grep`
BINPS=`which ps`
BINWC=`which wc`
# look if your ps supports the syntax - Solaris does not...
PSCOMMAND="$BINPS ax"
# we need an output with the name of the process, so you
# may adapt "ps ax" to what your system understands :-)
and then I modified the checks:
#
# No arguments. Let's kick this pig.
#
# is smbd running? Count everything with "smbd" inside:
SMBDRUN=$($PSCOMMAND | $BINGREP smbd | wc -l)
# now we subtract "ps ax":
SMBDRUN=$[$SMBDRUN-1]
#
# Ok, now let's grab a count of nmbd processes.
#
NMBDRUN=$($PSCOMMAND | $BINGREP nmbd | wc -l)
# now we subtract "ps ax" again:
NMBDRUN=$[$NMBDRUN-1]
#
# now for the dismount.
#
#echo "Total Users:$total_users Total Files:$total_files"
echo "SMB-Procs: $SMBDRUN - NMB-Procs: $NMBDRUN"
# if any of NMBDRUN or SMBDRUN equals zero, ALLPROC will become zero too:
ALLPROC=$[$NMBDRUN*$SMBDRUN]
#
# let Nagios know that everything is ok - or not...
#
# either nmbd or smbd is (or both are) not running
if [ $ALLPROC -eq 0 ]; then
exit $STATE_CRITICAL
# maybe you want to see a warning when there is only
# 1 smbd and 1 nmbd running? Then de-comment next 2 lines:
#elif [ $ALLPROC -lt 2 ]; then
# exit $STATE_WARNING
# and in any other case I assume everything is OK...
else
exit $STATE_OK
fi
So I fairly agree with Cal Evans: "Shamelessly stolen from other Nagios
plugins."
HTH,
Werner
--
Werner Flamme, Abt. WKDV
UFZ Umweltforschungszentrum Leipzig-Halle GmbH
Permoserstr. 15, 04318 Leipzig
eMail: werner.flamme at ufz.de, Tel.: (0341) 235-2500
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list