cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
588
Views
0
Helpful
1
Replies

TCL Script Help

tbacon
Cisco Employee
Cisco Employee

*********************************************************

Some additional information....

After much troubleshooting today, I realized that the variable wasn't having a cast problem it was actually appending the router's hostname and # to the variable itself.  So instead of having "BottomsOspfCost = 20"...it was saying "BottomsOspfCost = 20 hostname#"

I have no idea why it was and is adding this hostname to the variable.  It seems to just be happening on values that we get from polling OIDs not on our local router.  For example, the OSPF oid that we poll from the adjacent router has it appended.

*********************************************************

We are having trouble exporting a variable from a TCL script to EEM

##Creating the variable from the ospf request.  Getting the OSPF cost snmp into a variable

if [catch {cli_exec $cli1(fd) "snmp get v2c 10.10.10.1 cisco timeout 1 oid ospfIfMetricEntry.4.10.0.0.1.0.0"} RESULT] {
  error $RESULT $errorInfo
  } else {
   set BottomsOspfCostGi03Request $RESULT
}

##Chopping that variable up to just get the cost info

set BottomsOspfCostGi03List [split $BottomsOspfCostGi03Request " "]
set BottomsOspfCostGi03Index [expr [llength $BottomsOspfCostGi03List]-1]
set BottomsOspfCostGi03 [lindex $BottomsOspfCostGi03List $BottomsOspfCostGi03Index]

Now that BottomsOspfCostGi03 should be our variable that has the OSPF cost in it.  HOWEVER, we can't use it as an integer inside the EEM, which is calling a tcl policy. 

So when we try to do the following, it throws errors:

set newGi03OspfCost [expr $BottomsOspfCostGi03 * 2]

Any help that you can provide will be muchly appreciated!

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

Why are you using CLI commands here?  You can use sys_reqinfo_snmp to query SNMP is a more programmatic fashion.

array set snmp_res [sys_reqinfo_snmp oid "ospfIfMetricEntry.4.10.0.0.1.0.0" get_type exact]

set newGi03OspfCost [expr $snmp_res(value) * 2]

Review Cisco Networking for a $25 gift card