Event Handler Script not working.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Figment
Posts: 17
Joined: Mon Jan 28, 2019 5:21 am
Location: London, UK

Re: Event Handler Script not working.

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Event Handler Script not working.

Post 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
        }
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Figment
Posts: 17
Joined: Mon Jan 28, 2019 5:21 am
Location: London, UK

Re: Event Handler Script not working.

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Event Handler Script not working.

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked