09-10-2013 09:06 AM
We have a New config going to all routers in the field. We upload the config to flash and then allow the customer to login to router and copy from flash to startup and reload when they are ready to do the conversion. We created an eem script that will reload the router to the older version of the config if they do not login within 20 minutes and remove the eem script. They now want to bypass the manual disabling of the eem script and want it automated. I have most of it working except the write mem process.
Customer logs in and manually removes this: Works
event manager applet SetConfig
event timer watchdog time 1200
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "file prompt quiet"
action 1.3 cli command "end"
action 2.0 cli command "copy original.cfg startup-config"
action 3.0 syslog msg "EEM forced reload"
action 4.0 reload
end
Automated removal of eem script and all its settings: Works
event manager applet Delete_SetConfig
event track 333 state up
event timer watchdog time 600
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "no event manager applet SetConfig"
action 1.3 cli command "no ip sla 6"
action 1.4 cli command "no ip sla 7"
action 1.5 cli command "no track 111 rtr 6 reachability"
action 1.6 cli command "no track 222 rtr 7 reachability"
action 1.7 cli command "no track 333 list threshold weight"
action 1.8 cli command "no event manager applet Delete_SetConfig"
action 1.9 cli command "end"
Once the eem script above processes, we want to write running-config to startup-config: Fails
event manager applet Write_Memory
event cli pattern "no event manager applet Delete_SetConfig" sync yes occurs 1
action 1.0 cli command "write memory"
action 1.1 cli command "end"
!
Any Ideas on how to get this to work?
Solved! Go to Solution.
03-31-2020 06:15 PM
try copy running to startup instead
09-11-2013 10:16 AM
You need EEM 3.0 for the wait action. Prior to that, you could configure yet another applet to countdown the time needed then do the action. That is, have the Write_Memory applet just configure a new applet that uses a countdown event to countdown 1 or some other amount of seconds, then have IT perform the write mem. Make sense?
09-11-2013 10:30 AM
I.... Guess sooooo
Concept makes sense but how to accomplish it I don't even want to look at trying to figure out right now
Buried alive with lots of stuff
Thanks Again,
You Rock!
09-11-2013 10:59 AM
Hey Joseph,
I noticed when I copy my EEM script the "event timer watchdog time 600" overwrites the "event track 333 state up" line. I want to track this 333 for ten minutes and then do all the removals and write mem after being up for ten minutes. Are these commands mutually exclusive? Is there a way to track the 333 up for 10 mins?
Here is what I have applied but the line "event track 333 state up" is not there.
event manager applet Delete_SetConfig
event track 333 state up
event timer watchdog time 600
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "no event manager applet SetConfig"
action 1.3 cli command "no ip sla 6"
action 1.4 cli command "no ip sla 7"
action 1.5 cli command "no track 111 rtr 6 reachability"
action 1.6 cli command "no track 222 rtr 7 reachability"
action 1.7 cli command "no track 333 list threshold weight"
action 1.75 publish-event sub-system 798 type 1 arg1 "WRITE-MEM"
action 1.8 cli command "no event manager applet Delete_SetConfig"
action 1.9 cli command "end"
event manager applet Write_Memory
event application sub-system 798 type 1
action 1.0 cli command "enable"
action 2.0 cli command "write mem"
event manager applet SetConfig
event timer watchdog time 1200
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "file prompt quiet"
action 1.3 cli command "end"
action 2.0 cli command "copy original.cfg startup-config"
action 3.0 syslog msg "EEM forced reload"
action 4.0 reload
!
09-11-2013 08:05 PM
Yes, the commands are mutually exclusive. If you have EEM 2.4 or higher (which I don't think you do) you can use multiple events, but I don't think that will help for what you want to do.
Essentially, what you want to do is have your event track applet configure a timer countdown applet (call it Timer_Delete_SetConfig") that counts down 600 seconds. This is similar to this other thread I helped you with:
https://supportforums.cisco.com/message/675502#675502
The timer countdown applet, if allowed to reach 0 will remove those config bits you have in Delete_SetConfig. You'll also need another applet like this:
event manager applet Stop_Timer
event track 333 state down
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "no event manager applet Timer_Delete_SetConfig"
action 4.0 cli command "end"
09-12-2013 09:13 AM
I am having a tough time getting my head around this this morning . If I create a new applet that removes my "bits" then wouldn't the tracking go down and then it would never delete the Timer_Delete_SetConfig? I am really confused now
event manager applet Delete_SetConfig
event track 333 state up
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "event manager applet Timer_Delete_SetConfig"
action 1.3 cli command "event timer watchdog time 600"
action 1.35 cli command "no ip sla 6"
action 1.4 cli command "no ip sla 7"
action 1.5 cli command "no track 111 rtr 6 reachability"
action 1.6 cli command "no track 222 rtr 7 reachability"
action 1.7 cli command "no track 333 list threshold weight"
action 1.75 publish-event sub-system 798 type 1 arg1 WRITE-MEM
action 1.8 cli command "no event manager applet Delete_SetConfig"
action 1.9 cli command "end"
!
event manager applet Write_Memory
event application sub-system 798 type 1
action 1.0 cli command "enable"
action 2.0 cli command "write mem"
!
event manager applet Stop_Timer
event track 333 state down
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "no event manager applet Timer_Delete_SetConfig"
action 4.0 cli command "end"
!
event manager applet SetConfig
event timer watchdog time 1200
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "file prompt quiet"
action 1.3 cli command "end"
action 2.0 cli command "copy original.cfg startup-config"
action 3.0 syslog msg "EEM forced reload"
action 4.0 reload
09-12-2013 01:24 PM
It would look like:
event manager environment q "
!
event manager applet Delete_SetConfig
event track 333 state up
action 001 cli command "enable"
action 002 cli command "config t"
action 003 cli command "event manager applet Timer_Delete_SetConfig"
action 004 cli command "event timer countdown time 600"
action 005 cli command "action 1.0 cli command enable"
action 006 cli command "action 1.1 cli command $q config t$q"
action 007 cli command "action 1.2 cli command $q no ip sla 6$q"
action 008 cli command "action 1.3 cli command $q no ip sla 7$q"
action 009 cli command "action 1.4 cli command $q no track 111 ip sla 6 reachability$q"
action 010 cli command "action 1.5 cli command $q no track 222 ip sla 7 reachability$q"
action 011 cli command "action 1.6 cli command $q no track 333 list threshold weight$q"
action 012 cli command "action 1.7 publish-event sub-system 798 type 1 arg1 WRITE-MEM"
action 013 cli command "action 1.8 cli command $q no event manager applet Delete_SetConfig$q"
action 014 cli command "action 1.9 cli command $q no event manager applet Stop_Timer$q"
action 015 cli command "action 2.0 cli command $q no event manager applet Timer_Delete_Setconfig$q"
action 016 cli command "end"
The rest remain the same.
09-12-2013 04:44 PM
OK, what a day.
This look right?
event manager environment q "
event manager applet Write_Memory
event application sub-system 798 type 1
action 1.0 cli command "enable"
action 2.0 cli command "write mem"
!
event manager applet Delete_SetConfig
event track 333 state up
action 001 cli command "enable"
action 002 cli command "config t"
action 003 cli command "event manager applet Timer_Delete_SetConfig"
action 004 cli command "event timer countdown time 600"
action 005 cli command "action 1.0 cli command enable"
action 006 cli command "action 1.1 cli command $qconfig t$q"
action 007 cli command "action 1.2 cli command $qno ip sla 6$q"
action 008 cli command "action 1.3 cli command $qno ip sla 7$q"
action 009 cli command "action 1.4 cli command $qno track 111 ip sla 6 reachability$q"
action 010 cli command "action 1.5 cli command $qno track 222 ip sla 7 reachability$q"
action 011 cli command "action 1.6 cli command $qno track 333 list threshold weight$q"
action 012 cli command "action 1.7 publish-event sub-system 798 type 1 arg1 WRITE-MEM"
action 013 cli command "action 1.8 cli command $qno event manager applet Delete_SetConfig$q"
action 014 cli command "action 1.9 cli command $qno event manager applet Stop_Timer$q"
action 015 cli command "action 2.0 cli command $qno event manager applet Timer_Delete_SetConfig$q"
action 016 cli command "end"
!
event manager applet Stop_Timer
event track 333 state down
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "no event manager applet Timer_Delete_SetConfig"
action 4.0 cli command "end"
!
event manager applet SetConfig
event timer watchdog time 1200
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "file prompt quiet"
action 1.3 cli command "end"
action 2.0 cli command "copy original.cfg startup-config"
action 3.0 syslog msg "EEM forced reload"
action 4.0 reload
09-12-2013 09:34 PM
You need a space between $q and the start of the command. For example "$q no ..."
09-13-2013 01:16 PM
It's not working as I would have hoped. It was not cleaning up all the other eem scripts as expected and them I moved the write mem around to get it to delete the eem's but now the write mem fails to run. You have time for a webex to discuss the logic and look at what happens?
Here is what I have in the initial config.
event manager applet Write_Memory
event application sub-system 798 type 1
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "no event manager applet SetConfig"
action 1.1 cli command "end"
action 2.0 cli command "write mem"
event manager applet Delete_SetConfig
event track 333 state up
action 001 cli command "enable"
action 002 cli command "config t"
action 003 cli command "event manager applet Timer_Delete_SetConfig"
action 004 cli command "event timer countdown time 600"
action 005 cli command "action 1.0 cli command enable"
action 006 cli command "action 1.1 cli command $q config t$q"
action 007 cli command "action 1.2 cli command $q no ip sla 6$q"
action 008 cli command "action 1.3 cli command $q no ip sla 7$q"
action 009 cli command "action 1.4 cli command $q no track 111 ip sla 6 reachability$q"
action 010 cli command "action 1.5 cli command $q no track 222 ip sla 7 reachability$q"
action 011 cli command "action 1.6 cli command $q no track 333 list threshold weight$q"
action 012 cli command "action 1.7 cli command $q no event manager applet Stop_Timer$q"
action 013 cli command "action 1.8 cli command $q no event manager applet Timer_Delete_SetConfig$q"
action 014 cli command "action 1.9 publish-event sub-system 798 type 1 arg1 WRITE-MEM"
action 015 cli command "action 2.0 cli command $q no event manager applet Delete_SetConfig$q"
action 016 cli command "end"
event manager applet Stop_Timer
event track 333 state down
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "no event manager applet Timer_Delete_SetConfig"
action 4.0 cli command "end"
event manager applet SetConfig
event timer watchdog time 1200
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "file prompt quiet"
action 1.3 cli command "end"
action 2.0 cli command "copy original.cfg startup-config"
action 3.0 syslog msg "EEM forced reload"
action 4.0 reload
09-14-2013 11:27 AM
Your order of removals is out of whack. You need to swap actions 013 and 015 in the Delete_SetConfig applet. That is, when Timer_Delete_SetConfig is running, it needs to delete Delete_SetConfig first, then itself last.
09-17-2013 04:27 PM
Hi Joe,
The write mem works but the original requirement to dynamically remove the
eem reboot script is not. Here is what is left in the config.
event manager applet SetConfig
event timer watchdog time 1200
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "file prompt quiet"
action 1.3 cli command "end"
action 2.0 cli command "copy original.cfg startup-config"
action 3.0 syslog msg "EEM forced reload"
action 4.0 reload
09-17-2013 07:48 PM
In Delete_SetConfig add an action 0141 or the like that does:
cli command "action 1.91 cli command $q no event manager applet SetConfig$q"
09-19-2013 07:47 AM
Hi Joe, The following did not get deleted.
"event manager applet Timer_Delete_SetConfig"
Yet "event manager applet SetConfig" was deleted and they both come after the write mem.
I am trying to understand something. If the the eem policy has been "registered" and it gets deleted, does what has already been registered continue to run? Because if I change the order of some of these deletions, it seems as if some run and some don't, as in this case mentioned.
Here is the current script.
event manager applet Delete_SetConfig
event track 333 state up
action 001 cli command "enable"
action 002 cli command "config t"
action 003 cli command "event manager applet Timer_Delete_SetConfig"
action 004 cli command "event timer countdown time 600"
action 005 cli command "action 1.0 cli command enable"
action 006 cli command "action 1.1 cli command $q config t$q"
action 007 cli command "action 1.2 cli command $q no ip sla 6$q"
action 008 cli command "action 1.3 cli command $q no ip sla 7$q"
action 009 cli command "action 1.4 cli command $q no track 111 ip sla 6 reachability$q"
action 010 cli command "action 1.5 cli command $q no track 222 ip sla 7 reachability$q"
action 011 cli command "action 1.6 cli command $q no track 333 list threshold weight$q"
action 012 cli command "action 1.7 cli command $q no event manager applet Stop_Timer$q"
action 013 cli command "action 1.8 cli command $q no event manager applet Delete_SetConfig$q"
action 014 cli command "action 1.9 publish-event sub-system 798 type 1 arg1 WRITE-MEM"
action 015 cli command "action 2.0 cli command $q no event manager applet SetConfig$q"
action 016 cli command "action 2.1 cli command $q no event manager applet Timer_Delete_SetConfig$q"
action 017 cli command "end"
event manager applet Stop_Timer
event track 333 state down
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "no event manager applet Timer_Delete_SetConfig"
action 4.0 cli command "end"
!
event manager applet SetConfig
event timer watchdog time 1200
action 1.0 cli command "enable"
action 1.1 cli command "conf t"
action 1.2 cli command "file prompt quiet"
action 1.3 cli command "end"
action 2.0 cli command "copy original.cfg startup-config"
action 3.0 syslog msg "EEM forced reload"
action 4.0 reload
09-19-2013 12:16 PM
Your policies look right to me. Yes, in your version of IOS, if the policy is unconfigured, even by itself, it will be forcibly terminated. That is why deleting the current policy must be its very last action. And that appears to be the case in Timer_Delete_SetConfig. The problem might be that the event is acted upon before the Timer_Delete_SetConfig policy can be deleted. I had that concern from the beginning. That is why I suggested you may need to add some delay between when the event is received and when the write mem is performed. You can do that by having the applet that currently does the write mem install yet another nested applet that counts down a second or two, then does the write mem.
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