Pages: << 1 ... 5 6 7 8 9 10 11 12 13 14 15 ... 52 >>
Clients sometimes request that we (Nagios) sends out SNMpo traps to third party monitoring soliutions like OpenView, Solarwinds.
Basically we monitior a service "normally" with Nagios but send at the same time the state changes or perfdata to a SNMP trap receiver (third party monitoring software).
Sanjay blogged about this in our Intuit blog:
First thing do ensure that your Nagios box has the snmptrap binary and perhaps all other associated SNMP binaries installed. If you haven’t a good start would be to use the following lines:
Debians..
apt-get net-snmp net-snmp-utils net-snmp-devel -y
Redhats..
yum install net-snmp net-snmp-utils net-snmp-devel –y
In Nagios, we setup to have SNMP traps to send out to a HP OpenView box in our customer’s corporate network. These traps are sent as Event Handlers in Nagios. You may try doing them as normal notifications (i guess, haven’t tested).
So, each time there’s a state change (e.g. from OK to Warning), you will get, beside the standard notifications, an event that triggers a snmp trap to a remote management host.
To make things simple, we use existing config definitions such as the original commands.cfg and the linux-services.cfg. The following guide attempt to send a trap when there’s more than 2 or 3 users logging onto the nagios (localhost) box.
First, edit the commands.cfg file and add the following lines. I will explain what these lines mean.
define command{
command_name send_snmptrap
command_line /usr/bin/snmptrap -v 2c -c public 192.168.2.22 ” NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$HOSTNAME$" nSvcDesc s "$SERVICEDESC$" nSvcStateID i $SERVICESTATEID$ nSvcOutput s "$SERVICEOUTPUT$"
}
Simply copy paste everything and it should actually be single lines something like below;

The command name can be anything you wish, just as long it’s mentioned correctly in the _x_services.cfg files.
/usr/bin/snmptrap –v 2c –c public 192.168.2.22…
This is quite straightforward, here, we attempt to send SNMPv2 with the community string of public to the remote server 192.168.2.22.
…” NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$HOSTNAME$" nSvcDesc s "$SERVICEDESC$" nSvcStateID i $SERVICESTATEID$ nSvcOutput s "$SERVICEOUTPUT$"
This part above firstly, feeds the Nagios MIBs so that we can use easy readable words such as NSvcDesc instead of OID numbers. It would be a good idea to give the Nagios MIBs to the 3rd party remote monitoring host as well.
The next few fields are completely up to you and what you wish Nagios to output to the trap receiver. In my case, HOSTNAME – The monitored host, SERVICEDESC – service description, SERVICESTATEID – the Nagios state id like 0 for OK, 1 – for warning etc…and SERVICEOUTPUT – The additional info field from the plug-in is sufficient. You may add more if you like where you deem necessary.
Now, the command to execute and send traps out is ready. Now we tell which service/host is to execute this command in a state change (triggering the event handler).
Here’s a sample of my linux-services.cfg
define service{
use debian5-linuxservice
host_name Nagios-Server
service_description Current Users
event_handler send_snmptrap
event_handler_enabled 1
check_command check_local_users!2!3
}
NOTE: Check local users thresholds are normally much higher but for testing, i just made it warn at 2 users and critical at 3.
The only two parts i added from the normal service definition are;
event_handler send_snmptrap
event_handler_enabled 1
That’s all is needed for hosts or services to send traps out with the configured output as above when a state change happens.
send_snmptrap is the logical name i created for that command in commands.cfg. Well, that’s about it. Simple right? Now, just restart your nagios to enable the above configs.
/etc/init.d/nagios restart
And test the traps by sending a passive check in Nagios WEB UI to for example, Warning or Critical.

Also, if you would like to test receiving traps, i can recommend you the free iReasoning SNMP toolset. There’s a paid one if you like the rich features of this tool but the free one has limited functions.
Now, for iReasoning, launch the MIB Browser tool. Do load the Nagios MIB to make things much prettier. File >> Load MIBs and select Nagios-Notify-MIB. Now, click on Tools >> Trap Receiver.
In the remote management host value (in my case was 192.168.2.22) enter the IP where iReasoning is running. Ensure your windows firewall enables incoming port UDP 162 for snmptraps if you enable WF.
Trigger something and see it work. See sample from iReasoning below.
NOTE: Whenever you change something in the config files, remember to restart Nagios.


Please do comment and give further suggestions.
Enjoy!
Cheers
Daniel
Business FM is interviewing us on the 16. November 2009 8 AM (GMT +8) on the Breakfast Grill... If you like to know what we are up to just listen in :-)
Internet Stream: www.bfm.com.my
FM-Frequency: 89.9 (in Malaysia)

BFM launched in September 2008, and is a 24‐hour independent radio station focused on business news and current affairs. Core programmes include the latest business news and stock market reports from Malaysia and other financial centres, interviews with business personalities, financial analysts, entrepreneurs, technologists and marketers.
Im finally back home after a long and tiring trip :-) And yessssssssss we won the prestigious Digium Award!
Mark Warren (CEO Redfone), Daniel, Marco, Ethan (President and founder of Nagios)
![]()
Mark Warren (CEO Redfone), Daniel, Marco, Ethan (President and founder of Nagios)
![]()
Marc Spencer, me
![]()
![]()
The winning team!
![]()
We left LA and drove to Las Vegas for one day.
Here some pictures:




Best burger ever at "In-and-Out"















Cheers
Daniel
We ate at Gordon Ramsey in LA. It was ok but honestly not great.
Miss a nice Nasi Lemak.. :-)
Here some pictures:










Cheers
Daniel