Page 1 of 2

add hostgroups to service SNMP traps

Posted: Mon Feb 13, 2017 3:03 pm
by peter.zanetti
Is there a way to add the hostgroups a host is in to a service alert SNMP trap?

Re: add hostgroups to service SNMP traps

Posted: Mon Feb 13, 2017 6:00 pm
by avandemore
I'm afraid I'm not sure I understand your question. Are you saying you want a single SNMP trap to be distributed to the same service among a hostgroup?

Have you looked at this?

https://assets.nagios.com/downloads/nag ... ricks.html

Re: add hostgroups to service SNMP traps

Posted: Tue Feb 14, 2017 8:58 am
by peter.zanetti
Sorry for the poor wording.

The way we are currently monitoring these devices we were monitoring just the host up/down and when a host went down it would send an SNMP trap out to create a ticket on that device. In that SNMP trap we have the hostgroups that host is in, in the trap itself.

We are now getting ready to implement service alerts on these hosts as well. However, during our testing we are not getting the hostgroups to come across in our SNMP traps. Is there a way to modify the trap sender on the back end to include hostgroups?

Re: add hostgroups to service SNMP traps

Posted: Tue Feb 14, 2017 1:33 pm
by avandemore
You could modify the snmptt.conf entry for the OID in and around the line beginning with:

Code: Select all

EXEC /usr/local/bin/snmptraphandling.py
/etc/snmp/snmptt.ini provides configuration and debugging settings to work out how the data looks on the way out.
/etc/snmp/snmptt.conf provides the OID's and their actions.
/usr/local/bin/snmptraphandling.py is the script which actually submits the result to Nagios.

Re: add hostgroups to service SNMP traps

Posted: Tue Feb 21, 2017 10:00 am
by peter.zanetti
I'm not seeing these files in /etc/snmp

the files I'm seeing are: snmpd.conf snmpd.conf.rpmnew snmptrapd.conf

Re: add hostgroups to service SNMP traps

Posted: Tue Feb 21, 2017 3:27 pm
by tgriep
I am guessing that you are using the SNMP Trap Sender component in Nagios XI and you want it to include the Hostgroup a Host is in in the data that is sent to your ticketing system, correct?
If so, the SNMP Component does not have the capability to do that.
If that is not what you are looking for, let us know.

Re: add hostgroups to service SNMP traps

Posted: Wed Feb 22, 2017 8:23 am
by peter.zanetti
That's correct. We are using the SNMP Trap Sender component. Right now we only have it set up to send traps on hard state DOWN hosts. In order to get the hostgroups to come across in these traps we modified the xi_host_event_handler command adding

Code: Select all

--hostgroupnames="$HOSTGROUPNAMES$"
to the end of the command.

We are now wanting to do the same but with hard state DOWN services. I made the same change to the xi_service_event_handler command but after sending a test SNMP trap we saw that change did nothing to bring the host groups over to our ticketing tool in the trap.

Re: add hostgroups to service SNMP traps

Posted: Wed Feb 22, 2017 10:04 am
by tgriep
That Macro should be available for Service Notifications but try using the $HOSTGROUPNAME$ macro for a quick test and see if that one works for the xi_service_event_handler.

Re: add hostgroups to service SNMP traps

Posted: Wed Feb 22, 2017 1:34 pm
by peter.zanetti
We tested that earlier this week and it didn't work as we expected it to.

EDIT: Just tested it again with hostgroupname and hostgroupsnames, neither of which worked.

Re: add hostgroups to service SNMP traps

Posted: Wed Feb 22, 2017 2:25 pm
by tgriep
Well, worth a try. I don't think the SNMP Trap sender is using the hostgroupsname / s when sending service traps could be the reason it is not working.