This example shows how to quickly send the logs and configuration to TAC easily with EEM.
1. Configure the following required email related EEM environment variables:
event manager environment _email_server 1.2.3.4
event manager environment _email_from panda@pandaeatsbamboo.com
event manager environment _email_to attach@cisco.com
2. Configure the following EEM Applet named “sendtech”:
event manager applet sendtech
event none
action 1.1 cli command "enable"
action 1.2 cli command "del /force flash:show_tech"
action 1.3 cli command "show tech | append flash:show_tech"
action 1.4 cli command "show ip route | append flash:show_tech"
action 1.5 cli command "show ip interface brief | append flash:show_tech"
action 1.6 cli command "more flash:show_tech"
action 1.7 syslog msg "Sending show tech..."
action 1.8 mail server $_email_server to $_email_to from $_email_from subject " Show Tech Output (SR99999) " body "$_cli_result"
action 1.9 syslog msg "Show tech sent!"
Explanation of EEM Applet:
event manager applet sendtech ! registers applet with the name ‘sendtech’
event none ! specifies the event which will trigger this applet – in this case, the applet will be triggered manually
3. Verify that the EEM applet has been registered and that the environment variables have been set correctly:
R3#show event manager policy registered
No. Class Type Event Type Trap Time Registered Name
1 applet user none Off Sat Mar 16 19:39:39 2002 sendtech
policyname {sendtech} sync {yes}
maxrun 20.000
action 1.1 cli command "enable"
action 1.2 cli command "del /force flash:show_tech"
action 1.3 cli command "show tech | append flash:show_tech"
action 1.4 cli command "show ip route | append flash:show_tech"
action 1.5 cli command "show ip interface brief | append flash:show_tech"
action 1.6 cli command "more flash:show_tech"
action 1.7 syslog msg "Sending show tech.."
action 1.8 mail server "$_email_server" to "$_email_to" from "$_email_from" subject "Show Tech Output (SR12345)" body "$_cli_result"
action 1.9 syslog msg "Show tech sent!"
R3#show event manager env all
No. Name Value
1 _email_server 1.2.3.4
2 _email_from panda@pandaeatsbamboo.com
3 _email_to attach@cisco.com
4. Manually trigger the script by issuing the command “event manager run sendtech”:
R3#event manager run sendtech
*May 19 20:16:46.440: %HA_EM-6-LOG: sendtech: Sending show tech...
*May 19 20:16:46.801: %HA_EM-6-LOG: sendtech: Show tech sent!
halo
ReplyDeletei want to learn about EEM
could you help me, how i start to learn...
i never know EEM..
thnks
The best way to learn is to write your first EEM
ReplyDelete