Did you know your Cisco router could send you an e-mail? Until recently, I would have said that it wasn’t possible, but today, I’ll show you how to do it. And we won’t stop there: I’ll tell you where to find some other scripts that you can use on your Cisco router. Let’s see how the Cisco IOS Tool Command Language (TCL) can make your Cisco administration easier.
A while ago, I wrote an article introducing TCL — “Get to know Cisco’s Tool Command Language (TCL)” — and I told you how you can create your own scripts using TCL. To run TCL, your router needs to be running Cisco IOS 12.3(2)T or later.
While TCL offers many uses for your Cisco router, it needs to be able to communicate with the Cisco IOS. Traditionally, when an event happens on a Cisco router, it sends that event to a management station on your network for some subsequent action. However, with Cisco’s introduction of the Embedded Event Manager (EEM), Cisco routers now have more intelligence and can take actions on their own.
Cisco originally released EEM 1.0 in IOS versions 12.0(26)S and 12.3(4)T. Today, with IOS versions 12.4(2)T, 12.2(31)SB3, 12.2(33)SRB, we’re up to EEM version 2.2, and we’ve gained many features along the way. To learn more, check out Cisco’s Embedded Event Manager Overview.
I suspect that TCL and EEM sound only moderately interesting to most of you because, like any scripting language, it can be difficult to envision what you can do with it. To help you understand the power of EEM, Cisco has created the Embedded Event Manager (EEM) Scripting Community.
Thanks to this site, you can not only download many useful scripts, but you can also submit your own to share with other Cisco users. Kudos to Cisco for this excellent resource!
Send e-mail with your router
To better understand the uses of TCL and EEM, let’s look at an example. Here’s a simple demonstration of how a router can send an e-mail that contains the output of the show version command.
First, I went to the EEM Scripting Community and downloaded the Send Email script. I unzipped the script and ended up with a simple text file called Sendmail.tcl.
Next, I stated my TFTP server on my PC, and I used TFTP on the router to transfer the modified script from my PC to the router’s flash. Figure A shows you what it looked like.
Next, I ran the following command while in Global Configuration Mode:
Router(config)# event manager directory user policy flash:
Then, according to the instructions included in the script’s comments, I set the following environmental variables on the router to fit my particular configuration (still in Global Configuration Mode), as shown in Figure B:
event manager environment _email_server 10.10.10.10
event manager environment _email_from firstname.lastname@example.org
Router(config)#event manager environment _email_to email@example.com
Next, I registered the script using the following command:
Router(config)# event manager policy sendmail.tcl
Finally, I ran the script using the event manager run sendmail.tcl command. If all goes well, there’s no output. Figure C shows the e-mail message.
You can also modify this script to run on triggered events. For example, there’s a script called showtech that you can use to e-mail the output from the show tech-support command directly to Cisco or to yourself. For more information, check out Cisco’s video tutorials on using TCL/EEM router scripts.
More uses for TCL and EEM
While this article has focused on using TCL and EEM to send an e-mail with your router, I want to stress that there are so many more practical uses for TCL and EEM with the Cisco IOS. For example, one of the most useful things you can do with TCL and EEM is use a set of diagnostic scripts dubbed IOS Service Diagnostics. Such scripts are available for OSPF, BGP, and QoS.
With these scripts running on your router, when abnormal events occur (such as losing an OSPF Neighbor), your router can automatically attempt to diagnose the issue, perhaps take action to solve it, or, if nothing else, notify you of the issue along with all of the relevant information needed to resolve it. In other words, the scripts can provide for a shorter Mean Time To Repair (MTTR) — which equates to cost savings. In addition, the scripts can increase network uptime, quickly identify root causes, and automatically collect network troubleshooting data.
Here are some of the other interesting scripts available:
- Memory Health
- Power and Temperature Health
- Composite Device Health — Interface Errors
- HSRP State Change
- L3 Path Failure Detection — EIGRP Neighbor Change
- VPN Failure Detection
- WAN Load Alarm
According to Cisco’s IOS Service Diagnostic Web site, Cisco plans on introducing a management interface to help administrators manage these types of scripts on Cisco routers. I look forward to trying that out as soon as it’s available. In the meantime, we have a lot of powerful scripts available to test and learn about. In fact, you could even write your own!
What do you want your router to troubleshoot or notify you about today? Add your ideas in this article’s discussion.
Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!
Subscribe to the Developer Insider Newsletter
From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays