1) Load and compile MIBS to Nagios
This is the command to compile MIBS to Nagios server:
snmpttconvertmib --in=
It would be tedious if there are too many MIBs files. Therefore, I wrote a simple bash script called “loadMIBS to compile all the MIBS in a folder.
if [ $# -ne 2 ]; then
echo "loadMIBS 'folder' 'device'"
exit 1
fi
for file in $( ls $1 ); do
/usr/sbin/snmpttconvertmib --in=$1\/$file \
--out=/etc/snmp/snmptt.conf.$2 \
--exec='/usr/local/nagios/libexec/eventhandlers/submit_check_result $r TRAP 1'
echo "MIBS loaded in /etc/snmp/snmptt.conf.$2"
done
2) Inform SNMPTT on the newly compiled Files
Modify /etc/snmp/snmptt.ini to include the earlier files:
[TrapFiles]
snmptt_conf_files =
/etc/snmp/snmptt.conf.devicename1
/etc/snmp/snmptt.conf.devicename2
END
3) Add the new Device to Nagios configuration file
I have created a standard file to consolidate all SNMP Trap devices at /usr/local/nagios/etc/objects/snmptrap.cfg. Just follow the example below:
define host{
use windows-server ; Inherit default values from a template
host_name HostA
alias HostA
address xx.xx.xx.xx ; IP address of the host
}
define host{
use windows-server ; Inherit default values from a template
host_name HostB
alias HostB
address xx.xx.xx.xx ; IP address of the host
}
define hostgroup{
hostgroup_name snmp_group ; The name of the hostgroup
alias SNMP TRAP
members HostA, HostB
}
define service{
hostgroup_name snmp_group
use snmptrap-service
contact_groups netadmin ; Who to alert & contact
}
4) Define New TRAP service on Nagios
Separately, on the templates.cfg, I have added this SNMP trap service
# define snmp trap service for network
define service{
use generic-service
name snmptrap-service
check_command check-host-alive
service_description TRAP
passive_checks_enabled 1
register 0
is_volatile 1
check_period none
max_check_attempts 1
normal_check_interval 1
retry_check_interval 1
notification_interval 31536000
notification_options w
}
Red: Make sure that the service description must match the submit_check_result parameter i.e. TRAP in this case. Otherwise, Nagios won't be able to match the recieved snmp trap to the passive service.
5) Verifying New SNMP Trap Service
- Check that the snmp trap daemon is running i.e. ps -e | grep trap
- Check the snmptt log that the trap is received
- Click on the "Event Logs" of Nagios admin console. Check that the event handler "submit_check_result" is executed correctly.
very good post. works 100%
ReplyDeletethx
Hi Samyee...
ReplyDeleteits really very great post. I was stuck in some issue to receive trap from my server but didn't find any solution. Only on your post I found the solution
"Red: Make sure that the service description must match the submit_check_result parameter i.e. TRAP in this case. Otherwise, Nagios won't be able to match the recieved snmp trap to the passive service.".
U saved my lost of time... I wish I came across ur post earlier....
thanks once again.
Este link no contiene nada ==> How to recieve SNMP Trap in Nagios
ReplyDeleteMe llega el trap en los log pero no salta la alarma.
Puedes ayudarme....
Why speak spanish when all the others on this page is speaking English >:(
DeleteDyma yw eich cyswllt torri selffish concwerwr:
http://xavier.dusart.free.fr/nagios/en/snmptraps.html
because es su idioma nativo papa
DeleteSNMP trap was sent and I was alerted by Nagios, but nagios kept saying following message in the log even after the trap condition has cleared. Is there a way to disable this?
ReplyDelete'Warning: Check of service 'TRAP' on host 'xxxxxxxx' could not be rescheduled properly. Scheduling check for 'date'