Pass in a HostGoup name as part of Service Trap

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nagwindmon
Posts: 92
Joined: Mon Dec 01, 2014 3:39 pm

Pass in a HostGoup name as part of Service Trap

Post by nagwindmon »

Nagios team,
I've setup a service to check on a few things on windows servers but one of the requirements is to include a HostGroup name in trap that particular server in trouble belongs to. Here is what I have found at MIBs file for Host vs Service traps:

The .5 trap does have it, so I want to make this:
nHostEvent NOTIFICATION-TYPE
OBJECTS { nHostname, nHostStateID, nHostStateType, nHostAttempt,
nHostDurationSec, nHostGroupName, nHostLastCheck, nHostLastChange,
nHostOutput }

::= { nagiosNotify 5 }

(Notice that trap 7 below doesn’t have the nHostGroupName in it)

nSvcEvent NOTIFICATION-TYPE
OBJECTS { nHostname, nHostStateID, nSvcDesc, nSvcStateID, nSvcAttempt,
nSvcDurationSec, nSvcLastCheck, nSvcLastChange,
nSvcOutput }

::= { nagiosNotify 7 }


Look like this:

nSvcEvent NOTIFICATION-TYPE
OBJECTS { nHostname, nHostStateID, nSvcDesc, nSvcStateID, nSvcAttempt,
nSvcDurationSec, nHostGroupName, nSvcGroupName, nSvcLastCheck, nSvcLastChange,
nSvcOutput }

::= { nagiosNotify 7 }


So that the .7 trap populates the nHostGroupName data.

My questions are: is this something I can do and if so, how do I update the trap definition in Nagios once I upload the modified NAGIOS-NOTIFY-MIB.txt file? Any other options/suggestions how to accomplish it?

thanks!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Pass in a HostGoup name as part of Service Trap

Post by scottwilkerson »

you would need to modify the trap sender which I am guessing may be what you are trying to do here
https://support.nagios.com/forum/viewto ... 16&t=47641

That said, I would highly recommend changing the naming structure, and re-building the actual snmptrapsender because your changes could be over written if you update the component
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Pass in a HostGoup name as part of Service Trap

Post by tgriep »

I have a question, are you trying to setup the Nagios SNMP Trap Sender to send hostgroup names?
Be sure to check out our Knowledgebase for helpful articles and solutions!
nagwindmon
Posts: 92
Joined: Mon Dec 01, 2014 3:39 pm

Re: Pass in a HostGoup name as part of Service Trap

Post by nagwindmon »

tgriep wrote:I have a question, are you trying to setup the Nagios SNMP Trap Sender to send hostgroup names?
No, to include a HostGroup name the host belongs to as one of parameters, in .7 Service trap for the host the trap was generated on.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Pass in a HostGoup name as part of Service Trap

Post by tgriep »

I do have an example on the entries that have to be added to the MIB file.

Edit the NAGIOS-NOTIFY-MIB.txt and change the following from

Code: Select all

HostEventEntry ::= SEQUENCE {
  nHostEventIndex    Integer32,
  nHostname          OCTET STRING,
  nHostAlias         OCTET STRING,
  nHostStateID       HostStateID,
  nHostStateType     HostStateType,
  nHostAttempt       Integer32,
  nHostDurationSec   Integer32,
  nHostGroupName     OCTET STRING,
  nHostLastCheck     Integer32,
  nHostLastChange    Integer32, 
  nHostLastUp        Integer32,
  nHostLastDown      Integer32,
  nHostLastUnreachable Integer32,
  nHostOutput        OCTET STRING,
  nHostPerfData      OCTET STRING
  }
to

Code: Select all

HostEventEntry ::= SEQUENCE {
  nHostEventIndex    Integer32,
  nHostname          OCTET STRING,
  nHostAlias         OCTET STRING,
  nHostStateID       HostStateID,
  nHostStateType     HostStateType,
  nHostAttempt       Integer32,
  nHostDurationSec   Integer32,
  nHostGroupName     OCTET STRING,
  nHostLastCheck     Integer32,
  nHostLastChange    Integer32, 
  nHostLastUp        Integer32,
  nHostLastDown      Integer32,
  nHostLastUnreachable Integer32,
  nHostOutput        OCTET STRING,
  nHostPerfData      OCTET STRING
  nHostHostgroupnames    OCTET STRING
  }
That added the "nHostHostgroupnames OCTET STRING" line.
Next you need to add the OID for that entry
Add the following

Code: Select all

nHostHostgroupnames OBJECT-TYPE  
  SYNTAX     OCTET STRING
  MAX-ACCESS read-only  
  STATUS     current  
  DESCRIPTION
    "This object contains The Hostgroups the Host is in."
  ::= { nagiosHostEventEntry 16 }
Under this line

Code: Select all

::= { nagiosHostEventEntry 15 }
Next change this from

Code: Select all

SvcEventEntry ::= SEQUENCE {
  nSvcEventIndex    Integer32,
  nSvcHostname      OCTET STRING,
  nSvcHostAlias     OCTET STRING,
  nSvcHostStateID   HostStateID,
  nSvcHostStateType HostStateType,
  nSvcDesc          OCTET STRING,
  nSvcStateID       ServiceStateID,
  nSvcAttempt       Integer32,
  nSvcDurationSec   Integer32,
  nSvcGroupName     OCTET STRING,
  nSvcLastCheck     Integer32,
  nSvcLastChange    Integer32,
  nSvcLastOK        Integer32,
  nSvcLastWarn      Integer32,
  nSvcLastCrit      Integer32,
  nSvcLastUnkn      Integer32,
  nSvcOutput        OCTET STRING,
  nSvcPerfData      OCTET STRING
  }
to

Code: Select all

SvcEventEntry ::= SEQUENCE {
  nSvcEventIndex    Integer32,
  nSvcHostname      OCTET STRING,
  nSvcHostAlias     OCTET STRING,
  nSvcHostStateID   HostStateID,
  nSvcHostStateType HostStateType,
  nSvcDesc          OCTET STRING,
  nSvcStateID       ServiceStateID,
  nSvcAttempt       Integer32,
  nSvcDurationSec   Integer32,
  nSvcGroupName     OCTET STRING,
  nSvcLastCheck     Integer32,
  nSvcLastChange    Integer32,
  nSvcLastOK        Integer32,
  nSvcLastWarn      Integer32,
  nSvcLastCrit      Integer32,
  nSvcLastUnkn      Integer32,
  nSvcOutput        OCTET STRING,
  nSvcPerfData      OCTET STRING
  nSvcHostgroupnames      OCTET STRING
  }
That added the "nSvcHostgroupnames OCTET STRING" line.
Next you need to add the OID for that entry
Add the following

Code: Select all

nSvcHostgroupnames      OBJECT-TYPE
  SYNTAX          OCTET STRING
  MAX-ACCESS      read-only  
  STATUS          current       
  DESCRIPTION
    "This object contains the Hostgroup the Host associated to this service."
  ::= { nagiosSvcEventEntry 19 }
under this line

Code: Select all

::= { nagiosSvcEventEntry 18 }
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Pass in a HostGoup name as part of Service Trap

Post by tgriep »

I have added the full MIB file here so you can see what was done to the file to get the added entries.
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
nagwindmon
Posts: 92
Joined: Mon Dec 01, 2014 3:39 pm

Re: Pass in a HostGoup name as part of Service Trap

Post by nagwindmon »

Let me update my MIB file and give it a try...

In meantime is there a way I can see what is inside the Trap once it gets genereated? The actual data Trap contains so to be sure HostGroup name is in it??
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Pass in a HostGoup name as part of Service Trap

Post by tgriep »

If you are sending the trap from or to a Linux system, you can run a tcpdump command and decode the traps to the screen so you can view them. Try running this as root.

Code: Select all

tcpdump -i any -n udp port 162 -A -vv
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked