cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1257
Views
0
Helpful
1
Replies

Best Method: Status Command

Bryan Allebone
Level 1
Level 1

I might have the wrong methodology...just seeking some unvarnished idealogy. I own the Cisco Press TCL Scripting book, but things have changed some since printing.

 

First Part: We have one Router that several mobile routers at various branches dial-in to.  Very sporadic, long story, but it works well for what we're doing. Problem is, the IP addresses mean nothing, they have site names like San Francisco, Tokyo, etc. and the IP stays the same.  Is there a way to have scripting take advantage of a Hosts file of sorts that can associate say a "Show Users"  and/or "Show DMVPN" Command and just have it disply the name instead of IP.

 

Second Part: Is it possible to have this EEM/TCL/ETC continuosly run? It doesn't need to update continuously, but maybe on trigger of a change or periodically like every 30 seconds...nothing crazy. It'd be nice to have untrained people be able to just stroll past and see whats up at the time.

 

Thank You,

 

Bryan

1 Reply 1

Dan Frey
Cisco Employee
Cisco Employee

TCL string map is one option to replace the IP address with a name in an EEM policy.

Place this in the router config:   event manager environment timer * * * * *

 

#####Start file#######

::cisco::eem::event_register_timer cron name byte_counter.tcl cron_entry "$timer" maxrun 55

namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set _sinfo [sys_reqinfo_routername]
set host $_sinfo(routername)

if {![info exists timer]} {
    set result \
      "Policy cannot be run: variable timer has not been set"
    error $result $errorInfo
}

# Open the CLI
if [catch {cli_open} result] {
   error $result $errorInfo
} else {
    array set cli1 $result
}

# Go into enable mode
if [catch {cli_exec $cli1(fd) "enable"} result] {
    error $result $errorInfo
}

if [catch {cli_exec $cli1(fd) "show users" } users ] {
        error $users $errorInfo
}

set result [ string map {192.168.0.125 Hong-Kong \
192.168.0.19 Washington-DC} $users]

puts "$result"


######end file#####

 

Once the policy is registered it will run every minute and produce this output.

%HA_EM-6-LOG: status_update.tcl:     Line       User       Host(s)              Idle       Location

%HA_EM-6-LOG: status_update.tcl:    3 tty 3                Async interface      00:00:59   
%HA_EM-6-LOG: status_update.tcl:   10 vty 0     cpe        idle                 00:00:08 Hong-Kong
%HA_EM-6-LOG: status_update.tcl:   11 vty 1     cpe        idle                 00:00:04 Washington-DC
%HA_EM-6-LOG: status_update.tcl: * 12 vty 2                idle                 00:00:00 EEM:status_update.tcl