In CSE, we use Net-SNMP snmptrapd to receive notifications about renewable resource capacities on our monitored servers. Our monitored resources include:
- Disk Usage. We typically receive an alert when a disk is less than 20% free.
- Load Average. We receive alerts if 1-, 5-, and 15-minute average loads exceed a preconfigured threshold.
- Memory Usage.
- Processes. We receive alerts if the numbers of monitored processes vary from preconfigured minimum and maximum thresholds.
- Each CSE SNMP-monitored host must run Net-SNMP snmpd with a customized snmpd.conf. Look for snmpd.conf in /etc/snmp/ on Linux systems and in /usr/local/etc/snmp/ on FreeBSD systems. In snmpd.conf, the informsink and/or trap2sink tokens must be assigned the value of our trap receiver, the-who.cse.buffalo.edu. The snmpd process must be running.
- the-who:/etc/snmp/snmptrapd.conf must be properly configured and snmptrapd must be running. snmptrapd.conf contains a reference to the NetSNMP embedded Perl features:
perl NetSNMP::TrapReceiver::register("all", \&my_receiver);
perl do "/etc/snmp/mytrapdmail.pl";
- the-who:/etc/snmp/mytrapmail.pl is the Perl script that snmptrapd calls to email trap messages to cse-staff.
I couldn't make Net-SNMP 5.4.2.1 snmptrapd work properly on a FreeBSD system, so this section does not describe our current setup.
- In /etc/rc.conf, snmptrapd_enable="YES".
- Enable this host to receive traps. In /etc/hosts.allow, add:
#
# Permit SNMP-monitored machines to snmptrap to us
#
snmptrapd : 128.205.0.0/255.255.0.0 : allow
- Make sure configuration directives land in /usr/local/etc/snmp/snmptrapd.conf.
- Add an entry to /etc/newsyslog.conf to rotate the logfiles:
/var/log/snmptrapd.log 644 7 100 * JC
- % sudo snmpconf -i
- % sudo snmpconf -g basic_setup
- Verify that a SNMP trap receiver is receiving traps on interface xl0, port 162:
% sudo tcpdump -i xl0 port 162
-
% sudo snmptrapd -f -Le -d
-
% sudo snmptrapd -f -Le -D ALL
-
% net-snmp-config --configure-options
- To build a Linux NetSNMP::TrapReceiver.pm, I had to build a net-snmp into /util. This procedure finally worked:
% cd /tmp/net-snmp/net-snmp-5.4.2.1
% ./configure --prefix=/util/net-snmp-5.4.2.1 --with-default-snmp-version="2"
% make
% sudo make install
... then go back into the net-snmp source and install the Perl stuff:
% cd /tmp/net-snmp/net-snmp-5.4.2.1/perl
% /util/perl/bin/perl Makefile.PL -NET-SNMP-CONFIG="sh /util/net-snmp/bin/net-snmp-config" -NET-SNMP-IN-SOURCE=true
% make
% make test
% sudo make install
- http://en.wikipedia.org/wiki/Net-SNMP
- http://www.net-snmp.org/docs/man/snmptrapd.html
- http://www.net-snmp.org/docs/man/snmptrapd.conf.html
- http://www.net-snmp.org/wiki/index.php/Main_Page
- http://net-snmp.sourceforge.net/docs/FAQ.html#How_do_I_send_traps_and_no...
- http://fixunix.com/snmp/175135-trap-handling.html
- % man snmptrapd
- % man snmptrapd.conf
- % man snmpcmd
- % perldoc NetSNMP::TrapReceiver