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

Making existing EEM applets simple by Tcl or python scripts.

thsmfe001
Level 1
Level 1

Hi, All

I'd like to make existing EEM applets simple by Tcl or python scripts.

To monitor nodes in an ITD service, i configure an EEM applet per a node.

But the nodes keep adding so EEM applets are also added as many as nodes.

For that reason EEM configuration get more complex so i should find out a solution.

I think It could be Tcl or Python scripts.

Could you check whether it is possible or not ?

- Monitor track or syslog pattern about ITD nodes down or up.

- When ITD nodes get down or up, the script associated with the event trigger to add or remove in a device-group.

** To reduce EEM applets i'd like to use variable to identify exact node under status change situation.

Below are current EEM configurations.

event manager applet remove_inside_node1
event track 101 state down
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "itd session device-group ips_inside"
action 4 cli command "no node ip 1.1.121.1"
action 5 cli command "commit"
action 6 cli command "end"
action 7 puts "INFO:removed node 1.1.121.1"

event manager applet add_inside_node1
event track 101 state up
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "itd session device-group ips_inside"
action 4 cli command "node ip 1.1.121.1"
action 5 cli command "commit"
action 6 cli command "end"
action 7 puts "INFO:inserted node 1.1.121.1"

Omitted...

event manager applet remove_inside_node199
event track 199 state down
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "itd session device-group ips_inside"
action 4 cli command "no node ip 1.1.121.199"
action 5 cli command "commit"
action 6 cli command "end"
action 7 puts "INFO:removed node 1.1.121.199"

event manager applet add_inside_node199

event track 199 state up
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "itd session device-group ips_inside"
action 4 cli command "node ip 1.1.121.199"
action 5 cli command "commit"
action 6 cli command "end"
action 7 puts "INFO:inserted node 1.1.121.199"

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

Using track, it's not possible as you can't match on a track pattern.  But, using track syslogs, it would be possible to consolidate these applets down to one.  For example:

event manager applet add_inside_node

 event syslog pattern "TRACK-6-STATE:.*-> Up"

 action 1.0 regexp "STATE: ([0-9]+)" "$_syslog_msg" match track

 action 2.0 cli command "enable"

 action 3.0 cli command "config t"

 action 4.0 cli command "itd session device-group ips_inside"

 action 5.0 cli command "node ip 1.1.121.$track"

 action 6.0 cli command "commit"

 action 7.0 cli command "end"

 action 8.0 syslog msg "INFO: inserted node 1.1.121.$track"

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

Using track, it's not possible as you can't match on a track pattern.  But, using track syslogs, it would be possible to consolidate these applets down to one.  For example:

event manager applet add_inside_node

 event syslog pattern "TRACK-6-STATE:.*-> Up"

 action 1.0 regexp "STATE: ([0-9]+)" "$_syslog_msg" match track

 action 2.0 cli command "enable"

 action 3.0 cli command "config t"

 action 4.0 cli command "itd session device-group ips_inside"

 action 5.0 cli command "node ip 1.1.121.$track"

 action 6.0 cli command "commit"

 action 7.0 cli command "end"

 action 8.0 syslog msg "INFO: inserted node 1.1.121.$track"

Thank you for your response.

I could make EEM configuration based on your suggestion.

The result was perfect as i expect.

event manager applet test
event syslog pattern "OTM-5-OTM_OBJECT_STATUS: Status of tracking object .* changed to DOWN"
action 1.0 regexp "object ([0-9]+)" "$_syslog_msg" match track
action 2.0 cli command "show ip sla configuration $track | in Target"
action 3.0 regexp "Target address/Source address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)" "$_cli_result" match node
action 4.0 puts "Node will be down No $node"
action 5.0 cli command "enable"
action 6.0 cli command "config t"
action 7.0 cli command "interface loopback $track"
action 8.0 cli command "no sh"
action 9.0 puts "Node will be forced to up"


Below are outputs of EEM working

N7K_VDC_1(config-if)# 2016 Aug 2 07:07:57 N7K_VDC_1 %ETHPORT-5-IF_DOWN_ADMIN_DOWN: Interface loopback101 is down (Administratively down)
2016 Aug 2 07:08:01 N7K_VDC_1 %OTM-5-OTM_OBJECT_STATUS: Status of tracking object 101 changed to DOWN
2016 Aug 2 07:08:03 N7K_VDC_1 eem_policy_dir: %eem_policy_dir-2-LOG: test: "Node will be down No 1.1.121.1"
2016 Aug 2 07:08:04 N7K_VDC_1 %VSHD-5-VSHD_SYSLOG_CONFIG_I: Configured from vty by admin on slot-9@pts/19
2016 Aug 2 07:08:04 N7K_VDC_1 eem_policy_dir: %eem_policy_dir-6-LOG: add_inside_node: INFO: inserted node object 101
2016 Aug 2 07:08:05 N7K_VDC_1 %ETHPORT-5-IF_UP: Interface loopback101 is up
2016 Aug 2 07:08:05 N7K_VDC_1 eem_policy_dir: %eem_policy_dir-2-LOG: test: "Node will be forced to up"
2016 Aug 2 07:08:08 N7K_VDC_1 %OTM-5-OTM_OBJECT_STATUS: Status of tracking object 101 changed to UP

Review Cisco Networking for a $25 gift card