How to pass flapping information macro to event handler?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
rupesh_arora_tmna
Posts: 6
Joined: Thu Mar 11, 2021 3:40 pm

How to pass flapping information macro to event handler?

Post by rupesh_arora_tmna »

I'm looking for same macro as $NOTIFICATIONTYPE$ which tell during notification that type of notification that is being sent ("PROBLEM", "RECOVERY", "ACKNOWLEDGEMENT", "FLAPPINGSTART", "FLAPPINGSTOP", "FLAPPINGDISABLED", "DOWNTIMESTART", "DOWNTIMEEND", or "DOWNTIMECANCELLED").

But problem with this macro is, we can use this macro with notification handler but not with event handler. When I use this macro in my event handler it give me blank.

Now, I'm looking for a macro that, I can send to my event handler, so that it can tell me whether host/service flapping has been started or not.

I tried using $HOSTPERCENTCHANGE$ but not happy/understand with the result. If no macro is available, how can I get this info whether flapping has been started.

What, I'm trying to achieve is stop processing SNMP traps being sent, if host/service start flapping. Nagios write the code don't send SNMP traps during downtime, but how can I stop sending SNMP traps while host/service is flapping.

Well I edited my code

Code: Select all

/usr/local/nagiosxi/html/includes/components/snmptrapsender/snmptrapsender.inc.php at line number 457 by trying to get the macro by $meta
.Once I get flapping start, I'll put my if condition and stop it for further processing.

Please help me to sort this out.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: How to pass flapping information macro to event handler?

Post by ssax »

There isn't currently a macro available for that during the event handler context, only in the notification context as you found.

You would essentially need to have your event handler query the API to check it (or look directly in /usr/local/nagios/var/status.dat) at is_flapping, see here on your server:

http://YOURXISERVER/nagiosxi/help/api-o ... vicestatus

I have submitted a feature request to development:

XI - SNMP Trap Sender - Add the ability to exclude flapping traps from being sent
rupesh_arora_tmna
Posts: 6
Joined: Thu Mar 11, 2021 3:40 pm

Re: How to pass flapping information macro to event handler?

Post by rupesh_arora_tmna »

Well, I wrote code for that.

Code: Select all

$req = array("name" => $meta['service'], "host_name" => $meta['host']);
 $obj = simplexml_load_string(get_service_status_xml_output($req));
$is_flapping = intval($obj ->hoststatus ->is_flapping);
FYI meta is an array in which lots of information were present.
It did my job.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: How to pass flapping information macro to event handler?

Post by ssax »

Awesome, thank you for posting your solution! That should work too. Let us know when we're okay to lock this up and mark this as resolved.
rupesh_arora_tmna
Posts: 6
Joined: Thu Mar 11, 2021 3:40 pm

Re: How to pass flapping information macro to event handler?

Post by rupesh_arora_tmna »

Yes you may close this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to pass flapping information macro to event handler?

Post by scottwilkerson »

rupesh_arora_tmna wrote:Yes you may close this post.
Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked