In previous posts, I’ve explained how you can use the SYS-5-RESTART syslog message to detect router reloads and execute commands (for example, fix router configuration or enable debugging) right after the reload. If you want to perform actions that require network connectivity (for example, send an e-mail when a router is reloaded), you cannot execute them right away, as the routing protocols might not have converged yet (in our example, the e-mail server might not be reachable).
You can use the timer countdown event to execute an EEM applet within a fixed delay after the reload. When the router is reloaded, all EEM applets stored in the startup configuration are registered and the one-time countdown timer will fire after the specified time.
For example, to execute an EEM applet that will send an e-mail twenty seconds after the router reload, you could use this configuration:
hostname test ! service timestamps debug uptime service timestamps log uptime ! event manager applet ReloadNotify event timer countdown name Delay time 20 action 1.0 info type routername action 1.1 mail server "mail.example.com" → to "email@example.com" from "$firstname.lastname@example.org" → subject "Router reload: $_info_routername" action
1.0syslog msg "E-mail was sent"
After the router is reloaded, the following syslog messages are generated (the exact timing might vary):
00:00:20: %SYS-5-CONFIG_I: Configured from memory by console 00:00:21: %SYS-5-RESTART: System restarted -- 00:00:21: %SNMP-5-COLDSTART: SNMP agent on host c7200 is undergoing a cold start 00:00:40: %HA_EM-6-LOG: ReloadNotify: E-mail was sent