O'Reilly logo

Nagios, 2nd Edition by Wolfgang Barth

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C.3 The Handler Script

The actual treatment of the error—depending on the current event—is dealt with by the script defined in the command definition. So that we can concentrate on the essential aspects in this context, we shall assume that lpd is installed on the Nagios server itself. This enables the service to be restarted locally, without the need for a remote shell such as the Secure Shell.

The script restart-lpd.sh checks to see exactly what event is involved, using the macros passed on to it, and either does nothing at all or tries to restart lpd:

#!/bin/bash # /usr/local/nagios/libexec/eventhandlers/restart-lpd.sh # $1 = Status, $2 = status type, $3 = attempt case $1 in OK) ;; WARNING) ;; CRITICAL) if [ $2 == "HARD" ] || [[ $2 == "SOFT" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required