Help with eventhandlers

Carole Gimenez gimenez at cict.fr
Thu Dec 6 18:07:30 CET 2007


Hi,

For some time, i execute severals evenhandlers to restart services. Now, 
i would send an email when an eventhandler is executed. So, in commands 
file, i modified my eventhandler 'restart-httpd-test' like this:
usr/local/nagios/libexec/eventhandlers/restart-httpd-test $SERVICESTATE$ 
$STATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$ $HOSTNAME$ $CONTACTEMAIL$ 2>> 
/usr/local/nagios/tmp/httpd-test.log

My problem is that i don't arrive to recovered the macro $CONTACTEMAIL$.

My script looks at that:

#!/bin/sh
set -x
contenumail=/usr/local/nagios/tmp/contenumail.txt
sortie=/usr/local/nagios/tmp/sortie.txt
date=`date`
echo $date > $contenumail
echo 'SERVICESTATE : ' $1 >> $contenumail
echo 'STATETYPE: ' $2 >> $contenumail
echo 'SERVICEATTEMPT: ' $3 >> $contenumail
echo 'HOSTADDRESS: ' $4 >> $contenumail
echo 'CONTACTEMAIL: ' $6
echo 'CONTACTEMAIL: ' "$6"

# What state is the HTTP service in?
case "$1" in
CRITICAL)
        case "$2" in
        SOFT)
                case "$3" in
                2)
                        echo "Restarting HTTP service (3rd soft critical 
state)..." >> $contenumail
                        # Call the init script to restart the HTTPD server
                        /usr/local/bin/ssh root@$4 /etc/init.d/httpd 
restart > $sortie
                        cat $sortie >> $contenumail
                        /usr/bin/mailx -s "Redemarrage du service HTTP 
sur $5" "$6" < $contenumail
                        ;;
                        esac
                ;;
        HARD)
                echo "Restarting HTTP service..." >> $contenumail
                # Call the init script to restart the HTTPD server
                /usr/local/bin/ssh root@$4 /etc/init.d/httpd-webmail 
restart > $sortie
                cat $sortie >> $contenumail
                /usr/bin/mailx -s "Redemarrage du service HTTP sur $5" 
"$6" < $contenumail
                ;;
        esac
        ;;
esac
exit 0

And my log file:
date=Thu Dec  6 18:05:40 MET 2007
+ echo Thu Dec 6 18:05:40 MET 2007
+ echo SERVICESTATE :  CRITICAL
+ echo STATETYPE:  SOFT
+ echo SERVICEATTEMPT:  2
+ echo HOSTADDRESS:  130.120.74.17
+ echo CONTACTEMAIL:
+ echo CONTACTEMAIL:
+ echo Restarting HTTP service (3rd soft critical state)...
+ /usr/local/bin/ssh root at 130.120.74.17 /etc/init.d/httpd-webmail restart
+ cat /usr/local/nagios/tmp/sortie.txt
+ /usr/bin/mailx -s Redemarrage du service HTTP sur pc-systeme.cict.fr
+ exit 0


Thanks for advance for your help.

Carole.


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
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