have written a check_sendmail in Solaris plugin
Alexander Harvey
alexh19740110 at gmail.com
Tue Aug 8 14:11:40 CEST 2006
Hi All,
I've just written a check_sendmail plugin shell script for Solaris; I'm
wondering if anyone has any thoughts for improving it (be as pedantic as you
like), problems with it, etc. Alternatively, if anyone wants to use it
themselves.
To use the plugin via nrpe
** you must give the nagios user on the remote host
** you must give the nagios user sudo access to run this script as root
without password
Kind Regards,
Alex
#!/bin/ksh
# check_sendmail
# author: alex harvey
# email: alexh19740110 at gmail.com
die=false
OS=`uname -r`
# first check status according to SMF if we're in Solaris 10
if [ "$OS" == "5.10" ]; then
svcs -l sendmail >|/tmp/check_sendmail.tmp.1 2>&1
smf_enabled=`cat /tmp/check_sendmail.tmp.1 | awk '{if ($1 == "enabled")
print $2}'`
smf_state=`cat /tmp/check_sendmail.tmp.1 | awk '{if ($1 == "state") print
$2}'`
if [ "$smf_enabled" == "false" ]; then
echo WARNING [ Disabled by SMF ]
exit 1
fi
# $smf_enabled must be "true"
if [ "$smf_state" != "online" ]; then
echo WARNING [ SMF reports state $smf_state ]
exit 1
fi
# $smf_enabled must be "true" and $smf_state must be "online"
sendmail_pid_file=/var/run/sendmail.pid
client_pid_file=/var/spool/clientmqueue/sm-client.pid
if [ ! -e $sendmail_pid_file ]; then
messpart1="and $sendmail_pid_file "
die=true
fi
if [ ! -e $client_pid_file ]; then
messpart1="$messpart1 and $client_pid_file"
die=true
fi
messpart1=`echo $messpart1 | sed -e 's/^and //'`
mess1="$messpart1 not found!"
[ $die == "true" ] && echo CRITICAL [ $mess1 ] && exit 2
fi
# now check that both processes are running
sendmail_pid=`cat /var/run/sendmail.pid | head -1`
sendmail_cmd=`cat /var/run/sendmail.pid | tail -1`
client_pid=`cat /var/spool/clientmqueue/sm-client.pid | head -1`
client_cmd=`cat /var/spool/clientmqueue/sm-client.pid | tail -1`
ps -ef | egrep "${sendmail_pid}.*${sendmail_cmd}" >/dev/null 2>&1
RC1=$?
ps -ef | egrep "${client_pid}.*${client_cmd}" >/dev/null 2>&1
RC2=$?
if [ $RC1 -ne 0 ]; then
messpart2="and daemon "
die=true
fi
if [ $RC2 -ne 0 ]; then
messpart2="$messpart2 and client"
die=true
fi
messpart2=`echo $messpart2 | sed -e 's/^and //'`
mess2="sendmail $messpart2 is not running!"
[ $die == "true" ] && echo CRITICAL [ $mess2 ] && exit 2
# otherwise exit OK
echo OK && exit 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20060808/a1f81d56/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
-------------- next part --------------
_______________________________________________
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