cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2560
Views
0
Helpful
3
Replies

Automated Voice Port Reset

tkrautkramer
Level 1
Level 1

EEM and TCL scripting are completely new concepts for me. I am using a Cisco 2951 ISR running IOS version Version 15.0(1r)M16 and I am wondering if it is possible to create a TCL script that can monitor the operational state of an FXO port and perform a reset (shut ,no shut) on that port if the operational state is up for more than 1 minute? The reasoning behind this is that I have a paging system on one of my FXO ports (voice-port 0/2/3) and some end users continually put the call on hold instead of hanging up when making a page. This results in the paging system becoming unusable until one of our staff log into the router and reset the port manually. I would like to automate the process if possible. I cannot think of any other way of doing this but I would be open to suggestions.

2 Accepted Solutions

Accepted Solutions

tkrautkramer
Level 1
Level 1

I finally got a bit of time to tinker and I figured it out...

Here are my final working applets if anyone is interested:

 

event manager applet PAGING_MONITOR
description MONITOR PAGING PORT FOR OFF-HOOK STATUS
event timer watchdog time 120 maxrun 65
action 1.0 cli command "enable"
action 1.2 cli command "show voice port summary | include 0/2/3"
action 1.3 regexp "off-hook" "$_cli_result"
action 1.4 if $_regexp_result eq "1"
action 1.5 cli command "event timer countdown time 60"
action 1.6 cli command "event manager run PAGING_RESET"
action 1.8 end
event manager applet PAGING_RESET
description AUTOMATED PAGING PORT RESET FOR PAGING_MONITOR
event none
action 1.0 cli command "enable"
action 1.1 cli command "config t"
action 1.2 cli command "voice-port 0/2/3"
action 1.3 cli command "shut"
action 1.4 cli command "no shut"
action 1.5 cli command "exit"
action 1.6 syslog priority notifications msg "Paging has been reset by EEM" facility "EEM-FAC"

View solution in original post

Same goal, different method. This one checks once a second it the port is still off-hook after 50 seconds it resets the port. Seems to work a little better...

 

event manager applet PAGING_MONITOR
event timer watchdog time 60 maxrun 60
 action 1.1 set i 0
 action 1.2 cli command "enable"
 action 1.3 while $i lt 50
 action 1.4 cli command "show voice port summary | include 0/2/3"
 action 1.5 regexp "off-hook" "$_cli_result"
 action 1.6 if $_regexp_result eq 1
 action 1.7 increment i
 action 1.8 wait 1
 action 2.0 elseif $_regexp_result eq 0
 action 2.1 exit
 action 2.2 end
 action 2.3 end
 action 3.1 cli command "config t"
 action 3.2 cli command "voice-port 0/2/3"
 action 3.3 cli command "shut"
 action 3.4 cli command "no shut"
 action 3.5 cli command "exit"
 action 3.6 syslog priority notifications msg "Paging port was reset by EEM" facility "EEM-FAC"
 action 3.7 exit

 

Same thing in TCL...

 

::cisco::eem::event_register_timer watchdog time 60 maxrun 60


namespace import ::cisco::eem::*
namespace import ::cisco::lib::*

array set arr_einfo [event_reqinfo]


if [catch {cli_open} result] {
   error $result $errorInfo
} else {
   array set cli1 $result
}

set i 0
if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
   error $_cli_result $errorInfo
}

while {$i < 50} {
       if [catch {cli_exec $cli1(fd) "show voice port summary | include 0/2/3"} _cli_result] {
          error $_cli_result $errorInfo
       }

       set _regexp_result [regexp {off-hook} $_cli_result]
       if {$_regexp_result == 1} {
          incr i
          after 1000
      } elseif {$_regexp_result == 0} {

         catch {cli_close $cli1(fd) $cli1(tty_id)} result
         exit
      }
}
if [catch {cli_exec $cli1(fd) "config t"} _cli_result] {
   error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "voice-port 0/2/3"} _cli_result] {
   error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "shut"} _cli_result] {
   error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "no shut"} _cli_result] {
error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "exit"} _cli_result] {
   error $_cli_result $errorInfo
}

action_syslog priority notice msg "Paging port was reset by EEM"

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

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

View solution in original post

3 Replies 3

tkrautkramer
Level 1
Level 1

While searching on here for answers I stumbled across a similar request that was answered by Joe Clarke, but was never confirmed as a working solution by the user who asked for help. This is the EEM Script that I concluded I need based on Joe's reply to that thread:

 

event manager applet PAGING_MONITOR
event timer watchdog time 60
action 001 cli command "enable"
action 002 cli command "show voice port summary | include 0/2/3"
action 003 regexp "off-hook" $_cli_result
action 004 if $_regexp_result eq 1
action 005 cli command "config t"
action 006 cli command "event manager applet PAGING_RESET"
action 007 cli command "event timer countdown time 120"
action 008 cli command "event manager applet PAGING_MONITOR"
action 009 cli command "event none"
action 010 cli command "end"
action 011 end
action 012 end

 

event manager applet PAGING_RESET
action 001 cli command "config t"
action 002 cli command "voice-port 0/2/3"
action 003 cli command "shut"
action 004 cli command "no shut"
action 005 cli command "exit"
action 006 syslog msg "Voice-Port 0/2/3 reset via EEM"
action 007 cli command "event manager applet PAGING_MONITOR"
action 008 cli command "event timer watchdog time 60"
action 009 cli command "event manager applet PAGING_RESET"
action 010 cli command "event none"
action 011 cli command "end"

 

If I understand correctly, this should cause the FXO port to be reset if it is determined to be off-hook for two minutes. I don't quite understand why you would execute an event manager applet from within that applet itself. For example - PAGING_MONITOR action 8. Can anyone confirm that this is correct?

tkrautkramer
Level 1
Level 1

I finally got a bit of time to tinker and I figured it out...

Here are my final working applets if anyone is interested:

 

event manager applet PAGING_MONITOR
description MONITOR PAGING PORT FOR OFF-HOOK STATUS
event timer watchdog time 120 maxrun 65
action 1.0 cli command "enable"
action 1.2 cli command "show voice port summary | include 0/2/3"
action 1.3 regexp "off-hook" "$_cli_result"
action 1.4 if $_regexp_result eq "1"
action 1.5 cli command "event timer countdown time 60"
action 1.6 cli command "event manager run PAGING_RESET"
action 1.8 end
event manager applet PAGING_RESET
description AUTOMATED PAGING PORT RESET FOR PAGING_MONITOR
event none
action 1.0 cli command "enable"
action 1.1 cli command "config t"
action 1.2 cli command "voice-port 0/2/3"
action 1.3 cli command "shut"
action 1.4 cli command "no shut"
action 1.5 cli command "exit"
action 1.6 syslog priority notifications msg "Paging has been reset by EEM" facility "EEM-FAC"

Same goal, different method. This one checks once a second it the port is still off-hook after 50 seconds it resets the port. Seems to work a little better...

 

event manager applet PAGING_MONITOR
event timer watchdog time 60 maxrun 60
 action 1.1 set i 0
 action 1.2 cli command "enable"
 action 1.3 while $i lt 50
 action 1.4 cli command "show voice port summary | include 0/2/3"
 action 1.5 regexp "off-hook" "$_cli_result"
 action 1.6 if $_regexp_result eq 1
 action 1.7 increment i
 action 1.8 wait 1
 action 2.0 elseif $_regexp_result eq 0
 action 2.1 exit
 action 2.2 end
 action 2.3 end
 action 3.1 cli command "config t"
 action 3.2 cli command "voice-port 0/2/3"
 action 3.3 cli command "shut"
 action 3.4 cli command "no shut"
 action 3.5 cli command "exit"
 action 3.6 syslog priority notifications msg "Paging port was reset by EEM" facility "EEM-FAC"
 action 3.7 exit

 

Same thing in TCL...

 

::cisco::eem::event_register_timer watchdog time 60 maxrun 60


namespace import ::cisco::eem::*
namespace import ::cisco::lib::*

array set arr_einfo [event_reqinfo]


if [catch {cli_open} result] {
   error $result $errorInfo
} else {
   array set cli1 $result
}

set i 0
if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
   error $_cli_result $errorInfo
}

while {$i < 50} {
       if [catch {cli_exec $cli1(fd) "show voice port summary | include 0/2/3"} _cli_result] {
          error $_cli_result $errorInfo
       }

       set _regexp_result [regexp {off-hook} $_cli_result]
       if {$_regexp_result == 1} {
          incr i
          after 1000
      } elseif {$_regexp_result == 0} {

         catch {cli_close $cli1(fd) $cli1(tty_id)} result
         exit
      }
}
if [catch {cli_exec $cli1(fd) "config t"} _cli_result] {
   error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "voice-port 0/2/3"} _cli_result] {
   error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "shut"} _cli_result] {
   error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "no shut"} _cli_result] {
error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "exit"} _cli_result] {
   error $_cli_result $errorInfo
}

action_syslog priority notice msg "Paging port was reset by EEM"

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

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

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: