Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

EEM command to read OID value

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,

Everyone's tags (5)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

EEM command to read OID value

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"

6 REPLIES
Cisco Employee

EEM command to read OID value

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"

New Member

EEM command to read OID value

Hi Joseph,

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

Thanks a lot

New Member

EEM command to read OID value

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.

Cisco Employee

EEM command to read OID value

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"

...

New Member

EEM command to read OID 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

Cisco Employee

EEM command to read OID value

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

1533
Views
5
Helpful
6
Replies
CreatePlease to create content