TCL Script on interface down

Answered Question
Feb 23rd, 2010
User Badges:

Hello,

I was reffered to this discussion board by cisco support. We are troubleshooting an issue with cisco 7609 and need to create TCL script that does the following.

Tracks interface status and on down state executes 'show log' , 'show tech' ..... all the output needs to be saved into a file


In additon show commands needs to be executed from SIP-200 card ('attach 4' is the command to get there)


I created EEM applet but it turned out that to get to SIP-200 card TCL script is required.



Thanks

Correct Answer by Joe Clarke about 7 years 1 month ago

This version should do what you want.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Joe Clarke Tue, 02/23/2010 - 11:50
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

What version of IOS does this need to run on?  Exactly what commands need to be run on the Sup and on the line card?

EUGENE LAYKHTMAN Tue, 02/23/2010 - 12:36
User Badges:

Version  12.2(33)SRD3

Sup commands:

A. show log
B. show controllers serial 4/0/0/3:0 [5 times, pause 15 seconds between outputs]
C.show interface serial 4/0/0/3:0  [5 times, pause 15 seconds between outputs]
D. show hqf interface [5 times, pause 15 seconds between outputs]
E. show policy-map interface serial 4/0/0/3:0  [5 times, pause 15 seconds between outputs]
F. show tech


From SIP-200 [In this order]:
=============================
A. show platform software camp [5 times, pause 15 seconds between outputs]
B. show proc cpu [5 times, pause 15 seconds between outputs]
C. show platform software ibc [5 times, pause 15 seconds between outputs]
D. show plat hard egos counters [5 times, pause 15 seconds between outputs]
E. show platform hardware spi4 spa0  [5 times, pause 15 seconds between outputs]
F. show interfaces [5 times, pause 15 seconds between outputs]
G. show controllers [5 times, pause 15 seconds between outputs]
H. sh platform hardware hyperion all [5 times, pause 15 seconds between outputs]
I. sh platform hardware hyperion counters [5 times, pause 15 seconds between outputs]
J. sh platform hardware hyperion errors [5 times, pause 15 seconds between outputs]
K. sh platform hardware hyperion packet [5 times, pause 15 seconds between outputs]
L. sh platform hardware sonet [5 times, pause 15 seconds between outputs]
M. sh platform hardware iofpga [5 times, pause 15 seconds between outputs]
N. sh platform hardware ssa brief [5 times, pause 15 seconds between outputs]
O. sh platform hardware ssa counters [5 times, pause 15 seconds between outputs]
P. sh platform hardware ssa status [5 times, pause 15 seconds between outputs]  
Q. sh platform hardware eos brief [5 times, pause 15 seconds between outputs]
R. sh platform hardware eos counters [5 times, pause 15 seconds between outputs]
S. sh platform hardware eos status [5 times, pause 15 seconds between outputs]


Thanks

Joe Clarke Wed, 02/24/2010 - 20:12
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

I believe this script will do what you want.  You will need to set some EEM environment variables before you can use it.



# check_intf      : Name of the interface to watch.

#

# check_intf_file : Full patch to the file into which the command output

#                   will be saved.

#

# check_intf_mod  : Module from which additional CLI output will be collected.


For example:


event manager environment check_intf Serial4/0/0/3:0

event manager environment check_intf_file disk0:/cli_output.txt

event manager environment check_intf_mod 4


The policy must then be copied to the switch.  I typically create a directory called "policies" on one of the local flash file systems (e.g. disk0:/policies).  After creating the directory, copy the sl_check_intf.tcl policy into this directory.  Finally, after configuring the environment variables above, configure the following:


event manager directory user policy disk0:/policies

event manager policy sl_check_intf.tcl

Joe Clarke Thu, 02/25/2010 - 17:24
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

I didn't have a module with which to test other than the SP module of my 7600.  If you're using this to connect to an ESM card, for example, you may run into problems.  Here is a better version which should work more reliably.

EUGENE LAYKHTMAN Fri, 02/26/2010 - 13:57
User Badges:

Thanks Joe. I also need to remove a service policy once all show commands are done.

I tried adding a script into your file, but .....


Could you help me with that. Here are the commands:


conf t

interface serial 4/0/0/3:0

no service-policy output Parent



Thanks,

EUGENE LAYKHTMAN Tue, 03/02/2010 - 14:49
User Badges:

Joe,

I tested the script few times. The ouput fie has only the results of show commands from the privilage mode.

'show policy-map interface serial 4/0/0/3:0' is the last one (5 times)

'Show tech' and commands from the module are not there.


Thanks,

Joe Clarke Tue, 03/02/2010 - 17:42
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Do you see any messages in show logg?  I allowed this policy to run for an hour, so I don't think it's being terminated before the show tech.  If you can, collecting the output of "debug event manager tcl cli" would be helpful.

Joe Clarke Wed, 03/03/2010 - 08:58
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

You're using the wrong version of the script.  Make sure you download the LAST version in this thread.  I changed the attach approach to "remote command".  Check the script to make sure you see "remote command" and not "attach".

EUGENE LAYKHTMAN Wed, 03/03/2010 - 11:46
User Badges:

I checked and file was correct. Just in case I deleted it and uploaded again. Checked the contect of the file on the router and it has 'remote command'. Tested it again and got the same result. Do I need to re-register the script or do something else to activate the new script?


Thanks

Joe Clarke Wed, 03/03/2010 - 12:23
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Yes, you must always re-register EEM Tcl policies when you make a change.  Simply copying the new policy file to the device is not sufficient.  Just unconfigure the policy, and reconfigure it, and that will sufficiently re-register it.

EUGENE LAYKHTMAN Wed, 03/03/2010 - 14:17
User Badges:

Got it. It's running the new script now. But still cannot get output from the module 4. Here is what debug command shows :

.

.

2083110: 21w5d: %HA_EM-6-LOG: sl_check_intf.tcl : DEBUG(cli_lib) : IN  : 7600rtr#remote command module 4 show platform hardware sonet | append sup-bootdisk:ser4003_shut.txt
2083111: 21w5d: %HA_EM-6-LOG: sl_check_intf.tcl : DEBUG(cli_lib) : OUT : $atform hardware sonet | append sup-bootdisk:ser4003_shut.txt
2083112: 21w5d: %HA_EM-6-LOG: sl_check_intf.tcl : DEBUG(cli_lib) : OUT : Cannot remote to module 4

.

.


I tried running 'remote command module 4 show ..' manualy from the privilieage mode and got the same error "cannot remote to module 4"

Joe Clarke Wed, 03/03/2010 - 15:27
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

But attach works?  What type of module is this?

EUGENE LAYKHTMAN Thu, 03/04/2010 - 12:08
User Badges:

That is SIP -200, model# SPA-4XCT3/DS0


Yes, attach 4 works, though after executing attach 4 command system gives the following prompt:


7600rtr#attach 4
Entering CONSOLE for slot 4
Type "^C^C^C" to end this session


And carriage return is expected. From there 'enable' command is required to get to the privilege mode on module 4



Thank you,

Joe Clarke Thu, 03/04/2010 - 13:49
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

I didn't have a SIP-200, but I adapted my policy to work with "attach" on a SIP-600.  Give this version a shot.

EUGENE LAYKHTMAN Tue, 03/09/2010 - 07:05
User Badges:

Interesting, I ran it few times but never got output on show commands from module 4. Attached is TCL debug,it looks like correct commands are executed but there is no ouptut. Any ideas?

Thanks,

Joe Clarke Tue, 03/09/2010 - 10:12
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

I think I needed to do a "term len 0" on the SIP module.  I don't have my test SIP handy at the moment to confirm, but try this version, and see if it works.

EUGENE LAYKHTMAN Wed, 03/10/2010 - 12:46
User Badges:

Great. That worked just perfect. The only problem is, it takes too long to execute all those commands. Interface stays down till all the commands are done and service-policy is removed.

Would it be possible to run all the module commands at once, pause for 15 sec and run them again(5 times), as suppose to pausing 15 sec after each command. That should save us a lot of time. Sorry should have though about this before.



Thanks

Actions

This Discussion