Mail multiple printouts from EEM applet

From CT3

Jump to: navigation, search

By Ivan Pepelnjak

If you want to e-mail printouts of multiple show commands from your EEM applet, you have to:

  • execute the desired show commands and combine their outputs in a local file with the append output redirection;
  • list the contents of the selected local file with the more command;
  • send the results with the action mail command using $_cli_result variable in the e-mail body.
Usage guidelines:
  • You have to erase the file that will collect the show outputs with the delete /force command before the first show command is executed
  • The append output redirection works only on Flash cards formatted as DOS file system
  • If you cannot reformat your Flash card, use NVRAM as the temporary storage

The following sample EEM applet executes the show version and show logging commands and e-mails the results to the network operator. Please check the Send e-mail from EEM applet page for additional detailed explanations of various EEM environment variables and action mail command parameters.

ip host mail-gw.mydomain.info 10.0.0.1
event manager environment _mail_smtp mail-gw.mydomain.info
event manager environment _mail_domain mydomain.info
event manager environment _mail_rcpt operator@mydomain.info
!
event manager applet RouterReload
 event syslog occurs 1 pattern "%SYS-5-RESTART"
 action 0.1 cli command "enable"
 action 1.0 cli command "delete /force flash:output.txt"
 action 1.1 cli command "show version | append flash:output.txt"
 action 1.2 cli command "show logging | append flash:output.txt"
 action 1.3 cli command "more flash:output.txt"
 action 2.0 info type routername
 action 2.1 mail server "$_mail_smtp" to "$_mail_rcpt" from "$_info_routername@$_mail_domain" →
   subject "Reload: $_info_routername" body "$_cli_result"
Personal tools

CT3

Main menu