msgbartop
msgbarbottom

11 Feb 15 EEM Script to shut and no shut BGP Neighbor – Cisco IOS

I am loving EEM Scripting so far. Had a need recently to accomplish the following with a script:
EEM Script 1 – Shutdown BGP Neighbor

  • Shut down BGP Neighbor
  • Add a static Route
  • Shutdown Multilink Interface
  • Save Config

EEM Script 2 – Re Enable BGP Neighbor

  • Un shut BGP Neighbor
  • Remove static route
  • Re enable Multilink Interface
  • Save Config

In order to accomplish these two tasks I created two separate scripts.

event manager applet bgp_shut
event none
action 1.0 cli command “enable”
action 1.1 cli command “conf t”
action 1.2 cli command “router bgp 65081”
action 1.3 cli command “neighbor 10.138.128.130 shutdown”
action 1.4 cli command “exit”
action 1.5 cli command “ip route 0.0.0.0 0.0.0.0 10.255.255.105”
action 1.6 cli command “int multi 1”
action 1.7 cli command “shut”
action 1.8 cli command “end”
action 1.9 cli command “wr mem”

event manager applet bgp_noshut
event none
action 1.0 cli command “enable”
action 1.1 cli command “conf t”
action 1.2 cli command “router bgp 65081”
action 1.3 cli command “no neighbor 10.138.128.130 shutdown”
action 1.4 cli command “exit”
action 1.5 cli command “no ip route 0.0.0.0 0.0.0.0 10.255.255.105”
action 1.6 cli command “int multi 1”
action 1.7 cli command “no shut”
action 1.8 cli command “end”
action 1.9 cli command “wr mem”

By visiting this website and reading the content you are agreeing to the Terms and Conditions of this website

Tags: , , ,

07 Feb 14 EEM Script for clearing – Cisco IOS

EEM Script example to clear stuff in Cisco IOS

I had to recently clear the DHCP Conflict log from a Cisco Router as it was filling up and not allowing devices to get back on the network in a specific situation. Well instead of doing it manually I just decided to give Cisco EEM Script a try. And it worked out pretty good :). Another scenario I used was clearing DHCP bindings and arp.

EEM Script – Clear DHCP Conflict Log

event manager applet CLEAR_DHCP_CONFLICT (This is applets name)
event timer watchdog time 172800 (Using the watchdog option I allowed it to run every 48 hours)
action 1.0 cli command “enable”
action 2.0 cli command “clear ip dhcp conflict *”
action 3.0 syslog msg “IP DHCP Conflict log has been cleared successfully” (syslog msg enabled me to trigger a syslog message)

EEM Script – Clear DHCP Bindings and Arp Cache

event manager applet CLEAR_DHCP_CONFLICT
event timer watchdog time 172800
action 1.0 cli command “enable”
action 2.0 cli command “clear ip dhcp binding *”
action 3.0 cli command “clear arp”
action 4.0 syslog msg “IP DHCP bindings and Arp Cache have been cleared”

So Cisco EEM Scripting is pretty cool. Possibilities are endless.

Tags: , ,

31 Aug 13 No Shut Cisco router interface automatically – EEM Script

How to re enable a Cisco router interface after shutting it down automatically

Recently I had a need to shutdown a Cisco router interface for testing, but then I needed it to be re enabled after a min or so. Well since it was a remote router I did not have console access to it, no dial up access to it either. I had an option to do a reload in xxx, but I really did not want the whole router reloaded. Thanks to Cisco Event Manager EEM Scripting :), it came to my rescue. Here are a few examples that I ended up using for my testing.

EEM Script examples that I used utilized multiple parameters, there is so much more you can do but these are just very basic for what I needed to accomplish:

EEM Script – “no shut” after 60 seconds

event manager applet NOSHUT1
event timer countdown time 60
action 1 cli command “enable”
action 2 cli command “configure terminal”
action 3 cli command “interface serial0”
action 4 cli command “no shut”

The only thing about this script was that it ran only once and that is it, countdown time would not reset, so to take care of that issue I used another option.

EEM SCript – “no shut” after 60 seconds and reset counter

event manager applet NOSHUT
event timer watchdog time 60
action 1 cli command “enable”
action 2 cli command “configure terminal”
action 3 cli command “interface serial0”
action 4 cli command “no shut”

Now with this script I would shut down an interface and after 60 seconds script re enabled it and reset the counter again. Which means when I shut the interface down again, EEM Script would re enable it again after the counter reached “0”.

EEM Script – “no shut” after detecting a pattern in the log

event manager applet NOSHUT3
event syslog pattern “Interface Serial0, changed state to administratively down”
action 1 cli command “enable”
action 2 cli command “configure terminal”
action 3 cli command “interface serial0”
action 4 cli command “no shut”

This last one pretty much looks for certain patterns in the log and if it matches, script will run and perform the actions you specify. In my case I just did a “no shut” on the serial 0 interface. So this can give you an idea on how powerful EEM Scripting can be and we can accomplish so much utilizing EEM Scripting :).

Note:Use this as a reference point only. There are other configuration options available to tweak this according to your needs. Remember to always backup your work before you make any changes, always test configurations in the lab and never do anything that you can not undo 🙂 . Terms and conditions of using this site

Tags: , , , ,

WordPress SEO