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