Page 4 of 4

Re: Event Handler Script not working.

Posted: Wed Feb 06, 2019 9:12 am
by Figment
Even with the file in a different directory I'm getting the same error.

So I've tried not using a script and instead putting the cmd into the Command.cfg as below. If I enter the command_line directly into the console it works fine.

Code: Select all

define command{
        command_name    auto_acknowledge
        command_line    /bin/printf "[%lu] ACKNOWLEDGE_HOST_PROBLEM;TEST_PRINTER;2;1;1;Autobot;Non-critical host, outage acknowledged\n" > /usr/local/nagios/var/rw/nagios.cmd
        }
However defining it to trigger as the event handler results in the below error.

Code: Select all

[1549460469] Warning: Check of host 'TEST_PRINTER' timed out after 30.01 seconds
[1549460469] HOST EVENT HANDLER: TEST_PRINTER;DOWN;SOFT;2;auto_acknowledge
[1549460469] wproc: HOST EVENTHANDLER job 1986 from worker Core Worker 15484 is a non-check helper but exited with return code 1
[1549460469] wproc:   early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
[1549460469] wproc:   stderr line 01: /bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
[1549460469] wproc:   stderr line 02: /bin/sh: -c: line 1: syntax error: unexpected end of file
Any Idea how to get this to work? Or if theres a better way to automatically acknowledge non critical hosts.

Re: Event Handler Script not working.

Posted: Wed Feb 06, 2019 9:23 am
by scottwilkerson
Figment wrote:Even with the file in a different directory I'm getting the same error.
Are you sure you don't have the event handler defined multiple times?
Figment wrote:However defining it to trigger as the event handler results in the below error.
That's because your printf command didn't have the date stamp to substitute the date, try:

Code: Select all

define command{
        command_name    auto_acknowledge
        command_line    /bin/printf "[`date +%s`] ACKNOWLEDGE_HOST_PROBLEM;TEST_PRINTER;2;1;1;Autobot;Non-critical host, outage acknowledged\n" > /usr/local/nagios/var/rw/nagios.cmd
        }

Re: Event Handler Script not working.

Posted: Thu Feb 07, 2019 10:50 am
by Figment
Hi Scott,

Thanks for all your help. I've ended up going down a different route for the monitoring of non critical hosts (check_dummy).

You can close this thread now.

Re: Event Handler Script not working.

Posted: Thu Feb 07, 2019 11:47 am
by scottwilkerson
Figment wrote:Hi Scott,

Thanks for all your help. I've ended up going down a different route for the monitoring of non critical hosts (check_dummy).

You can close this thread now.
Ok locking thread