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.2 Defining the Event Handler in the Service Definition

Although Nagios executes the event handler for every event, it does not have to carry out an action each time. In our example the handler should attempt to reset the printer service on the third soft error state (check No. 4) and on the first hard error state (check No. 5), and do nothing at all the other execution times.

For this purpose, the service definition is modified as follows:

define service{
    host_name             printserver
    service_description   LPD
    ...
    event_handler  restart-lpd
    ...
}

The event_handler parameter expects a Nagios command object that will run the handler script:

define command{
    command_name restart-lpd command_line $USER1$/eventhandler/restart-lpd.sh $SERVICESTATE$ $SER VICESTATETYPE$ ...

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