09-24-2014 04:35 AM
Hi all,
I have created an EEM script for my switch to perform a few commands I would normally use then email that output to my mail address. The event triggers on interface down and emails ok, but it's missing one of the commands (it only shows the output of the show interface command) and the reason why is not immediately obvious!
Here is the script I am using:
event manager applet AP-DOWN
event syslog pattern "%ILPOWER-5-IEEE_DISCONNECT: Interface Gi1/0/1: PD removed"
action 1.0 cli command "enable"
action 1.5 cli command "config t"
action 2.0 cli command "interface Gi1/0/1"
action 2.5 cli command "shut"
action 3.0 cli command "no shut"
action 3.5 cli command "end"
action 4.0 cli command "sh mac-address table interface Gi1/0/1"
action 4.5 cli command "show interface Gi1/0/1"
action 5.0 mail server "x.x.x.x" to "myname@email.com" from "wlan-ph-c7@email.com" subject "Interface down" body "$_cli_result"
On a side note, I would like to incorporate all my switchports into the script, is it possible without having to create an applet for each interface?
Thanks.
Solved! Go to Solution.
09-26-2014 12:57 PM
The $_cli_result variable only shows the output of the last CLI command executed. What one typically does in this case is:
cli command "show mac-address table int gi1/0/1 | redirect flash:output.txt"
cli command "show int gi1/0/1 | append flash:output.txt"
cli command "more flash:output.txt"
mail ... body "$_cli_result"
cli command "del /force flash:output.txt"
09-26-2014 12:57 PM
The $_cli_result variable only shows the output of the last CLI command executed. What one typically does in this case is:
cli command "show mac-address table int gi1/0/1 | redirect flash:output.txt"
cli command "show int gi1/0/1 | append flash:output.txt"
cli command "more flash:output.txt"
mail ... body "$_cli_result"
cli command "del /force flash:output.txt"
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