Why dos Nagios not execute the EventHandler Script


(Chris) #21

okay, that’s the new output :+1: :grinning:

‘OUT:MicrosoftDynamicsNavServer$NAV_PROD MicrosoftDynamicsNavServer:MicrosoftDynamicsNavServer$NAV_PROD:MicrosoftDynamicsNavServer:’

I combine this solution with my script and will test it again.

(Chris) #22

That was a long case, but finally it works.

Now I’ve got a universal script, without any hardcoded commands. That’s realy realy nice.

Wolfgang, thank you a lot for your help and your patience.

(Chris) #23


  1. If you have special character in your Arguments, look for this characters in the Nagios.cfg. Maybe you have to exclude your characters. In my case it was the dollar sign.
    Look for this setting:

  2. Use single quotes befor and after an Argument, in the command definitions

    define command{
    command_name                    event_RemoteRestartNTServices
    command_line                    $USER1$/RemoteRestartNTServices.cmd $HOSTADDRESS$ $USER10$ $USER9$ '$ARG1$' $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$'
  3. maybe you have to use your special character two times in the service definition. It depends on your OS or script language which escape character you have to use: https://en.wikipedia.org/wiki/Escape_character

    define service{
           event_handler                   event_RemoteRestartNAVServices!MicrosoftDynamicsNavServer$$NAV_PROD
    event_handler_enabled           1
  4. I you what to know which value are handed over to your script, write a Log-file for debugging. Print every Argument in an Log-file. I added this lines in the header of my script:

    echo IP-Adress: $1 >> /usr/lib/nagios/plugins/RemoteRestartNTServices.log
    echo Username: $2 >> /usr/lib/nagios/plugins/RemoteRestartNTServices.log
    echo Password: $3 >> /usr/lib/nagios/plugins/RemoteRestartNTServices.log
    echo Servicename: $4 >> /usr/lib/nagios/plugins/RemoteRestartNTServices.log
    echo Nagios-Servicestate: $5 >> /usr/lib/nagios/plugins/RemoteRestartNTServices.log
    echo Nagios-Servicestatetype: $6 >> /usr/lib/nagios/plugins/RemoteRestartNTServices.log
    echo Nagios-Serviceattempt: $7 >> /usr/lib/nagios/plugins/RemoteRestartNTServices.log