have written a check_sendmail in Solaris plugin

Mika Borner Mika.Borner at clariden.com
Tue Aug 8 14:45:34 CEST 2006


Hi

The "correct" way to check the SMF Repository for the state of sendmail
(or any other service) is:

svcprop -c svc:/network/smtp:sendmail/:properties/restarter/state

Regards
Mika


>>> "Alexander Harvey" <alexh19740110 at gmail.com> 08/08/06 2:11 pm >>>
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


-------------------------------------------------------------------------
This message is intended for the addressee only and may
contain confidential or privileged information. If you
are not the intended receiver, any disclosure, copying
to any person or any action taken or omitted to be taken
in reliance on this e-mail, is prohibited and may be un-
lawful. You must therefore delete this e-mail.
Internet communications may not be secure or error-free
and may contain viruses. They may be subject to possible
data corruption, accidental or on purpose. This e-mail is
not and should not be construed as an offer or the
solicitation of an offer to purchase or subscribe or sell
or redeem any investments.
-------------------------------------------------------------------------


-------------------------------------------------------------------------
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
_______________________________________________
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