cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1903
Views
0
Helpful
2
Replies

I am trying to build a basic TCL skeleton script that reads a remote SNMP OID and displays the value on the screen.

tproeber
Level 1
Level 1

I am trying to build a basic TCL skeleton script that reads a remote SNMP OID and displays the value on the screen.

I don't want it to be an EEM Event, I just want to run it from the (tcl)# prompt.

So I guess I'm asking if you can use cli_exec and other commands in the "namespace import ::cisco::eem::*" in a normal non-EEM script - can I do that?


This is the error I get:


OTN.159(tcl)#source flash:TCL_SNMP_Remote_Read.tcl
invalid command name "::cisco::eem::event_register_none"             ^
% Invalid input detected at '^' marker.

What am I missing?


=================  TCL_SNMP_Remote_Read.tcl  ==============================


::cisco::eem::event_register_none

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


if [catch {cli_open} RESULT]
    { error $RESULT $errorInfo }
    else { array set cli1 $RESULT }


if [catch {cli_exec $cli1(fd) "snmp get v2c 192.168.1.100 public timeout 1 oid 1.3.6.1.2.1.1.1.0" } RESULT]
       { error $RESULT $errorInfo  }
       else { set SnmpSysDesc $RESULT }


if [catch {cli_close $cli1(fd) $cli1(tty_id)} RESULT] {
            error $RESULT $errorInfo


puts $SnmpSysDesc


=========================================================================


In the sho-run config I have:

!
event manager directory user policy "flash:/"
event manager session cli username "cisco"

!


Any help to get me started would be greatly appreciated!

Tim

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

If you don't want an EEM policy, then don't use any of the EEM constructs.  Instead, all you need is this:

set output [exec "snmp get v2c 192.168.1.100 public timeout 1 oid 1.3.6.1.2.1.1.1.0"]

puts $output

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

If you don't want an EEM policy, then don't use any of the EEM constructs.  Instead, all you need is this:

set output [exec "snmp get v2c 192.168.1.100 public timeout 1 oid 1.3.6.1.2.1.1.1.0"]

puts $output

Thanks a lot!

That gets me going.

Tim