11-26-2012 12:23 PM
Hello Experts,
I have taken the following sample EEM from
https://learningnetwork.cisco.com/blogs/network-sheriff/2009/06/19/writing-your-first-eem-applet
The intention is to send a notification to an email address about a network problem. I have modified it bit for illustrative purposes. You will see that there are various show commands.
Can someone please show me how to email the show commands instead just appending them to the directory called "server_unreachable"?
TechWiseTV4506(config)#eve
nt manager environment _email_server 172.16.1.44 (<-my Post Cast server)
TechWiseTV4506(config)#event manager environment _email_to jimmyray@cisco.com
TechWiseTV4506(config)#event manager environment _email_from crapsrv@cisco.com
event manager applet email_server_unreachable
event track 10 state down
action 1.0 syslog msg "Houston we have a problem. Ping failed, server unreachable!"
action 1.1 cli command "enable"
action 1.2 cli command "del /force flash:server_unreachable"
action 1.3 cli command "show clock | append server_unreachable"
action 1.4 cli command "show ip arp 172.16.1.55 | append server_unreachable"
action 1.5 cli command "show ip route 172.16.1.55 | append server_unreachable"
action 1.6 cli command "show interface FastEthernet0/1/1 | append server_unreachable"
action 1.7 cli command "more flash:server_unreachable"
action 1.8 mail server "$_email_server" to "$_email_to" from "$_email_from" subject "Server Unreachable: ICMP-Echos Failed" body "$_cli_result
action 1.9 syslog msg "Server unreachable alert has been sent to email server!"
Cheers
Carlton
Solved! Go to Solution.
11-26-2012 12:51 PM
This applet will actually email the results. However, in order to get all of the output together, it uses the server_unreachable file as an accumulator buffer. That file could be deleted as action 2.0:
action 2.0 cli command "delete /force flash:server_unreachable"
But that is already there in action 1.2, so it's not really needed.
What will happen is the applet will more the file to collect all of the output. That aggregated output will be stored in the $_cli_result variable. The result is that the body of your email will contain the consolidated command output.
11-26-2012 12:51 PM
This applet will actually email the results. However, in order to get all of the output together, it uses the server_unreachable file as an accumulator buffer. That file could be deleted as action 2.0:
action 2.0 cli command "delete /force flash:server_unreachable"
But that is already there in action 1.2, so it's not really needed.
What will happen is the applet will more the file to collect all of the output. That aggregated output will be stored in the $_cli_result variable. The result is that the body of your email will contain the consolidated command output.
11-26-2012 01:18 PM
Hi Joseph,
Thanks for responding.
All I need is a email server that I can get to work. I'm not having any luck with the suggested podcast server.
Do you know of any?
Cheers
Carlton
11-26-2012 01:20 PM
I don't know of any open SMTP servers (those are generally considered insecure). Do you not have a corporate SMTP server you can use?
11-26-2012 01:32 PM
Hi Joseph,
I'm a contractor working from home.
11-26-2012 01:35 PM
Then your email provider (e.g., Comcast, Time Warner, etc.) must offer an SMTP server. Can you use that one?
11-26-2012 01:36 PM
I'm just unsure on what email address I need to place in the 'from box'?
11-26-2012 01:45 PM
Generally it can be anything you want. If you're using Comcast, for example, you could do: noreply@comcast.net or myrouter@comcast.net.
11-26-2012 01:51 PM
Actually, I think its my dns settings.
When I check out the logs I see the following:
PostCast Server 2.6.0
SMTP log started at 11/26/2012 09:41:35 PM
Thread 1: 09:41:51 PM [<-->] : Error: DNS timeout. Unable to resolve (myserver)
My dns ip is 192.168.0.1 (which I'm sure won't resolve anything)
What do you think?
11-26-2012 01:53 PM
I'm not familiar with PostCast, but typically SMTP servers will want to resolve themselves as well as tne envelope hostname. You can usually work around the first thing by using a local hosts file. However, the server's own hostname should be able to be resolved automatically.
11-26-2012 01:59 PM
Joseph,
I tried entering 192.168.0.3 as the hostname or 127.0.0.1 for the from email address but I keep on getting the same message.
11-26-2012 02:03 PM
Sorry, I don't have any advice to offer on PostCast. Perhaps Google can shed some light on how to fix that error.
11-27-2012 03:09 AM
Hi Joseph,
Thanks for your help.
I don't know how to add 5 star ratings...
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