cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2101
Views
0
Helpful
5
Replies
jprodrig01
Beginner

Help to generate snmp trap from tcl script

Hi I need to generate a trap from tcl to integrate with other tcl scripts that I have in my routers.

Here is my scritp

CORP #more flash:test.tcl

::cisco::eem::event_register_none

namespace import ::cisco::eem::*

namespace import ::cisco::lib::*

sys_reqinfo_snmp_trapvar var vbinds oid 1.3.6.1.4.1.33333.2.0 string "send_custom_trap.tcl"

sys_reqinfo_snmp_trapvar var vbinds oid 1.3.6.1.4.1.33333.3.0 string "This is a custom trap"

sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1.4.1.33333.1 generic_trapnum 6 specific_trapnum 1 trap_oid 1.3.6.1.4.1.33333.1.0.1 trap_var vbinds

CORP #

Here begins the problem

CORP #event manager run test.tcl

Embedded Event Manager policy test.tcl not registered with event none Event Detector

CORP #

and if i test this command

CORP #tclsh flash:test.tcl

invalid command name "::cisco::eem::event_register_none"

   while executing

"::cisco::eem::event_register_none"

   (file "flash:test.tcl" line 1)

thanks for your help

5 REPLIES 5
Joe Clarke
Hall of Fame Cisco Employee

This is an EEM Tcl policy and not a tclsh script.  You will need to register this policy by doing:

event manager directory user policy flash:

event manager policy test.tcl

Then you can execute it using:

event manager run test.tcl

thanks Joseph, but now I have this error

CORP(config)#event manager directory user policy flash:
CORP(config)#event manager policy test.tcl
CORP(config)#
CORP(config)#^Z
CORP#event manager run test.tcl
invalid command name "sys_reqinfo_snmp_trapvar"
    while executing
"sys_reqinfo_snmp_trapvar var vbinds oid 1.3.6.1.4.1.33333.2.0 string "send_custom_trap.tcl""
    invoked from within
"$slave eval $Contents"
    (procedure "eval_script" line 7)
    invoked from within
"eval_script slave $scriptname"
    invoked from within
"if {$security_level == 1} {       #untrusted script
     interp create -safe slave
     interp share {} stdin slave
     interp share {} stdout slave
..."
    (file "tmpsys:/lib/tcl/base.tcl" line 50)
Tcl policy execute failed: invalid command name "sys_reqinfo_snmp_trapvar"

CORP#

Joe Clarke
Hall of Fame Cisco Employee

This command is only available in newer versions of IOS (with EEM 3.1).  What version of EEM do you have?

I think that my version is 1.0

CORP#show event manager version

                              ^

% Invalid input detected at '^' marker.

CORP#show event manager envi  

CORP#show event manager environment

CORP#

I have thousands of routers with this version do you have some suggestion to generate a trap?

Joe Clarke
Hall of Fame Cisco Employee

No, you have at least 2.1.  I'm guessing probably 2.3.  You'll need 15.x for EEM 3.1.

Content for Community-Ad