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.
event handler options
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: event handler options
Hello @elinagios,
References:
Introduction to Event Handlers
Standard Macros in Nagios
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.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?
References:
Introduction to Event Handlers
Standard Macros in Nagios
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: event handler options
This event handler script in under a service, regular C disk drive check. Any other ideas?
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: event handler options
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
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.
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$"
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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: event handler options
Yes, "" did the trick, thank you.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: event handler options
Great!elinagios wrote:Yes, "" did the trick, thank you.
Locking thread