event handler options

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
elinagios
Posts: 146
Joined: Thu Feb 16, 2017 3:45 am

event handler options

Post 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.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: event handler options

Post 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
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!
elinagios
Posts: 146
Joined: Thu Feb 16, 2017 3:45 am

Re: event handler options

Post by elinagios »

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

Post 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.
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!
elinagios
Posts: 146
Joined: Thu Feb 16, 2017 3:45 am

Re: event handler options

Post by elinagios »

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

Post by scottwilkerson »

elinagios wrote:Yes, "" did the trick, thank you.
Great!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked