Cisco Works, SNMP, MIBs.
User avatar
Project2501
Post Whore
Posts:
6150
Joined:
Thu Apr 17, 2008 6:44 pm
Certs:
CCNA

Manually generate SNMP trap

Thu Jan 12, 2012 10:02 pm

Pretty much for testing purposes I'd like to confirm SNMP traps are working and are hitting the right server.

Had a quick search but didn't find any threads specific to what I'm trying to achieve.

viewtopic.php?f=38&t=25021
viewtopic.php?f=38&t=18136


What I can do is create a loopback shut it and unshut it. That works but I'm looking to automate this a bit more. I've tried using clogin but the commands are entered in too quickly for the device to trap the internet change state.

I'm still looking for a solution either increasing the delay between clogin commands entered or a command/snmp string that sends a trap.
- Pete

User avatar
Project2501
Post Whore
Posts:
6150
Joined:
Thu Apr 17, 2008 6:44 pm
Certs:
CCNA

Re: Manually generate SNMP trap

Thu Jan 12, 2012 10:27 pm

Seems like this is possible.


The EEM version 2.0 (available in 12.2S, 12.3T and 12.4) includes the action snmp-trap command, which can generate a trap from an EEM applet.



http://www.cisco.com/en/US/docs/ios/net ... #wp1168326


However not all devices seems to have this command available.
- Pete

User avatar
rstaples
Member
Posts:
117
Joined:
Wed Oct 20, 2010 3:35 pm
Certs:
CCNA, CCNAV, Cisco Rich Media Specialist

Re: Manually generate SNMP trap

Fri Jan 13, 2012 12:10 am

Is this what your looking for?

ip sla 9
tcp-connect YOUR_IP
owner YOU
tag This is from SLA 9
frequency 60
tos 128
timeout 5000
tag FLL-RO


ip sla reaction-configuration 5 react timeout action-type traponly threshold-type immediate
ip sla schedule 5 start-time now


you can test this with kiwi http://www.kiwisyslog.com/
www.configbytes.com
I have no special gift, I’m only passionately curious.
- Albert Einstein

User avatar
Project2501
Post Whore
Posts:
6150
Joined:
Thu Apr 17, 2008 6:44 pm
Certs:
CCNA

Re: Manually generate SNMP trap

Fri Jan 13, 2012 12:23 am

I just need to confirm the snmp-server configuration is correct and traps are being sent to the correct trap server.

The command action snmp-trap does just that and generates the snmp trap for testing purposes but it requires a recent IOS version.
- Pete

killabee
Post Whore
Posts:
1363
Joined:
Sat Dec 19, 2009 11:52 pm
Certs:
CCNP, JNCIA, MCSA

Re: Manually generate SNMP trap

Fri Jan 13, 2012 12:49 am

If you're trying to validate whether traps are being sent to the server you've configured, try this:

Code: Select all
debug snmp packets


A debug syslog will be displayed showing you the IP where the packet is sent to. Make sure you have 'logging monitor 7' or 'logging console 7' configured (this would be the default).

If you're trying to automate the shut/no shut of an interface, I can't offer much help there.

User avatar
Project2501
Post Whore
Posts:
6150
Joined:
Thu Apr 17, 2008 6:44 pm
Certs:
CCNA

Re: Manually generate SNMP trap

Fri Jan 13, 2012 1:49 am

Debug on a production device isn't really... lets just say that's not always a good thing. Also I need to confirm traps are making it to the traplogging boxes.

I've got rancid to go through and do

Code: Select all
config t
int lo 99
shut
no shut
exit
no int lo 99
end
exit


But it pastes the configuration so quick the device never has a chance to trap. I should be able to configure a 2-3 second delay between commands in the expect/clogin script so devices have a chance to trap.
- Pete

User avatar
wirerat
Post Whore
Posts:
5174
Joined:
Tue Mar 31, 2009 4:15 pm
Certs:
More than none

Re: Manually generate SNMP trap

Fri Jan 13, 2012 5:23 am

How about TCL? I believe it was around before EEM so may be in older versions of IOS.
"See packet, be packet, you are packet. Ignore all else!" -The Networker
packetsdropped.wordpress.com

User avatar
Project2501
Post Whore
Posts:
6150
Joined:
Thu Apr 17, 2008 6:44 pm
Certs:
CCNA

Re: Manually generate SNMP trap

Fri Jan 13, 2012 8:01 am

Yeah one of the voice guys suggested tcl. Scripting isn't my strong suit but here goes nothing.

Sent from mobile internet
- Pete

User avatar
Perlhack
Member
Posts:
231
Joined:
Wed Aug 19, 2009 7:22 pm
Certs:
CCNP CCIP CCNA-S

Re: Manually generate SNMP trap

Thu Jan 19, 2012 7:55 pm

I had some customers asking for this request as well. Attached is an EEM script that will send most of the ciscoenvmon traps.

*Edit* After several failed attempts to attach a file, its pasted below.

Code: Select all
# Install this file on the platform local media:
# event manager directory user policy <media>
# event manager policy ciscoEnvMonShutdownNotification.tcl type user
# Policy can be executed manually (user exec mode) on the platform by executing:
# event manager run ciscoEnvMonShutdownNotification.tcl

::cisco::eem::event_register_none
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.2.1.2.1 get_type exact]
set ciscoEnvMonVoltageStatusDescr $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.2.1.3.1 get_type exact]
set ciscoEnvMonVoltageStatusValue $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.2.1.7.1 get_type exact]
set ciscoEnvMonVoltageState $snmp_arr(value)


 sys_reqinfo_snmp_trapvar var vbinds2 oid 1.3.6.1.4.1.9.9.13.1.2.1.2 string $ciscoEnvMonVoltageStatusDescr
 sys_reqinfo_snmp_trapvar var vbinds2 oid 1.3.6.1.4.1.9.9.13.1.2.1.3 int $ciscoEnvMonVoltageStatusValue
 sys_reqinfo_snmp_trapvar var vbinds2 oid 1.3.6.1.4.1.9.9.13.1.2.1.7 int $ciscoEnvMonVoltageState

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.9.9.13.3  generic_trapnum 6 specific_trapnum 2 trap_oid 1.3.6.1.4.1.9.9.13.3.0.2 trap_var vbinds2
############################################ciscoEnvMonVoltageNotification########################################################

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.3.1.2.1 get_type exact]
set ciscoEnvMonTemperatureStatusDescr $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.3.1.3.1 get_type exact]
set ciscoEnvMonTemperatureStatusValue $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.3.1.6.1 get_type exact]
set ciscoEnvMonTemperatureState $snmp_arr(value)


 sys_reqinfo_snmp_trapvar var vbinds3 oid 1.3.6.1.4.1.9.9.13.1.3.1.2 string $ciscoEnvMonTemperatureStatusDescr
 sys_reqinfo_snmp_trapvar var vbinds3 oid 1.3.6.1.4.1.9.9.13.1.3.1.3 gauge $ciscoEnvMonTemperatureStatusValue
 sys_reqinfo_snmp_trapvar var vbinds3 oid 1.3.6.1.4.1.9.9.13.1.3.1.6 int $ciscoEnvMonTemperatureState

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.9.9.13.3  generic_trapnum 6 specific_trapnum 3 trap_oid 1.3.6.1.4.1.9.9.13.3.0.3 trap_var vbinds3
############################################ciscoEnvMonTemperatureNotification########################################################

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.4.1.2.1 get_type exact]
set ciscoEnvMonFanStatusDescr $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.4.1.3.1 get_type exact]
set ciscoEnvMonFanState $snmp_arr(value)


 sys_reqinfo_snmp_trapvar var vbinds4 oid 1.3.6.1.4.1.9.9.13.1.4.1.2 string $ciscoEnvMonFanStatusDescr
 sys_reqinfo_snmp_trapvar var vbinds4 oid 1.3.6.1.4.1.9.9.13.1.4.1.3 int $ciscoEnvMonFanState

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.9.9.13.3  generic_trapnum 6 specific_trapnum 4 trap_oid 1.3.6.1.4.1.9.9.13.3.0.4 trap_var vbinds4
############################################ciscoEnvMonFanNotification########################################################

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.5.1.2.1 get_type exact]
set ciscoEnvMonSupplyStatusDescr $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.5.1.3.1 get_type exact]
set ciscoEnvMonSupplyState $snmp_arr(value)


 sys_reqinfo_snmp_trapvar var vbinds5 oid 1.3.6.1.4.1.9.9.13.1.5.1.2 string $ciscoEnvMonSupplyStatusDescr
 sys_reqinfo_snmp_trapvar var vbinds5 oid 1.3.6.1.4.1.9.9.13.1.5.1.3 int $ciscoEnvMonSupplyState

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.9.9.13.3  generic_trapnum 6 specific_trapnum 5 trap_oid 1.3.6.1.4.1.9.9.13.3.0.5 trap_var vbinds5
############################################ciscoEnvMonRedundantSupplyNotification########################################################

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.2.1.2.1 get_type exact]
set ciscoEnvMonVoltageStatusDescr $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.2.1.3.1 get_type exact]
set ciscoEnvMonVoltageStatusValue $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.2.1.7.1 get_type exact]
set ciscoEnvMonVoltageState $snmp_arr(value)


 sys_reqinfo_snmp_trapvar var vbinds6 oid 1.3.6.1.4.1.9.9.13.1.2.1.2 string $ciscoEnvMonVoltageStatusDescr
 sys_reqinfo_snmp_trapvar var vbinds6 oid 1.3.6.1.4.1.9.9.13.1.2.1.3 gauge $ciscoEnvMonVoltageStatusValue
 sys_reqinfo_snmp_trapvar var vbinds6 oid 1.3.6.1.4.1.9.9.13.1.2.1.7 int $ciscoEnvMonVoltageState

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.9.9.13.3  generic_trapnum 6 specific_trapnum 6 trap_oid 1.3.6.1.4.1.9.9.13.3.0.6 trap_var vbinds6
############################################ciscoEnvMonVoltStatusChangeNotif########################################################

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.3.1.2.1 get_type exact]
set ciscoEnvMonTemperatureStatusDescr $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.3.1.3.1 get_type exact]
set ciscoEnvMonTemperatureStatusValue $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.3.1.6.1 get_type exact]
set ciscoEnvMonTemperatureState $snmp_arr(value)


 sys_reqinfo_snmp_trapvar var vbinds7 oid 1.3.6.1.4.1.9.9.13.1.3.1.2 string $ciscoEnvMonTemperatureStatusDescr
 sys_reqinfo_snmp_trapvar var vbinds7 oid 1.3.6.1.4.1.9.9.13.1.3.1.3 gauge $ciscoEnvMonTemperatureStatusValue
 sys_reqinfo_snmp_trapvar var vbinds7 oid 1.3.6.1.4.1.9.9.13.1.3.1.6 int $ciscoEnvMonTemperatureState

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.9.9.13.3  generic_trapnum 6 specific_trapnum 7 trap_oid 1.3.6.1.4.1.9.9.13.3.0.7 trap_var vbinds7
############################################ciscoEnvMonTempStatusChangeNotif########################################################

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.4.1.2.1 get_type exact]
set ciscoEnvMonFanStatusDescr $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.4.1.3.1 get_type exact]
set ciscoEnvMonFanState $snmp_arr(value)


 sys_reqinfo_snmp_trapvar var vbinds8 oid 1.3.6.1.4.1.9.9.13.1.4.1.2 string $ciscoEnvMonFanStatusDescr
 sys_reqinfo_snmp_trapvar var vbinds8 oid 1.3.6.1.4.1.9.9.13.1.4.1.3 int $ciscoEnvMonFanState

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.9.9.13.3  generic_trapnum 6 specific_trapnum 8 trap_oid 1.3.6.1.4.1.9.9.13.3.0.8 trap_var vbinds8
############################################ciscoEnvMonFanStatusChangeNotif########################################################

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.5.1.2.1 get_type exact]
set ciscoEnvMonSupplyStatusDescr $snmp_arr(value)

 array set snmp_arr [sys_reqinfo_snmp oid 1.3.6.1.4.1.9.9.13.1.5.1.3.1 get_type exact]
set ciscoEnvMonSupplyState $snmp_arr(value)


 sys_reqinfo_snmp_trapvar var vbinds9 oid 1.3.6.1.4.1.9.9.13.1.5.1.2 string $ciscoEnvMonSupplyStatusDescr
 sys_reqinfo_snmp_trapvar var vbinds9 oid 1.3.6.1.4.1.9.9.13.1.5.1.3 int $ciscoEnvMonSupplyState

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.9.9.13.3  generic_trapnum 6 specific_trapnum 9 trap_oid 1.3.6.1.4.1.9.9.13.3.0.9 trap_var vbinds9
############################################ciscoEnvMonSuppStatusChangeNotif########################################################
_______________________________________________________________________
There are 10 types of people in the world. Those who understand binary and those who don't.

User avatar
Project2501
Post Whore
Posts:
6150
Joined:
Thu Apr 17, 2008 6:44 pm
Certs:
CCNA

Re: Manually generate SNMP trap

Thu Jan 19, 2012 8:04 pm

:thinking:
- Pete

'

Return to Cisco Network Management

Who is online

Users browsing this forum: No registered users and 6 guests