Global Event Handlers

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Global Event Handlers

Post by abrist »

klee wrote:OK, if NAGIOS-NOTIFY-MIB does not include the macros HOSTADDRESS and HOSTSTATE, then is there still a way we can still reference them in an snmptrap?
Not really as those macros are not present in the mib, but this would be a fine feature request. You can open an issue over at:
https://github.com/nagios-plugins/nagios-mib
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: Global Event Handlers

Post by klee »

Hi Abrist,

1) I would like to take a step back and ask for clarification on one item. You said, "The MIB does not include the macros HOSTADDRESS and HOSTSTATE."
...because I was originally inquiring about the use of variables. What exactly is the correlation between macros and variables? Are they basically the same other than: variables are limited to Global Event Handlers and macros for Individual Event Handlers?

2) It seems a good majority of the macros and variables are actually not referenced in the Nagios MIB file. Assuming that we'll have to submit a feature request to add multiple macros/variables... will they be willing to do so? Are the parties responsible for maintaining the Nagios MIB actually Nagios engineers, or are they an independent 3rd party?

3) Sorry but again, why does the example present as --host="%host%" --hoststate=%hoststate% ,etc...? I had tired to clarify my question along with example in follow-up post.

Thanks Much,

-klee
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Global Event Handlers

Post by abrist »

klee wrote:1) I would like to take a step back and ask for clarification on one item. You said, "The MIB does not include the macros HOSTADDRESS and HOSTSTATE."
...because I was originally inquiring about the use of variables. What exactly is the correlation between macros and variables? Are they basically the same other than: variables are limited to Global Event Handlers and macros for Individual Event Handlers?
The two terms are interchangeable in many cases. I tend to refer to the core nagiso macros as "macros", and any macros, once passed to a script, or when mapped to another name (like the %<var>% you see in the global handlers) as variables.
klee wrote:2) It seems a good majority of the macros and variables are actually not referenced in the Nagios MIB file. Assuming that we'll have to submit a feature request to add multiple macros/variables... will they be willing to do so? Are the parties responsible for maintaining the Nagios MIB actually Nagios engineers, or are they an independent 3rd party?
Nagios employees maintain the nagios-plugins, perl module, and the nagios mibs.
klee wrote:3) Sorry but again, why does the example present as --host="%host%" --hoststate=%hoststate% ,etc...? I had tired to clarify my question along with example in follow-up post.
Because the example uses our global event script that expects the macros to be mapped to variables. Most of your scripts could and should just use the %<var>% variables from the global event handler component doc:
http://assets.nagios.com/downloads/nagi ... ndlers.pdf
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: Global Event Handlers

Post by klee »

Hi Abrist,

Thank you very much for explaining.

Attached is a screenshot of a spreadsheet, matching up macros and variables against values in NAGIOS-NOTIFY-MIB.

It seems a majority of available macros & variables, can't be referenced via SNMP traps, because they don’t exist in this MIB file.

Is this accurate to say?

Thanks,

-klee
You do not have the required permissions to view the files attached to this post.
Last edited by klee on Tue May 27, 2014 10:08 pm, edited 1 time in total.
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: Global Event Handlers

Post by klee »

Also, will $macros$ work at all with Global Event Handlers or are we limited to using only %variables%?

Thanks,

-klee
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Global Event Handlers

Post by abrist »

Only to using the %variables%. BUT, you can map other nagios macros to the %vars% by editing the following commands in the ccm:

Code: Select all

xi_host_event_handler 

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=host --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --hostdowntime=$HOSTDOWNTIME$
-------------------------------------

Code: Select all

xi_service_event_handler

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=service --host="$HOSTNAME$" --service="$SERVICEDESC$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --servicedowntime=$SERVICEDOWNTIME$
EDIT: I just looked at the global event handler doc. It is a bit confusing, and the default commands in the component are not right. I will be updating the doc and component today for the purpose of clarity.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: Global Event Handlers

Post by klee »

Thank you Abrist,

Where exactly in the Core Configuration Manager can I edit those commands?

-klee
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Global Event Handlers

Post by tmcdonald »

In the CCM, on the left-side navigation pane there will be a section for "Commands"
Former Nagios employee
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: Global Event Handlers

Post by klee »

Thanks tmcdonald,

So, just define the commands: xi_host_event_handler & xi_service_event_handler with the long string of code provided in the Command Line field?

-klee
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Global Event Handlers

Post by abrist »

Those commands should already exist, you just need to append them with any other desired macros assignments.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked