X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fevent_handlers%2Fdsa-eventhandler-restart-service;h=28dfd903f65e9d4fe9dc6b62d3658184e29509e7;hb=29a608d713622f1ecdfacd2bdd88797c928dde40;hp=278ddeee20c33388f500979dc4f293999d1dd2e0;hpb=8cf0eb595cc722da0dc9b88235138806b88d937c;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/event_handlers/dsa-eventhandler-restart-service b/dsa-nagios-checks/event_handlers/dsa-eventhandler-restart-service index 278ddee..28dfd90 100755 --- a/dsa-nagios-checks/event_handlers/dsa-eventhandler-restart-service +++ b/dsa-nagios-checks/event_handlers/dsa-eventhandler-restart-service @@ -1,6 +1,6 @@ #!/bin/sh # -# Event handler script for restarting a service on the local machine +# Event handler script for restarting a service via NRPE # # Note: This script will only restart the service if the service is # retried 3 times (in a "soft" state) or if the service somehow @@ -10,25 +10,20 @@ # $1 $SERVICESTATE$ # $2 $SERVICESTATETYPE$ # $3 $SERVICEATTEMPT$ -# $4 init script name +# $4 $HOSTADDRESS$ +# $5 state to match against ("WARNING" or "CRITICAL") +# $6 NRPE service name to use state="$1" type="$2" attempt="$3" -service="$4" +host="$4" +starton="$5" +service="$6" # What state is the service in? case "${state}" in - OK) - # The service just came back up, so don't do anything... - ;; - WARNING) - # We don't really care about warning states, since the service is probably still running... - ;; - UNKNOWN) - # We don't know what might be causing an unknown error, so don't do anything... - ;; - CRITICAL) + "${starton}") # Aha! The service appears to have a problem - perhaps we should restart it # Is this a "soft" or a "hard" state? case "${type}" in @@ -45,18 +40,18 @@ case "${state}" in # result in a "soft" recovery. If that happens no one gets notified because we # fixed the problem! 3) - # Call the init script to restart the HTTPD server - sudo /etc/init.d/${service} restart + # Call the service restart script via NRPE + /usr/lib/nagios/plugins/check_nrpe -n -H "${host}" -c "${service}" ;; esac ;; # The service somehow managed to turn into a hard error without getting fixed. # It should have been restarted by the code above, but for some reason it didn't. - # Let's give it one last try, shall we? + # Let's give it one last try, shall we? # Note: Contacts have already been notified of a problem with the service at this # point (unless you disabled notifications for this service) HARD) - sudo /etc/init.d/${service} restart + /usr/lib/nagios/plugins/check_nrpe -n -H "${host}" -c "${service}" ;; esac ;;