cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5308
Views
0
Helpful
15
Replies

EEM script for show inter summary

bryan totten
Level 1
Level 1

I got great help from this community creating a EEM script which looks for output drops on a specific interface.  I would now like to do the following:

from the output of switch# "show interface summary" i would like to determine if any of the values in the OQD column have changed since last polling.  If there has been a change then write a syslog message.  (could also just check to see if the sum of all OQD values have changed since last polling).

I am not sure how to evaluate each row (interface).  I am also not sure how to only look at the OQD column of output and ignore the other 9 fields in the output.

THANKS!

2 Accepted Solutions

Accepted Solutions

Bryan,

No applet config is needed.   To verify that "show_int_summary.tcl" was successfully registered execute

"show event manager policy registered" in the switch cli.

The first line of this file has the event detector and it is currently using cron to run the policy every one minute. 

Dan

View solution in original post

The lines should free when the script terminates, but I see the script doesn't explicitly call cli_close.  Can you add the following to the end of the script and see if that helps:

catch {cli_close $cli1(fd) $cli1(tty_id)}

View solution in original post

15 Replies 15

Dan Frey
Cisco Employee
Cisco Employee

Bryan,

See the attached EEM policy to track the OQD from the show int summary command.  The policy will send a syslog message for each interface that has a different OQD value between polling cycles.

#First

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/16 previous OQD 2024957653 current OQD 2041624950

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/17 previous OQD 3942842565 current OQD 3970237661

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/18 previous OQD 211272539 current OQD 235053464

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/19 previous OQD 1351194314 current OQD 1381536130

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/20 previous OQD 1351191861 current OQD 1381533681

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/21 previous OQD 1786023656 current OQD 1793384045

# Second

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/16 previous OQD 2041624950 current OQD 2049981247

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/17 previous OQD 3970237661 current OQD 3983932106

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/18 previous OQD 235053464 current OQD 246981915

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/19 previous OQD 1381536130 current OQD 1396755462

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/20 previous OQD 1381533681 current OQD 1396753010

7w2d: %HA_EM-6-LOG: show_int_summary.tcl: DROP_PKT FastEthernet0/21 previous OQD 1793384045 current OQD 1797080539

Dan

Dan,

I really appreciate the quick response.  I am very new to EEM and this is most certainly more functionality than i have seen thus far with EEM.  So far i have performed the following steps:

1) copied  the file : show_int_summary.tcl to my 3750x switch flash:

2) event manager directory user policy "flash:/"

3) event manager policy show_int_summary.tcl

Do i now need to create an applet with an event to run the policy every x number of seconds?

thanks again!!!

bryan

Bryan,

No applet config is needed.   To verify that "show_int_summary.tcl" was successfully registered execute

"show event manager policy registered" in the switch cli.

The first line of this file has the event detector and it is currently using cron to run the policy every one minute. 

Dan

Dan,

I am very pleased this works great!!  I would like to completed understand the tcl script.  Do you have a recommendation for learning tcl/EEM?  For example i would like to at some point include the input drops into the script as well.  This i would like to handle myself.

thanks,

bryan

A good TCL book in my opinion is "Practical Programming in TCL and TK" by Brent Welch. 

http://www.beedub.com/book/

Ashish has published an EEM overview in this community at:

https://supportforums.cisco.com/docs/DOC-27996 

There is also a Cisco Press Book: TCL scripting for Cisco IOS

http://my.safaribooksonline.com/book/networking/9781587059551

Dan

I learned Tcl from Exploring Expect by Don Libes.  While it is a book for learning Expect, the second chapter covers the basics of Tcl very well pointing out things that are not obvious or should be obvious but are often overlooked. 

Mike

Dan,

This script works on a 3750x perfect.  Should this script also work on a 6500 switch with no modication?

thanks,

bryan

Bryan,

If the output (format) of the show interface summary command is the same as the 3750x then I believe it will work on the 6500.   The regexp lines need to match and parse out data from the show command and if that happens the script should work without modification.

Dan

Dan,

I feel like i am taking two steps back.  I got this script to work great on my 3750x hardware, however i am struggling just to enable on a 6500 chasis.  The error i am getting is "policy file not found" even though it is located in the disk0:/USER_TCL directory.

please see attachment

thanks!!

bryan

Try removing the trailing '/' on your EEM user policy directory path.

Joe,

thanks for the fix.  The script is now trying to execute however i am getting the following errors if i do a show log:

thanks!

bryan

You've exhausted your VTY lines.  In order for EEM to perform CLI operations, it must be able to allocate a VTY line.  EEM executes CLI exactly how a human would through a telnet or SSH session.  However, since EEM wants to play nicely with other interactive sessions, it requires there to be at least one additional free VTY line so that a human can still login.

The moral of the story is that you will need at least two free VTY lines to execute this policy.

Joe,

you are exactly right.  If i go into show users i see that all 16 vty lines are tied up.  If i " clear vty " to all lines then the eem script will run for 15 more times until the lines are all tied up again.  Is there a way to free up the vty line when the script completes?

thanks!

bryan

The lines should free when the script terminates, but I see the script doesn't explicitly call cli_close.  Can you add the following to the end of the script and see if that helps:

catch {cli_close $cli1(fd) $cli1(tty_id)}