cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2029
Views
0
Helpful
1
Replies

EEM Script - Mailing CLI Outputs

petenixon
Level 3
Level 3

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.

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

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"

View solution in original post

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

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"

Review Cisco Networking for a $25 gift card