Pass in a HostGoup name as part of Service Trap
-
- Posts: 92
- Joined: Mon Dec 01, 2014 3:39 pm
Pass in a HostGoup name as part of Service Trap
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!
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!
-
- 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
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
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
Re: Pass in a HostGoup name as part of Service Trap
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!
-
- Posts: 92
- Joined: Mon Dec 01, 2014 3:39 pm
Re: Pass in a HostGoup name as part of Service Trap
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.tgriep wrote:I have a question, are you trying to setup the Nagios SNMP Trap Sender to send hostgroup names?
Re: Pass in a HostGoup name as part of Service Trap
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
to
That added the "nHostHostgroupnames OCTET STRING" line.
Next you need to add the OID for that entry
Add the following
Under this line
Next change this from
to
That added the "nSvcHostgroupnames OCTET STRING" line.
Next you need to add the OID for that entry
Add the following
under this line
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
}
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
}
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 }
Code: Select all
::= { nagiosHostEventEntry 15 }
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
}
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
}
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 }
Code: Select all
::= { nagiosSvcEventEntry 18 }
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Pass in a HostGoup name as part of Service Trap
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!
-
- Posts: 92
- Joined: Mon Dec 01, 2014 3:39 pm
Re: Pass in a HostGoup name as part of Service Trap
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??
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??
Re: Pass in a HostGoup name as part of Service Trap
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!