eventhandler script

Jasmine Chua jasmine.chua at securecirt.com
Wed Dec 11 23:42:41 CET 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all..
I am trying to tell Nagios to talk to a remote server's NRPE daemon to restart 
a program when remote server's load service is heavy.. apparently my event 
handler is not working. Nagios is not talking to the remote server at all. 
Below is my script to talk to the NRPE daemon. Just wondering if anyone can 
provide me with some tips or point out any mistakes that I made in the 
script. Because I suspect that this script is not working at all! 

Any help is truly appreciated! Sorry.


#!/bin/sh
#
# Event handler script for calling xxx.xxx.xxx.xxx NRPE daemon to restart  
#program
#
# Note: This script will only call to restart program if the load service is
# retried 3 times (in a "soft" state) or if the load service
# falls into a "hard" error state
#

# Arguments:
# $1 = service_state
# $2 = state_type
# $3 = service_attempt

hostname="xxx.xxx.xxx.xxx"
checknrpedir="/usr/local/nagios/libexec"

# What state is the load service in?

case "$1" in
        OK)
                # There is no need to do anything.
                # The service is OK.

        ;;
        WARNING)
                # There is no need to do anything still.
                # The service is just in WARNING state.

        ;;
        UNKNOWN)
                # No need for anything because we dont really know
                # the exact problem.

        ;;
        CRITICAL)
                # The Load is heavy. There is a need to restart program.

                # See the state type if it is soft or hard?
                case "$2" in

                        SOFT)
					 # Determine the number of service attempts.
                                # Only restart program if its the 3rd attempt
                                # to confirm that it is really critical

                                case "$3" in

                                        3)

                         $checknrpedir/check_nrpe $hostname -c "check-program"

                                        ;;

                                esac
                        ;;
                        HARD)
                                        # If the check has tried 4 times and
                                        # the check still fails it will fall
                                        # into hard state. But normally the
                                        # 3rd try should restart program and
                                        # solve the load problem.

                        $checknrpedir/check_nrpe  $hostname -c "check-program"

                        ;;
                esac
        ;;
esac
exit 0

- -- 
Jasmine Chua
Security Engineer, SecureCiRT (A SBU of Z-Vance Pte Ltd)
http://www.securecirt.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9979lNgvTa7Hj2AURAgDiAKCcdh3qxe6AzPPYlElJX7CE3Hvl6gCdFeTD
NomoG/aSez82sEXvjE4mGwQ=
=b2S8
-----END PGP SIGNATURE-----



-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility 
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/




More information about the Users mailing list