Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

EEM Script - Mailing CLI Outputs

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.

  • EEM Scripting
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

The $_cli_result variable

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"

1 REPLY
Cisco Employee

The $_cli_result variable

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"

219
Views
0
Helpful
1
Replies