Page 1 of 1

event handler options

Posted: Fri Jan 10, 2020 7:19 am
by elinagios
Hello

im tryng to make a event handler that basically sends service alarms to outside system.
1) Created a nagiosxi command: $USER1$/event_handler_test.sh $NOTIFICATIONTYPE$ $SERVICEDESC$ $HOSTNAME$ $HOSTADDRESS$ $SERVICESTATE$ $LONGDATETIME$ $SERVICEOUTPUT$ $SERVICEOUTPUT$ $NOTIFICATIONCOMMENT$
2) Created a script:
#!/bin/bash
NOTIFICATIONTYPE=$1
SERVICEDESC=$2
HOSTNAME=$3
HOSTADDRESS=$4
SERVICESTATE=$5
LONGDATETIME=$6
SERVICEOUTPUT=$7
NOTIFICATIONCOMMENT=$8

echo $NOTIFICATIONTYPE $SERVICEDESC $HOSTNAME $HOSTADDRESS $SERVICESTATE $LONGDATETIME $SERVICEOUTPUT $NOTIFICATIONCOMMENT > /tmp/hostinfo.txt

The problem is that not all the variables give out info, like SERVICEOUTPUT. Is event handler somehow limited? Or i should use some other option to get status information?
If i get it working, then the idea is to curl it out to the outside system.

Thank you.

Re: event handler options

Posted: Fri Jan 10, 2020 11:05 am
by benjaminsmith
Hello @elinagios,
The problem is that not all the variables give out info, like SERVICEOUTPUT. Is event handler somehow limited? Or i should use some other option to get status information?
That looks right in your example. One thing to check is that you can only pass macros that are supported by the object type. Are you testing this against a host object? In that case, the SERVICEOUTPUT would not be supported.

References:
Introduction to Event Handlers
Standard Macros in Nagios

Re: event handler options

Posted: Mon Jan 13, 2020 1:43 am
by elinagios
This event handler script in under a service, regular C disk drive check. Any other ideas?

Re: event handler options

Posted: Mon Jan 13, 2020 3:34 pm
by benjaminsmith
Hi @elinagios,

It may be because of the spaces or special characters in the output of the macro itself as shown in the following thread.
https://support.nagios.com/forum/viewto ... 16&t=49907

Code: Select all

$USER1$/event_handler_test.sh "$NOTIFICATIONTYPE$" "$SERVICEDESC$" "$HOSTNAME$" "$HOSTADDRESS$" "$SERVICESTATE$" "$LONGDATETIME$" "$SERVICEOUTPUT$"  "$NOTIFICATIONCOMMENT$"
If this does not resolve the error, please send us your system profile and the exact name of the service check.

To send us your system profile.
Login to the Nagios XI GUI using a web browser
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
Save the profile.zip file and share this in a private message and then reply to this post to bring it up in the queue.

Re: event handler options

Posted: Tue Jan 14, 2020 7:09 am
by elinagios
Yes, "" did the trick, thank you.

Re: event handler options

Posted: Tue Jan 14, 2020 8:17 am
by scottwilkerson
elinagios wrote:Yes, "" did the trick, thank you.
Great!

Locking thread