02-14-2018 06:56 AM - edited 03-01-2019 06:24 PM
Hello;
I have several EEM scripts for Catalyst 6500 system. After upgrading from version 15.1(2)SY11 to version 15.2(1)SY5 and higher, scripts with regexp and sub-variable match stopped working.
Let me demonstrate this with simple test eem script.
::cisco::eem::event_register_syslog pattern ".*%LINEPROTO.*-5-UPDOWN: Line protocol on Interface .*, changed state to .*" maxrun 20
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
#
set syslog_info ""
#
array set arr_info [event_reqinfo]
set syslog_info $arr_info(msg)
puts "This was syslog msg: $syslog_info"
regexp {Interface\sLoopback([0-9]+),} $syslog_info match sub1
puts "match variable is: $match"
puts "sub1 variable is: $sub1"
Script should return interface Loopback name/id as sub-variable.
Test:
C6509#sh version | i IOS
Cisco IOS Software, s2t54 Software (s2t54-ADVIPSERVICESK9-M), Version 15.2(1)SY5, RELEASE SOFTWARE (fc4)
C6509#
C6509#ct
Enter configuration commands, one per line. End with CNTL/Z.
C6509(config)#int lo177
C6509(config-if)#shutdown
C6509(config-if)#^Z
C6509#
Feb 14 2018 15:26:50.379 CET: %SYS-5-CONFIG_I: Configured from console by srcsiki on vty0 (172.25.5.77)
C6509#
Feb 14 2018 15:26:51.539 CET: %LINK-5-CHANGED: Interface Loopback177, changed state to administratively down
Feb 14 2018 15:26:52.539 CET: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback177, changed state to down
C6509#
Feb 14 2018 15:26:52.687 CET: %HA_EM-6-LOG: test.tcl: This was syslog msg:
Feb 14 2018 15:26:52.687 CET: %HA_EM-6-LOG: test.tcl: Feb 14 2018 15:26:52.539 CET: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback177, changed state to down
Feb 14 2018 15:26:52.691 CET: %HA_EM-6-LOG: test.tcl: match variable is: Interface Loopback177,
Feb 14 2018 15:26:52.691 CET: %HA_EM-6-LOG: test.tcl: sub1 variable is:
C6509#
! "sub-variable" is not present only complete "match" variable
! "downgrade to version 15.1(2)SY11"
C6509#sh ver | i IOS
Cisco IOS Software, s2t54 Software (s2t54-ADVIPSERVICESK9-M), Version 15.1(2)SY11, RELEASE SOFTWARE (fc3)
C6509#
C6509#ct
Enter configuration commands, one per line. End with CNTL/Z.
C6509(config)#int lo177
C6509(config-if)#shutdown
C6509(config-if)#^Z
C6509#
Feb 14 2018 15:36:06.448 CET: %SYS-5-CONFIG_I: Configured from console by srcsiki on vty0 (172.25.5.77)
Feb 14 2018 15:36:06.920 CET: %LINK-5-CHANGED: Interface Loopback177, changed state to administratively down
C6509#
Feb 14 2018 15:36:07.920 CET: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback177, changed state to down
C6509#
Feb 14 2018 15:36:08.052 CET: %HA_EM-6-LOG: test.tcl: This was syslog msg:
Feb 14 2018 15:36:08.052 CET: %HA_EM-6-LOG: test.tcl: Feb 14 2018 15:36:07.920 CET: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback177, changed state to down
Feb 14 2018 15:36:08.052 CET: %HA_EM-6-LOG: test.tcl: match variable is: Interface Loopback177,
Feb 14 2018 15:36:08.052 CET: %HA_EM-6-LOG: test.tcl: sub1 variable is: 177
C6509#
! "sub-variable" and "match" variable are present
I have tested also with ios version 15.4(1)SY3, result was the same.
If using EEM Applet than everything works ok with all ios versions tested.
Any idea?
Best Regards,
Branko
Solved! Go to Solution.
02-15-2018 05:39 AM
Lists are easy with applets. Any space-separated string can be a list.
set lst "item1 item2 item3"
foreach item $lst
puts $item
end
02-14-2018 11:37 AM
This is the first I've heard of this, but it is a known bug: CSCvf41331. It's broken up through 15.5 exactly how you describe. Looks like the next release of 15.5 should have the fix.
But applets should work correctly. And you have EEM 4.0 in this code, so there is a lot you can do without needing Tcl. Certainly this trivial example could be an applet.
02-14-2018 11:48 PM
Hi Joe;
Thanks for info provided. I have assumed something like that. I have already moved some tcl scripts to eem applet, but it is not so flexible and right now I'm struggling with lists. I can not find applets supporting lists, probably I will need to find some workaround for this.
Best regards,
Branko
02-15-2018 05:39 AM
Lists are easy with applets. Any space-separated string can be a list.
set lst "item1 item2 item3"
foreach item $lst
puts $item
end
02-16-2018 05:06 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide