EEM-TCL Script to switch config from interface X to interface Y

Hello Guys,
I’m trying to create a script which is controlled by an EEM-UPDOWN event of an interface. What I’m trying to do is, if interface X is down for some reason it should copy the interface configuration to interface Y.
So my problem is I’m very new to eem-tcl scripting and I have some basic problem hopefully u can help me =) I’m working on a ASR9K !
So what i have done so fare:
::cisco::eem::event_register_syslog occurs 1 pattern ".*CHANGED.*$_sat_1_link_1.*" maxrun 90   
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
if {$_cerrno != 0} {
    set result [format "component=%s; subsys err=%s; posix err=%s;\n%s" \
      $_cerr_sub_num $_cerr_sub_err $_cerr_posix_err $_cerr_str]
    error $result
if [catch {cli_open} result] {
    error $result $errorInfo
} else {
    array set cli1 $result
action_syslog priority emergencies msg "start script testv1_1"
#puts "\nEXECUTE CLI COMAND :\n"
set out {cli_exec $cli1(fd) "show running-config formal interface $_sat_1_link_1"}
set xout [split $out \n]
#puts "DEBUG : $xout \n\n"
set anz [llength $xout]
#puts "DEBUG : count rows = $anz \n\n"
for {set ii "0"}  {$ii < $anz } {incr ii} {
       set indexout [lindex $out $ii]
    regexp  {([\w]+)[ ]([\w\d/]+)\s(.*)} $indexout a b c d
    #puts "\nDEBUG START"
    #puts "\nindex Nr  $ii"
    #puts "Full Match: $a"
    #puts "Sub Match1: $b"
    #puts "Sub Match2: $c"
    #puts "Sub Match3: $d"
    #puts "DEBUG END\n"
    set intsrc {cli_exec $cli1(fd) "no $b $_sat_1_link_1 $d"}
    set intdest {cli_exec $cli1(fd) "$b $_sat_1_link_2 $d"}
if [catch {cli_exec $cli1(fd) "commit"} result] {
    error $result $errorInfo
if [catch {cli_exec $cli1(fd) "end"} result] {
    error $result $errorInfo
action_syslog priority emergencies msg "End script testv1_1"
ps. $_sat_1_link_1 and $_sat_1_link_2 are globaly set per cli in the event manager env.
Thanks for your help and hopefully u can help me with this script

Hey
after show running-config formal interface TenGigE 0/0/2/1 the cli output example is :
interface TenGigE0/0/2/1 description Test: 0-43
interface TenGigE0/0/2/1
interface TenGigE0/0/2/1 shutdown
and now i want to split the config with my regex
regexp  {([\w]+)[ ]([\w\d/]+)\s(.*)} $indexout a b c d
As example line 1
set x= "TenGigE0/0/2/2"                  --> =dest_interface
a= interface TenGigE0/0/2/1 description Test: 0-43
b= interface
c= TenGigE0/0/2/1
d= description Test: 0-43
do this
cli_exec $cli1(fd) "no $b $c $d"      --->no interface TenGig E0/0/2/1 description Test: 0-43
cli_exec $cli1(fd) " $b $x $d"          ---> interface TenGigE0/0/2/2 description Test: 0-43
and from this point it shoud do this until there are no config lines  =)
as a final result is should copy the whole config from interface X to interface Y  if the trigger is active
but as i see, the main problem is to get the CLI output in a format like this
set xy = interface TenGigE0/0/2/1 description Test: 0-43\ninterface TenGigE0/0/2/1\ninterface TenGigE0/0/2/1 shutdown
or in an index like this:
Index | command
1         interface TenGigE0/0/2/1 description Test: 0-43
2         interface TenGigE0/0/2/1
3         interface TenGigE0/0/2/1 shutdown
Thx

Similar Messages

  • EEM TCL script configuration issue

    Hi Experts,
    I need help with an EEM TCL script for the CRS platform that generates a SYSLOG message after the CPU reaches a threshold value and then stays over the threshold value for 15 minutes, I've already tryied several thing and the last TCL script that I tested generated the SYSLOG message when the CPU reaches the threshold but I can't seem to find any way to make it wait the 15 min over the threshold and then generate the message.
    My current script looks like this:
    ::cisco::eem::event_register_wdsysmon timewin 900 sub1 cpu_tot op ge val 70
    namespace import ::cisco::eem::*
    namespace import ::cisco::lib::*
    array set event_details [event_reqinfo]
    action_syslog msg "sub1 is $event_details(sub1)"
    action_syslog msg "High CPU threshold value over 70%"
    puts ok
    I've tryied using the 'period' option for the 'cpu_tot' variable but the TCL script was'nt recognized and couldn't be registered, and I'm using the 'timewin' option here but it seems to be wrong as it says it's the time it has for multiple sub-events to ocurr in order for the script to execute.
    timewin
    (Optional) Time window within which all of the subevents have to occur in order for an event to be generated and is specified in SSSSSSSSSS[.MMM] format. SSSSSSSSSS format must be an integer representing seconds between 0 and 4294967295 inclusive. MMM format must be an integer representing milliseconds between 0 and 999).
    Also, the 'period' option I believe wouldn't have worked because I understand that it referrs to the time period that the script will take to monitor the CPU:
    •1. cpu_tot [op gt|ge|eq|ne|lt|le] [val ?] [period ?]
    op
    (Optional) Comparison operator that is used to compare the collected total system CPU usage sample percentage with the specified percentage value. If true, an event is raised.
    val
    (Optional) Percentage value in which the average CPU usage during the sample period is compared.
    period
    (Optional) Time period for averaging the collection of samples and is specified in SSSSSSSSSS[.MMM] format. SSSSSSSSSS format must be an integer representing seconds between 0 and 4294967295, inclusive. MMM format must be an integer representing milliseconds between 0 and 999. If this argument is not specified, the most recent sample is used.
    As I said, I couldn't try this because the script send an error when I tried to register using the following line:
    ::cisco::eem::event_register_wdsysmon sub1 cpu_tot op ge val 70 period 900
    This is the error message that appeared:
    RP/0/RP0/CPU0:CRS(config)#event manager policy test.tcl username cisco
    RP/0/RP0/CPU0:CRS(config)#commit
    Thu Aug 29 12:35:43.569 CDT
    % Failed to commit one or more configuration items during a pseudo-atomic operation. All changes made have been reverted. Please issue 'show configuration failed' from this session to view the errors
    RP/0/RP0/CPU0:CRS(config)#sh conf fail
    Thu Aug 29 12:35:52.427 CDT
    !! SEMANTIC ERRORS: This configuration was rejected by
    !! the system due to semantic errors. The individual
    !! errors with each failed configuration command can be
    !! found below.
    event manager policy test.tcl username cisco persist-time 3600
    !!% Embedded Event Manager configuration: failed to retrieve intermediate registration result for policy test.tcl
    end
    Anyway, to make this work I understand that I need nested TCL scripts that do the following:
    •1. Monitor the CPU and when it reaches the threshold install another TCL policy that counts down 15 min.
    •2. If the second TCL policy reaches zero then it should generate the SYSLOG message.
    •3. Monitor the CPU while this is running and if it falls below the threshold it should stop the second TCL policy.
    I don't know how I can acomplish this so if anyone can help me with this or show me another way to do this I would really appreciate it.
    Thanks in advance for all your help!

    Neither option is likely to do what you want.  The timewin is for correlating multiple events, and period is the polling interval.  What you want is to create a timer when the CPU is first detected as being high, countdown 15 minutes, then alert you.  You can do this with a nested EEM policy.  For example, you can add the following to your existing policy:
    proc get_pol_dir { fd } {
        set res {}
        set output [cli_exec $fd "show event manager directory user policy"]
        set output [string trim $output]
        regsub -all "\r\n" $output "\n" result
        set lines [split $result "\n"]
        foreach line $lines {
            if { $line == "" } {
                continue
            if { ! [regexp {\s} $line] && ! [regexp {#$} $line] } {
                set res $line
                break
        if { $res == {} } {
            return -code error "The user policy directory has not been configured"
        return $res
    if { [catch {cli_open} result] } {
        error $result $errorInfo
    array set cli $result
    set output [cli_exec $cli(fd) "show event manager policy registered | inc tm_alert_high_cpu.tcl"]
    if { [regexp {tm_alert_high_cpu.tcl} $output] } {
        exit 0
    set poldir [get_pol_dir $cli(fd)]
    set polname "${poldir}/tm_alert_high_cpu.tcl"
    set fd [open $polname "w"]
    puts $fd "::cisco::eem::event_register_timer countdown time 900"
    puts $fd "namespace import ::cisco::eem::*"
    puts $fd "namespace import ::cisco::lib::*"
    puts $fd "action_syslog msg \"CPU has been over 70% for 15 minutes\""
    close $fd
    cli_exec $cli(fd) "config t"
    cli_exec $cli(fd) "event manager policy tm_lert_high_cpu.tcl username eem"
    cli_exec $cli(fd) "commit"
    cli_exec $cli(fd) "end"
    catch {cli_close $cli(fd) $cli(tty_id)}
    Additionally, you'll want another permanently configured policy that checks for a low CPU threshold.  Something like:
    ::cisco::eem::event_register_wdsysmon sub1 cpu_tot op le val 10
    namespace import ::cisco::eem::*
    namespace import ::cisco::lib::*
    if { [catch {cli_open} result] } {
        error $result $errorInfo
    array set cli $result
    cli_exec $cli(fd) "config t"
    cli_exec $cli(fd) "no event manager policy tm_alert_high_cpu.tcl"
    cli_exec $cli(fd) "commit"
    cli_exec $cli(fd) "end"
    catch {cli_close $cli(fd) $cli(tty_id)}

  • How to register EEM Tcl script

    Hello,
    I've a EEM tcl script in bootflash. How to register EEM script. I did the following but it couldn't locate the script in bootflash.
    switch2(config)#event manager policy bootflash:eem-stuckcpu.tcl type user
    EEM configuration: policy file bootflash:eem-stuckcpu.tcl could not be found
    switch2(config)#
    switch2(config)#event manager policy eem-stuckcpu.tcl type user          
    EEM configuration: policy file eem-stuckcpu.tcl could not be found
    Thanks,
    /aa

    You need to configure:
    event manager directory user policy bootflash:
    Then use:
    event manager policy eem-stuckcpu.tcl

  • IP SLA EEM/Tcl Scripts

    Hello Community,
    I have been testing a EEM/Tcl scripts for IP SLA. However, after testing I realised that the script didn't go far enough in identifying the link(s) that has actually gone down.
    I was wondering if someone knows any good EEM/Tcl scripts for IP SLA?
    Cheers
    Carlton

    What about it doesn't work?  Is the policy not triggering?  Is the IPSLA operation not transitioning state?

  • Stopping EEM/TCL script

    How can I stop a pending EEM/TCL script?  I have a Catalyst 4506 version 12.2(40)SG.  The command 'event manager scheduler clear' isn't available.  The output of 'show event manager policy pending' shows:
    No.  Time of Event             Event Type          Name
    1    Wed Mar 3  09:39:31 2010  none                script: test_err.tcl
    2    Wed Mar 3  10:56:42 2010  timer watchdog      script: free_mem.tcl
    3    Wed Mar 3  11:43:19 2010  syslog              applet: Login-Fail
    So the policies coming after the stuck policy won't run.  I've tried to un-register/re-register the policy, but it didn't help.

    If your device does not support "event manager scheduler clear" the only way to terminate a stuck, or long-running EEM policy is to reboot.

  • EEM / Tcl Script Help Please

    Hello Community,
    I have been evaluating a Tcl Script posted here sometime ago, designed to help monitor track interfaces and routes, see attached.
    I believe I have applied the configurations correctly, however when I test the script by shutting down interfaces nothing happens.
    I'm sure its something very simple that I'm missing.
    I wonder if someone could take a look at the configs and let me know what I'm doing wrong. I have also attached a diagram.
    Cheers
    Carlton

    Joseph,
    I did read again and I got it to work :-)
    Cheers
    On a slightly different topic, is it possible to 'track' a static ip address?
    For example, I have the following tracking configured:
    track 1 ip route 0.0.0.0 0.0.0.0 reachability
    track 2 interface FastEthernet0/0 ip routing
    track 3 interface FastEthernet0/1 ip routing
    track 4 ip route 180.80.8.4 255.255.255.255 reachability
    track 5 ip route 170.70.7.4 255.255.255.255 reachability
    R3#show track brie
    Track   Object                         Parameter        Value
    1       ip route  0.0.0.0/0            reachability     Up (static)
    2       interface FastEthernet0/0      ip routing       Up
    3       interface FastEthernet0/1      ip routing       Up
    4       ip route  180.80.8.4/32        reachability     Down (no route)
    5       ip route  170.70.7.4/32        reachability     Down (no route)
    However, you will see that track 4 and 5 are down. This is because, although I can ping 180.80.8.4 and 170.70.7.4 the actual ip addresses don't appear in the routing table:
    Gateway of last resort is 0.0.0.0 to network 0.0.0.0
         170.70.0.0/24 is subnetted, 1 subnets
    C       170.70.7.0 is directly connected, FastEthernet0/0
         10.0.0.0/24 is subnetted, 1 subnets
    C       10.1.1.0 is directly connected, FastEthernet1/0
         180.80.0.0/24 is subnetted, 1 subnets
    C       180.80.8.0 is directly connected, FastEthernet0/1
         150.50.0.0/24 is subnetted, 1 subnets
    C       150.50.5.0 is directly connected, Ethernet2/0
    S*   0.0.0.0/0 is directly connected, FastEthernet1/0
    R3#
    Therefore, is there way of creating a track for /32 ip addresses?
    I hope that makes sense.
    Cheers

  • Router Crashs when using EEM(TCL script)

    I wrote a TCL script to deal with my  dual-link router, but the script running for some time will case the router crash.Could you help me for this?
    Is there some problem with my script ?Thank you!
    Routers :CISCO2821
    IOS vesion:12.4(15)T8

    This looks like CSCsv52332.  This bug is fixed in 12.4(15)T10.

  • EEM/Tcl Script Assistance Part3

    Hello Community,
    Attached is a script originally posted by Joseph.
    When I apply the script I get the following error message:
    R2(config)#event manager policy switchstats.tcl  
    Compile check and registration failed:policy file does not start with event register cmd: file
    Tcl policy execute failed: policy file does not start with event register cmd: file
    Embedded Event Manager configuration: failed to retrieve intermediate registration result for policy switchstats.tcl: Unknown error 0
    I was wondering if someone could take a quick look and let me know what the problem is/
    Cheers

    Hello Community,
    I realised what I was doing wrong, so please ignore the original post.
    However, I get the following error on line 22 when I run the script.
    uk0149_SW2960_100Cheapside#tclsh switchstats.tcl
    extra characters after close-quote
        while executing
    "puts $filename "switch, interface, packets input,bytes,no buffer,broadcasts,multicasts,runts,giants,throttles,input errors,CRC,frame,overrun,ignored,w..."
        (file "switchstats.tcl" line 22)
    Line 22 is:
    puts $filename "switch, interface, packets input,bytes,no buffer,broadcasts,multicasts,runts,giants,throttles,input errors,CRC,frame,overrun,ignored,watchdog,multicast,pause input,input packets with dribble condition detected,packets output,bytes,underruns,output errors,collisions,interface resets,babbles,late collision,deferred,lost carrier,no carrier,PAUSE ,output buffer failures,output buffers swapped out"
    Can you help?
    Cheers

  • SNMP GET operation via EEM Tcl Scripting

    Hi Experts,
    I am writing to you because I was browsing through the archives and saw in one discussion the following command:
    sys_reqinfo_snmp_set oid 1.3.6.1.2.1.2.2.1.7.2.3 int 2 community private ipaddr 1.1.1.1
    I am trying to the get the "get" version of the above command. This means a command that gives you the ability to poll an external/remote SNMP Agent MIB. This is the reason I highlited the "ipaddr" keyword.
    The following command gives you the option to locally poll an object, but it does not give you the option (as indicated in the available literature) to do it on an external device:
    sys_reqinfo_snmp oid ? get_type exact|next
    In applet configuration mode there is a way to achieve that but I have not found any indication on how to do it via Tcl, which supposedly supersedes what you can do via applet configuration.
    Thanks in advance for you knowledge and help.

    Assuming you have a new enough version of EEM, the command is:
    sys_reqinfo_snmp oid OID get_type {exact|next} community COMMUNITY ipaddr IPADDR

  • How to capture switch config from Hyperterminal

    Hi!!! I tried to capture configuration reports of a switch which i did from Hyperterminal.I went to the menu bar which in the top and went to transfer ,on the dropdown it says capture text.I did that but when i opened the captured file i can see the text scattered here and there.Is is possible to see the captured configurations of the switch as how we see organised in the hyperterminal.Can u pls tell me ,do i need to do any configurations in the hyperterminal before i could start capture text.
    thanks and regards

    hi
    try opening the file either with wordpad or notepad.
    sometimes it works fine with wordpad not though with notepad..
    regds

  • TCL Script: Automated extended ping (from traceroute results)

    This is my very first post on this (or any) forum. The reason behind my posting is because I have yet to find any script for automated ping on Cisco TCL Shell.
    Most of the post found on are always with a static ip addresses thus it does not really make the task easier. Most of the TCL ping script usually will look like this:
    foreach address {
    8.8.8.8
    8.8.4.4
    } size {
    1500
    1000
    } { ping $address re 10 si $size
    The script below has been tested on several router series. Seems the script can run smoothly, but some IOS version will not. If such happen, maybe the IOS of the device can be upgraded? Still has to be explored. Anyway, enjoy the script below, with simple comments listed on almost every line.
    Constructive comments are most welcome.
    Note: Once the script has been created, you can run the script by entering the command "tclsh flash:ext_ping.tcl"
    puts [open flash:ext_ping.tcl w+] {
    ###### Writes the whole script into a file ext_ping.tcl into the flash. allows the script to be reused again and again ######
    ###### Just me being vain here. :) ########
    puts "\n"
    puts "\n"
    puts "\n"
    puts "=========================================FYI============================================="
    puts "  This script allow you to perform an extended ping on each and every hop (traceroute)."
    puts "    If there is an error, most probably you have incorrectly entered a wrong value."
    puts "              When error occur, please try running the program again."
    puts "         WARNING: This program will not be invoke if someone else is using it."
    puts "                               Script created by Syam"
    puts "=========================================FYI============================================="
    ###### Displaying a line, while waiting for a user input ######
    puts -nonewline "Test to which IP address? (input IP address): "
    ###### Flushing out any keyboard input before this, allowing the device to capture new keyboard input ######
    flush stdout
    ###### Keyboard input is set into the variable ping_ip ######
    set ping_ip [ gets stdin ]
    ###### IF-loop, checking if IP address was entered correctly. Else, it will prompt user for a new input ######
    if {[regexp { ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]*)} [lindex $ping_ip 0] complete_string incorrect_input] != 1 } {
        puts "\n"
        puts "Your entry has error. Please re-input correctly (Key in the IP address without any mistakes)."
        puts "\n"
        puts -nonewline "Test to which IP address? (input IP address): "
        flush stdout
        set ping_ip [ gets stdin ]
        puts "You entered IP address $ping_ip for testing."
        puts "\n"
    } else {
        puts "You entered IP address $ping_ip for testing."
        puts "\n"
    ###### This loop is not perfect. it sees the IP address as a string, not a set of IP numbers. This causes the command to not run smoothly #####
    ###### Displaying a line, while waiting for a user input ######
    puts -nonewline "State the desired number of repeats for extended ping (Maximum 1000):  "
    ###### Flushing out any keyboard input before this, allowing the device to capture new keyboard input ######
    flush stdout
    ###### User input is set into the variable ping_repeats ######
    set ping_repeats [ gets stdin ]
    ###### IF-loop, checking if the repeat value was entered correctly. Else, it will prompt user for a new input ######
    if {$ping_repeats > 1001} {
        puts "\n"
        puts "Your entry $ping_repeats is too much."
        puts -nonewline "Please input a value of maximum 1000: "
        flush stdout
        set ping_repeats [ gets stdin ]
        puts "You entered $ping_repeats ping repeats."
        puts "\n"
    } else {
        puts "You entered $ping_repeats ping repeats."
    ###### This loop can be further improved. It allows non-integer to be seen as true value ######
    puts "\n"
    ###### Displaying a line, while waiting for a user input ######
    puts -nonewline "State the desired number for the size of ping packet (at least 100):  "
    ###### Flushing out any keyboard input before this, allowing the device to capture new keyboard input ######
    flush stdout
    ###### User input is set into the variable ping_repeats ######
    set ping_packet [ gets stdin ]
    ###### IF-loop, checking if the packet size value was entered correctly. Else, it will prompt user for a new input ######
    if {$ping_packet < 100} {
        puts "\n"
        puts "Your entry $ping_packet for ping packet size is incorrect."
        puts -nonewline "Please input a new value of at least 100: "
        flush stdout
        set ping_packet [ gets stdin ]
        puts "You entered $ping_packet ping packet size."
        puts "\n"
    } else {
        puts "You entered $ping_packet ping packet size."
    puts "\n"
    puts "Traceroute will now commence."
    ###### perform a traceroute base on the user input $ping_ip and set the output of the whole traceroute into variable tracert #######
    set tracert [exec "traceroute $ping_ip numeric probe 1"]
    #### display the $tracert variable ####
    puts $tracert
    puts "\n"
    puts "Performing extended ping to each traceroute hop"
    puts "\n"
    puts "\n"
    puts "========================================================= "
    puts "======================== Results ========================"
    puts "========================================================= "
    ### Because the traceroute output has several lines, this will split each line and correctly number each line beginning with 0. #####
    set hop_result [split $tracert "\n"]
    ##### Create FOR-loop of up to 33 lines. Begin with line 3 and increment with every loop ####
    for {set trace_line  3} {$trace_line < 33} {incr trace_line} {
          #### IF-loop, compare if each line of the traceroute has a HOP number. If no hop number, it will exit loop ####
          if {[regexp { ([0-9]*)} [lindex $hop_result $trace_line] complete_string hop_number] == 1 } {
            #### IF-loop, compare if each HOP number does not have an IP address and exits loop. Else, it will perform a simple ping test based on that IP address ####
                      if {[regexp { ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]*)} [lindex $hop_result $trace_line] complete_string ip_in_hop] != 1 } {
            } else {
                puts "\n"
                puts "Checking if $ip_in_hop can respond to ICMP ping."
                set output [exec "ping $ip_in_hop repeat 4 size 100" ]
                ##### IF-Loop, when the ping command is successful, it will perform extended ping test. Else, it will exit loop and goes to next traceroute output line#####
                if {[regexp {!} $output]} {
                    puts "IP address $ip_in_hop is responding to ICMP ping."
                    ############ proceed with the extended ping test of traceroute hop value ###########
                    set final_output [exec "ping $ip_in_hop repeat $ping_repeats size $ping_packet" ]
                    puts $final_output
                                          } else {
                        puts "\n"
                        puts "IP address $ip_in_hop is not responding to any ping responses"
    ###### close (for loop) #######
    puts $tracert
    puts "========================================================= "
    puts "====================== End Results ======================"
    puts "========================================================= "
    ###### End of File ext_ping.tcl creation ######

    Something like this should work:
    foreach vrf [list "CUST1" "CUST2"] {    set ips [list]    set output [exec "show arp vrf $vrf | inc Internet"]    foreach line [split $output "\n"] {        lappend ips [lindex $line 1]    }    set output [exec "show ip route vrf $vrf | inc /32"]    foreach line [split $output "\n"] {        if { [regexp {([\d\./]+)/32 \[} $line -> ip] } {            lappend ips $ip        }    }    foreach ip $ips {        set output [exec "ping vrf $vrf $ip rep 10"]        if { [regexp {!!!!!!!!!} $output] } {            puts "$ip   ****** PASSED $vrf *******"        } else {            puts "$ip ****** FAILED $vrf ******"        }    }}

  • Using EEM and TCL scripts for voice

    HI all,
    I'd like to use eem to check Sip dial-peer status+interface BRI status, when sip dial-peer has no answer to invite and bri interface is down the LAN interface must be shutted down. Is it possible to avhieve it using eem? I didn't find anything for eem monitoring sip dial-peers...
    thanks
    Massimiliano

    EEM doesn't have any ability to control the data plane currently.  Therefore, there is no direct voice tie-in.  There is a way to do Tcl scripting of some voice operations (e.g. IVR scripts), but those do not relate to EEM.
    That said, if there are some show commands which provide you the data you need, you can create an EEM timer policy (i.e. one that runs periodically), parsers the show command output, and takes further action if the output contains certain patterns.  Depending on the version of IOS, this may require an EEM Tcl script, or you may be able to do it within an EEM applet.
    If you need further assistance, you will need to provide your IOS version, and the exact commands (and output) which would tell you if the SIP peer isn't getting an answer and the BRI interface is truly down (I'm imagining something like "show isdn status" for this one).
    Please support CSC Helps Haiti
    https://supportforums.cisco.com/docs/DOC-8895
    https://supportforums.cisco.com

  • ACE TCL Script Probe for Websphere MQ

    Have anyone written a TCL script to probe MQ from the ACE?  Our app guys are saying that a Layer 4 probe (TCP port check) is generating errors in the QManager logs because there is no data exchange, just TCP connection setup, then tear-down.
    Thought I would check here to see if anyone has written a TCL Script for this before or has any other suggestions.
    Thanks!                  

    Hi,
    What do you need to check exactly on the server?  will be an specific uri?
    Cesar R
    ANS Team

  • Setting the source-interface in a tcl script for email.

    So once again I am trying to figure this out and failing miserably. The only thin I can think of at the moment is that I need to tell it to source from a specific vrf interface. I've tried looking through possible enviornment variables. Hoping I could set it that way but have yet to find one. I have read varios settings for source-interface and attempted them. But fail every time with:
    vpn_failure.tcl: smtp_send_email: error connecting to mail server:
    EEM Version:
    sho event manager version
    Embedded Event Manager Version 4.00
    Component Versions:
    eem: (rel4)1.0.4
    eem-gold: (rel1)1.0.2
    eem-call-home: (rel2)1.0.0
    Below is the stock format for sending the email from the script. If someone could guide me in the correct way to set this up to source the interface that would be awesome.
    # create mail form
      action_syslog msg "Creating mail header for vpn_failure.tcl script..."
      set body [format "Mailservername: %s" "$_email_server"]
      set body [format "%s\nFrom: %s" "$body" "$_email_from"]
      set body [format "%s\nTo: %s" "$body" "$_email_to"]
      set _email_cc ""
      set body [format "%s\nCc: %s" "$body" ""]
      set body [format "%s\nSubject: %s\n" "$body" "VPN Failure Detected: Router $routername Crypto tunnel is DOWN. Peer $remote_peer"]
      set body [format "%s\n%s" "$body" "Report Summary:"]
      set body [format "%s\n%s" "$body" "   - syslog message"]
      set body [format "%s\n%s" "$body" "   - summary of interface(s) in an up/down state"]
      set body [format "%s\n%s" "$body" "   - show ip route $remote_peer"]
      set body [format "%s\n%s" "$body" "   - show crypto isakmp sa"]
      set body [format "%s\n%s" "$body" "   - show crypto session detail"]
      set body [format "%s\n%s" "$body" "   - show crypto engine connection active"]
      set body [format "%s\n%s" "$body" "   - show ip nhrp detail (DMVPN only)"]
      set body [format "%s\n%s" "$body" "   - show log"]
      set body [format "%s\n\n%s" "$body" "---------- syslog message ----------"]
      set body [format "%s\n%s" "$body" "$syslog_msg"]
      set body [format "%s\n\n%s" "$body" "---------- summary of interface(s) in an up/down state ----------"]
      set body [format "%s\n\n%s" "$body" "$show_ip_interface_brief_up_down"]
      set body [format "%s\n\n%s" "$body" "---------- show ip route $remote_peer ----------"]
      set body [format "%s\n\n%s" "$body" "$show_ip_route"]
      set body [format "%s\n\n%s" "$body" "---------- show crypto isakmp sa ----------"]
      set body [format "%s\n\n%s" "$body" "$show_crypto_isakmp_sa"]
      set body [format "%s\n\n%s" "$body" "---------- show crypto session detail ----------"]
      set body [format "%s\n\n%s" "$body" "$show_crypto_session_detail"]
      set body [format "%s\n\n%s" "$body" "---------- show crypto engine connection active ----------"]
      set body [format "%s\n\n%s" "$body" "$show_crypto_engine_connection_active"]
      set body [format "%s\n\n%s" "$body" "---------- show ip nhrp detail (DMVPN only) ----------"]
      set body [format "%s\n\n%s" "$body" "$show_ip_nhrp_detail"]
      set body [format "%s\n\n%s" "$body" "---------- show log ----------"]
      set body [format "%s\n\n%s" "$body" "$show_log"]
      if [catch {smtp_send_email $body} result] {
        action_syslog msg "smtp_send_email: $result"

    I got this far, saw the MAXRUN error, bumped that out and then turned on debugging. I am still not connecting to the mail server. So I don't think I am reaching the mail server yet. I don't think it is using the sourceinterface. In debugging everyting in the script works except for the mail portion.
    Jul 29 16:01:00.334: %HA_EM-6-LOG: vpn_failure.tcl: Creating mail header for vpn_failure.tcl script...
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl: Process Forced Exit- MAXRUN timer expired.
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:     while executing
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl: "action_syslog msg "smtp_send_email: $result""
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:     invoked from within
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl: "$slave eval $Contents"
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:     (procedure "eval_script" line 7)
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:     invoked from within
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl: "eval_script slave $scriptname"
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:     invoked from within
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl: "if {$security_level == 1} {       #untrusted script
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:      interp create -safe slave
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:      interp share {} stdin slave
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:      interp share {} stdout slave
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl: ..."
    Jul 29 16:02:36.464: %HA_EM-6-LOG: vpn_failure.tcl:     (file "tmpsys:/lib/tcl/base.tcl" line 50)
    Jul 29 16:02:36.465: %HA_EM-6-LOG: vpn_failure.tcl: Tcl policy execute failed:
    Jul 29 16:02:36.465: %HA_EM-6-LOG: vpn_failure.tcl: Process Forced Exit- MAXRUN timer expired.
    Debugging On:
    Jul 29 16:28:51.471: [fh_smtp_debug_cmd]
    Jul 29 16:28:51.472: %HA_EM-6-LOG: vpn_failure.tcl : DEBUG(smtp_lib) : smtp_connect : attempt 2
    Jul 29 16:29:24.473: [fh_smtp_debug_cmd]
    Jul 29 16:29:24.473: %HA_EM-6-LOG: vpn_failure.tcl : DEBUG(smtp_lib) : smtp_connect : attempt 3
    Jul 29 16:29:57.475: [fh_smtp_debug_cmd]
    Jul 29 16:29:57.475: %HA_EM-6-LOG: vpn_failure.tcl : DEBUG(smtp_lib) : smtp_connect : attempt 4
    Jul 29 16:30:30.478: [fh_smtp_debug_cmd]
    Jul 29 16:30:30.479: %HA_EM-6-LOG: vpn_failure.tcl : DEBUG(smtp_lib) : smtp_connect : attempt 5
    Jul 29 16:31:00.482: %HA_EM-6-LOG: vpn_failure.tcl: smtp_send_email: error connecting to mail server:
    cannot connect to all the candidate mail servers
    Jul 29 16:31:00.483: %HA_EM-6-LOG: vpn_failure.tcl: vpn_failure.tcl script completed
    event manager environment _email_server 10.79.1.126
    event manager environment _email_from [email protected]
    event manager environment _email_to [email protected]
    interface Port-channel1.101
    description MGMT-1
    encapsulation dot1Q 101
    vrf forwarding MGMT-1
    ip address 10.79.1.252 255.255.255.0
    ip nat inside
    ip virtual-reassembly
    redundancy rii 101
    redundancy group 2 ip 10.79.1.254 exclusive decrement 10
    end
    #----------------------- send mail ----------------------
    # create mail form
      action_syslog msg "Creating mail header for vpn_failure.tcl script..."
      set body [format "Mailservername: %s" "$_email_server"]
      set body [format "%s\nFrom: %s" "$body" "$_email_from"]
      set body [format "%s\nTo: %s" "$body" "$_email_to"]
      set _email_cc ""
      set body [format "%s\nCc: %s" "$body" "[email protected]"]
      set body [format "%s\nSourceintf: %s" "$body" "port-channel1.101"]
      set body [format "%s\nSubject: %s\n" "$body" "VPN Failure Detected: Router $routername Crypto tunnel is DOWN. Peer $remote_peer"]
      set body [format "%s\n%s" "$body" "Report Summary:"]
      set body [format "%s\n%s" "$body" "   - syslog message"]
      set body [format "%s\n%s" "$body" "   - summary of interface(s) in an up/down state"]
      set body [format "%s\n%s" "$body" "   - show ip route $remote_peer"]
      set body [format "%s\n%s" "$body" "   - show crypto isakmp sa"]
      set body [format "%s\n%s" "$body" "   - show crypto session detail"]
      set body [format "%s\n%s" "$body" "   - show crypto engine connection active"]
      set body [format "%s\n%s" "$body" "   - show ip nhrp detail (DMVPN only)"]
      set body [format "%s\n%s" "$body" "   - show log"]
      set body [format "%s\n\n%s" "$body" "---------- syslog message ----------"]
      set body [format "%s\n%s" "$body" "$syslog_msg"]
      set body [format "%s\n\n%s" "$body" "---------- summary of interface(s) in an up/down state ----------"]
      set body [format "%s\n\n%s" "$body" "$show_ip_interface_brief_up_down"]
      set body [format "%s\n\n%s" "$body" "---------- show ip route $remote_peer ----------"]
      set body [format "%s\n\n%s" "$body" "$show_ip_route"]
      set body [format "%s\n\n%s" "$body" "---------- show crypto isakmp sa ----------"]
      set body [format "%s\n\n%s" "$body" "$show_crypto_isakmp_sa"]
      set body [format "%s\n\n%s" "$body" "---------- show crypto session detail ----------"]
      set body [format "%s\n\n%s" "$body" "$show_crypto_session_detail"]
      set body [format "%s\n\n%s" "$body" "---------- show crypto engine connection active ----------"]
      set body [format "%s\n\n%s" "$body" "$show_crypto_engine_connection_active"]
      set body [format "%s\n\n%s" "$body" "---------- show ip nhrp detail (DMVPN only) ----------"]
      set body [format "%s\n\n%s" "$body" "$show_ip_nhrp_detail"]
      set body [format "%s\n\n%s" "$body" "---------- show log ----------"]
      set body [format "%s\n\n%s" "$body" "$show_log"]
      if [catch {smtp_send_email $body} result] {
        action_syslog msg "smtp_send_email: $result"
      action_syslog msg "vpn_failure.tcl script completed"
    #------------------ end of send mail --------------------

  • Help with EEM TCL / CLI scripting for re-direction/wccp counters

    Being new with EEM scripting I wanted to see if I was on the right track and get some help to finish my idea.
    Our problem I am trying to fix is our remote sites utilize pairs of Cat3650's for some routing and WCCP redirection.  We are encountering ACL denial issues causing slow down and access issues.  The fix for the issue we remove the WCCP service groups to break peering with our wan optimizers and re-insert the configuration thus re-establishing peering and restoring service.
    My idea is to use a TCL scipt on a watchdog timer to parse the "sh ip wccp | inc denied (or unassign)" output for denial and unassignable error counters.  If a counter is found I wanted to create a syslog message that would then kick off a simple EEM CLI script to remove the service groups, wait 10 seconds, then re-add the service groups.  Please point me in the right direction if I am off track as I am not sure if I can use the EEM CLI for all this or since I want to retreive specific info from the sh ip wccp output if I do need to utilize TCL.  I am also unsure if the "total denied" ascii string pulled via the "sh ip wccp | inc denied" will cause issues when attempting to just pull the counter information.
    sh ip wccp | inc Denied Red
            Total Packets Denied Redirect:       0
            Total Packets Denied Redirect:       0
    Script thus far :
    TCL
    if [catch {context_retrieve "EEM_WCCP_ERROR_COUNTER" "count"} result] {
    set wccpcounter 0
    } else {
    set wccpcounter $result
    } if [catch {cli_open} result] {
    error $result
    } else {
    array set cli $result
    } if [catch {cli_exec $cli(fd) "show ip wccp | incl Denied"} result] {
    error $result
    } else {
    set cmd_output $result
    set count ""
    catch [regexp {receive ([0-9]+),} $cmd_output} ignore count]
    set count
    set diff [expr $count - $wccpcounter]
    if {$diff != 0} {
    action_syslog priority emergencies msg "WCCP counters showing incremental Denied packet counts"
    if [catch {cli_close $cli(fd) $cli(tty_id)} result] {
    error $result
    context_save EEM_WCCP_ERROR_COUNTER count
    CLI
    event manager applet WCCP_COUNTER_WATCH
    event syslog priority emergencies pattern "WCCP counters showing incremental Denied packet counts"
    action 001 cli command "enable"
    action 002 cli command "config t"
    action 003 cli command "no ip wccp 61"
    action 004 cli command "no ip wccp 62"
    action 005 wait 10
    action 006 cli command "ip wccp 61"
    action 007 cli command "ip wccp 62"
    action 008 wait 15
    action 009 cli command "clear ip wccp"
    action 010 cli command "end"
    Thanks for all the help

    This won't work as EEM cannot intercept its own syslog messages.  However, I'm not sure why you need this form of IPC anyway.  Why not just make the Tcl script perform the needed CLI commands?
    And, yes, you could use all applets here.  But since you've written the hard stuff in Tcl already, it might be best just to add the missing calls to reconfigure WCCP to that script.

Maybe you are looking for

  • Install Windows 8.1 on rMBP

    Hi All, Probably a simple question, however I seem to be struggling with this! I'm trying to install Windows 8.1 on my Retina Macbook Pro, however I'm unsure if i need to buy Windows 7 first? Or can I just get a Windows 8.1 student disk or what? Im c

  • SQL Server Reporting services. failed to establish connection with project server. verify the url is correct.

    Dear All, I'm working on reporting of Project Server 2010, while configuring SQL SERVER REPORTING SERVICES faced issue after two complete days of troubleshooting along with this gone through plenty of forums, unable to figure out any solution. So fin

  • Problem with BranchGroup

    Hi all, When the following class is called, Java returns an exception. I d'ont understand what the problem is. If anybody has an idea, it''ll be great. The code is : import javax.media.j3d.*; import com.sun.j3d.utils.picking.PickTool; import com.sun.

  • On the app store i clicked on essentials but i cant exit

    does anybody know how to exit because its driving me crazy and i cant redeem stuff on my ipod

  • Import Export Healthcare Endpoints

    Hi, I am currently exploring the healthcare pack for the Oracle SOA Suite Integration. While doing several POC's I often come across the need to somehow import/export the created healthcare endpoints onto some other SOA server, but everytime I have t