Page 3 of 4

Re: Global Event Handlers

Posted: Fri May 23, 2014 12:27 pm
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

Re: Global Event Handlers

Posted: Mon May 26, 2014 8:23 am
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

Re: Global Event Handlers

Posted: Tue May 27, 2014 10:41 am
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

Re: Global Event Handlers

Posted: Tue May 27, 2014 11:26 am
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

Re: Global Event Handlers

Posted: Tue May 27, 2014 11:39 am
by klee
Also, will $macros$ work at all with Global Event Handlers or are we limited to using only %variables%?

Thanks,

-klee

Re: Global Event Handlers

Posted: Wed May 28, 2014 10:37 am
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.

Re: Global Event Handlers

Posted: Thu May 29, 2014 7:07 am
by klee
Thank you Abrist,

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

-klee

Re: Global Event Handlers

Posted: Thu May 29, 2014 9:41 am
by tmcdonald
In the CCM, on the left-side navigation pane there will be a section for "Commands"

Re: Global Event Handlers

Posted: Thu May 29, 2014 4:52 pm
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

Re: Global Event Handlers

Posted: Thu May 29, 2014 5:02 pm
by abrist
Those commands should already exist, you just need to append them with any other desired macros assignments.