Configuring SNMP
You can configure a Cisco router to send SNMP traps when certain events happen. A SNMP trap, simply put, is a message triggered by a system event, such as "Hey! A link just went down!" Typically, some sort of network management software that understands SNMP traps (such as
IBM Tivoli Netview or
Nagios) correlates these messages with the events. The Net-SNMP package also has a program that understands how to deal with SNMP events.
First, start up the SNMP trap daemon, by running
snmptrapd from the Net-SNMP package. Run
snmptrapd as the root user. You'll also need to verify that any devices that might block SNMP traffic between the router and the SNMP host, such as firewalls, have been configured to allow this traffic through.
Next, you'll need to log onto your router and configure it for SNMP traps. As a bare minimum, you need to run SNMP, and you need to send traps to the SNMP host.
SomeRouter(config)# snmp-server host
<your snmp host> <your community string>
SomeRouter(config)# snmp-server enable traps config
SNMP will more or less randomly decide which interface to source the SNMP packets from, but you can simplify maintenance if you configure the device to use one specific port. The example below uses the FastEthernet0/0 port; however, you can use whatever port you like. It's important that your
snmp-conf.pl script is configured to use this IP address as the identifier of the router.
SomeRouter(config)# snmp-server trap-source FastEthernet 0/0
Now you can test the configuration. On the SNMP host, run a
tailf command on the System log. Under Solaris, it's in
/var/adm, on most Linux-like systems, it's under
/var/log. On the router, type
config t, and then
exit. The result should look something like this:
Jul 18 22:42:32 netflowc snmptrapd[20718]: [ID 702911
daemon.warning] 10.0.37.31: Enterprise Specific Trap
(.1) Uptime: 111 days, 6:49:44.81,
.1.3.6.1.4.1.9.9.43.1.1.6.1.3.145 = INTEGER: 1,
.1.3.6.1.4.1.9.9.43.1.1.6.1.4.145 = INTEGER: 2,
.1.3.6.1.4.1.9.9.43.1.1.6.1.5.145 = INTEGER: 3
Jul 18 22:42:32 netflowc snmptrapd[20718]: [ID 702911
daemon.warning] 10.0.37.31 [10.0.37.31]: Trap ,
.1.3.6.1.2.1.1.3.0 = Wrong Type (should be Timeticks):
INTEGER: 961498481, .1.3.6.1.6.3.1.1.4.1.0 = OID:
.1.3.6.1.4.1.9.9.43.2.0.1,
.1.3.6.1.4.1.9.9.43.1.1.6.1.3.145 = INTEGER: 1,
.1.3.6.1.4.1.9.9.43.1.1.6.1.4.145 = INTEGER: 2,
.1.3.6.1.4.1.9.9.43.1.1.6.1.5.145 = INTEGER: 3
Now that you know SNMP is working, you need to configure SNMPTT. First, create a
snmptt.conf file. You need to tell SNMPTT how to deal with the configuration traps, so add the following lines to
snmptt.conf:
EVENT ciscoConfigManEvent .1.3.6.1.4.1.9.9.43.2.0.1
"Status Events" Normal
FORMAT Notification of a configuration management
event as $*
EXEC /usr/local/bin/snmp-conf.pl -t $ar -a $1 -b $2 -c
$3 -o /tmp/routers |
/usr/local/bin/router-commit.sh
SDESC
Notification of a configuration management event as
recorded in ccmHistoryEventTable.
EDESC
You'll need to
download the script snmp-conf.pl and put it in
/usr/local/bin, then run the command
chmod 755 /usr/local/bin/snmp-conf.pl to make it executable. After doing that, you'll need to configure your router information in the script. Finally, create another helper script to manage the SVN updates. Paste the following code into a script, and then run
chmod 755 /usr/local/bin/router-commit.sh.
#!/bin/sh
# set SVN for your environment
SVN=/usr/local/bin/svn
NOW=`date`
cd /tmp/routers; $SVN update
cd /tmp/routers; $SVN commit --message
"Auto-triggered update on: $NOW"
cd /tmp/; $SVN co http://<yourhost>/depot/routers
Finally, you'll need to configure Net-SNMP's
snmptrapd by adding the following line to the
snmptrapd.conf file.
traphandle default /usr/local/sbin/snmptthandler