SNMP Trap Sender Component

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
Mitchell
Posts: 130
Joined: Thu Jan 05, 2012 2:33 am

SNMP Trap Sender Component

Post by Mitchell »

Hello Team,

I needed to send notification using SNMP trap to one of the dashboard solution we are working on. I used the 'SNMP Trap Sender' and it works fine with couple of issue..

1. sends notification for each state change; I only want to send for each notification (HARD STATE and RECOVERY) ....
2. For few hosts it is not sending event with wrong information... (Sends hostoutput in place of hostname)
3. For few hosts it is not sending OK (RECOVERY) event.


How can I test and troubleshoot this component? I see following entries in nagios.log. These suggests that events are triggered at every state change and I don't see the event forwarded for few host of interest.

Code: Select all

[1387398176] SERVICE ALERT: x317NTV;CPU Load;UNKNOWN;SOFT;1;Unknown - LoadPercentage cannot be determined
[1387398197] SERVICE ALERT: x19NTV;CPU Load;UNKNOWN;SOFT;1;Unknown - LoadPercentage cannot be determined
[1387398215] SERVICE ALERT: x18NTV;CPU Load;UNKNOWN;SOFT;1;Unknown - LoadPercentage cannot be determined
[1387398218] SERVICE ALERT: x28NTV;CPU Load;UNKNOWN;SOFT;1;Unknown - LoadPercentage cannot be determined
[1387398218] SERVICE ALERT: x19NTV;CPU Load;UNKNOWN;SOFT;1;Unknown - LoadPercentage cannot be determined
[1387398236] SERVICE ALERT: x100NTV;CPU Load;OK;SOFT;3;OK - _Total 'Load Percentage' = 2:
[1387398302] SERVICE ALERT: x03NTV;Memory Usage;WARNING;SOFT;1;OK - RAM 'Percentage Space Used' = 97(0.05 GB Free/ 2.00 GB Total): OK - PAGING 'Percentage Space Used' = 90(0.46 GB Free/ 5.02 GB Total): Warning - _TOTAL 'Percentage Space Used' = 92(0.51 GB Free/ 7.01 GB Total):
[1387398314] SERVICE ALERT: x45NTV;PSQL45NTV-TFS2012PROD BufferManager Metrics;OK;SOFT;2;OK (Sample Period 299 sec) - Buffercachehitratio=5.699K, _CheckpointpagesPersec=88/sec, Databasepages=539.343K, _FreeliststallsPersec=0/sec, Freepages=NO_WMI_DATA, _LazywritesPersec=4/sec, Pagelifeexpectancy=437, _PagelookupsPersec=62.326K/sec, _PagereadsPersec=128/sec, _PagewritesPersec=179/sec, _ReadaheadpagesPersec=89/sec, Reservedpages=NO_WMI_DATA, Stolenpages=NO_WMI_DATA, Targetpages=31.234M, Totalpages=NO_WMI_DATA
[1387398470] SERVICE ALERT: x103V;CPU Load;UNKNOWN;SOFT;1;Unknown - LoadPercentage cannot be determined
[1387398476] SERVICE ALERT: x317NTV;CPU Load;OK;SOFT;2;OK - _Total 'Load Percentage' = 1:
[1387398497] SERVICE ALERT: x19NTV;CPU Load;OK;SOFT;2;OK - _Total 'Load Percentage' = 1.5:
[1387398515] SERVICE ALERT: x18NTV;CPU Load;OK;SOFT;2;OK - _Total 'Load Percentage' = 1.5:
[1387398518] SERVICE ALERT: x28NTV;CPU Load;OK;SOFT;2;OK - _Total 'Load Percentage' = 1:
[1387398518] SERVICE ALERT: x19NTV;CPU Load;OK;SOFT;2;OK - _Total 'Load Percentage' = 1:
[1387398524] SERVICE ALERT: x09lx;proc_Nagios Server;CRITICAL;SOFT;1;CRIT - 3 processes (ok from 1 to 1)
[1387398599] SERVICE ALERT: x18NTV;CPU Load;UNKNOWN;SOFT;1;Unknown - LoadPercentage cannot be determined
[1387398599] SERVICE ALERT: x81NTV;CPU Load;UNKNOWN;SOFT;1;Unknown - LoadPercentage cannot be determined
[1387398599] SERVICE ALERT: x03NTV;Memory Usage;WARNING;SOFT;2;OK - RAM 'Percentage Space Used' = 97(0.05 GB Free/ 2.00 GB Total): OK - PAGING 'Percentage Space Used' = 90(0.46 GB Free/ 5.02 GB Total): Warning - _TOTAL 'Percentage Space Used' = 92(0.51 GB Free/ 7.01 GB Total):
Thanks
Ashish
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: SNMP Trap Sender Component

Post by sreinhardt »

The files should be in /usr/local/nagiosxi/html/includes/components/snmptrapsender/ You can certainly feel free to add additional filtering for only sending hard state changes, or submit a feature request. However I don't believe we consider this a bug at this point as most devices that send traps, alert when anything for that trap is triggered. As for some hosts not sending, do you have event handlers disabled for those hosts or services? That is about the only thing I could think of that would cause a global event handler not trigger on state change. Could you give a specific example of the trap being sent incorrectly please?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
User avatar
Mitchell
Posts: 130
Joined: Thu Jan 05, 2012 2:33 am

Re: SNMP Trap Sender Component

Post by Mitchell »

okay. I understand sending the trap for every state change and not necessarily for notifications only.

I think I could use 'Global Event Handlers' component for notification part. Can I use the commands used in 'SNMP Trap Sender' component file /usr/local/nagiosxi/html/includes/components/snmptrapsender/ with 'Global Event Handlers' component?

Code: Select all

$service_trap_command="/usr/bin/snmptrap -v 2c -c public 192.168.5.4 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s \"%host%\" nSvcDesc s \"%service%\" nSvcStateID i %servicestateid% nSvcOutput s \"%serviceoutput%\"";
$host_trap_command="/usr/bin/snmptrap -v 2c -c public 192.168.5.4 '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s \"%host%\" nHostStateID i %hoststateid% nHostOutput s \"%hostoutput%\"";
Since the event handlers holds the nagios thread, I want to make sure that this is a safe thing to do.

I figured out the incorrect information part. It was due to difference in plugin/s behavior. I will also re-validate the not sending RECOVERY trap.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: SNMP Trap Sender Component

Post by sreinhardt »

Yes you could use the snmptrap sending components functions with the global event handler(GEH) component. You might want to only have one or the other installed at a time though, as they both might get called. The commands from the snmptrap sender should directly work with the GEH component without modification. I would note, that I have not tested this, however their formatting and macros appear perfect for it.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked