cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2904
Views
5
Helpful
6
Replies

EEM command to read OID value

vgershman
Level 1
Level 1

Hi,

I am trying to change SNMPv2 community string on 6509 remotely, without using expect script. I tried EEM applet (we cannot use TCL scripts), but it does not work.

EEM command "action 10 info snmp oid 1.3.6.1.2.1.1.4 get-type exact" is supposed to store the result into an environment variable. It does not. Or at least not in the one that is documented. Is it a bug? We have IOS 12.2(17r)SX5.  To get EEM version i ran "sh event manager version" and got  "eem: (v240_throttle) 2.21.32". Does it mean i have EEM version 2.21?

Thanks,

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

You have EEM 2.4, but you're IOS version is definitely not 12.2(17r)SX5.  That is your boot code version.  The output of the action here will be in the variable $_info_snmp_value.

action 10 info snmp oid 1.3.6.1.2.1.1.4.0 get-type exact

action 20 syslog msg "Result is $_info_snmp_value"

View solution in original post

6 Replies 6

Joe Clarke
Cisco Employee
Cisco Employee

You have EEM 2.4, but you're IOS version is definitely not 12.2(17r)SX5.  That is your boot code version.  The output of the action here will be in the variable $_info_snmp_value.

action 10 info snmp oid 1.3.6.1.2.1.1.4.0 get-type exact

action 20 syslog msg "Result is $_info_snmp_value"

Hi Joseph,

i was missing ".0" at the end of the OID. This works now.

Thanks a lot

Hi Joseph

What if we would like to get mutiple snmp information from the device,.. What shoud be the stored variable? Does it allow us to save multiple snmp values? Please advice. Thank you, Joseph.

Just continue to use the info snmp action.  Each time through the result will be stored in the $_info_snmp_value variable.  For example:

action 1.0 info snmp oid 1.3.6.1.2.1.1.4.0 get-type exact

action 2.0 syslog msg "Result is $_info_snmp_value"

action 3.0 info snmp oid 1.3.6.1.2.1.1.5.0 get-type exact

action 4.0 syslog msg "Result is $_info_snmp_value"

...

Joseph

Thank you for your reply.

The reason I asked about storing the variable (Ex. snmp) is that. I am trying to compare the snmp value between the previous triggered event and the current triggered event. I think I need to store a valiable to do it. Would you recommend any way to do so

You would need to save that data into a context.  You will need EEM 3.0 or higher for this, but you could do something like:

action 1.0 info snmp oid 1.3.6.1.2.1.1.4.0 get-type exact

action 2.0 set snmp_res1 $_info_snmp_value

action 3.0 info snmp oid 1.3.6.1.2.1.1.5.0 get-type exact

action 4.0 set snmp_res2 $_info_snmp_value

action 5.0 context save key SNMPCTX variable snmp_res*

To retrieve the previously saved values, use:

action 1.0 handle-error type ignore

action 2.0 context retrieve key SNMPCTX

action 3.0 if $_error ne FH_EOK

action 4.0  set snmp_res1 0

action 5.0  set snmp_res2 0

action 6.0 end

action 7.0 handle-error type exit

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: