There are four steps to setting up an EEM system. In this example, we will get an email of the status of the system when the [[HSRP]] state changes. This examples defines an applet action rather than Tcl.
1. <tt>event manager environment _email_server 172.27.121.177<tt> ''<span style="color:blue;"><-- define the environment variable</span>''
12. <tt>event manager environment _email_server_email_to 172.27.121.177EMAIL_ADDRESS</tt> <i>''<span style="color:blue;"><-- define the environmentaddress to which email will variablebe sent</span></i>''
23. <tt>event manager environment _email_to_email_from EMAIL_ADDRESS</tt> <i>''<span style="color:blue;"><-- define the address tofrom which the email will be sent</span></i>''
34. <tt>event manager environmentapplet _email_from EMAIL_ADDRESSemail_hsrp_state_change</tt> <i>''<span style="color:blue;"><-- defineset the address from whichup the email will be sentpolicy</span></i>''
45. <tt>event managersyslog appletpattern email_hsrp_state_change".*%HSRP-5-STATECHANGE.*"</tt> <i>''<span style="color:blue;"><-- set updefine the policytrigger</span></i>''
56. <tt>eventaction syslog1.0 patterninfo ".*%HSRP-5-STATECHANGE.*"type routername</tt> <i>''<span style="color:blue;"><-- defineobtain the triggercurrent device hostname and place it in the $_info_routername variable</span></i>''
67. <tt>action 1.01 infocli typecommand routername"enable"</tt> <i>''<span style="color:blue;"><-- obtainactions thesuch currentas devicewriting hostnameto andflash, placemaking itconfig inchanges, theetc. require $_info_routernameenable variableprivilege</span></i>''
78. <tt>action 1.13 cli command "enableshow standby | append flash:hsrp_state_change.txt"</tt> <i>''<span style="color:blue;"><-- actionswrite suchsome asdebugging writingoutput to flash, making config changes, etc. require enable privilege</span></i>''
8. <tt>action 1.3 cli command "show standby | append flash:hsrp_state_change.txt"</tt> <i><span style="color:blue;"><-- write some debugging output to flash</span></i>
9. <tt>action 1.4 cli command "show standby brief | flash:append hsrp_state_change.txt"</tt> <i>''<span style="color:blue;"><-- more debugging output</span></i>''
10. <tt>action 1.5 mail server "$_email_server" to "$_email_to" from "$_email_from" subject "HSRP_STATE_CHANGE Alert from $_info_routername: $_syslog_msg" body "$_cli_result"</tt> <i>''<span style="color:blue;"><-- send an email with the result of the last CLI command in the body of the message</span></i>''
== Related Links ==
* [http://www.cisco.com/en/US/prod/collateral/iosswrel/ps6537/ps6555/ps6815/datasheet_c78-492444.html EEM Data Sheet]
* [[Cisco]]
<references/>
{{DEFAULTSORT:Embedded Event Manager}}
[[Category:Cisco Systems]]
|