Page 1 of 1

How to pass flapping information macro to event handler?

Posted: Mon May 10, 2021 4:08 pm
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.

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

Posted: Tue May 11, 2021 1:52 pm
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

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

Posted: Thu May 13, 2021 3:18 pm
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.

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

Posted: Fri May 14, 2021 10:12 am
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.

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

Posted: Mon May 31, 2021 8:00 am
by rupesh_arora_tmna
Yes you may close this post.

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

Posted: Tue Jun 01, 2021 6:49 am
by scottwilkerson
rupesh_arora_tmna wrote:Yes you may close this post.
Locking thread