Showing results for 
Search instead for 
Did you mean: 

EEM script to monitor and shut / no shut fxo port


Development team,

I've run into a situation with a large hospital UC deployment that I'm looking to an EEM or TCL solution for.  I have a Valcom paging integration to a pair of FXO ports on two 3945 ISR G2s.  Ocasionally, and without any forensic details pointing to why, the ports will lock up and hang in an off hook state (one or the other, but eventually both).  This presents users with a fast busy when attempting to page.

Can anyone suggest a script that could monitor a FXO port for off hook state, initialize a countdown timer of two minutes, and then issue the shut / no shut sequence if the port is still off hook?

I've gotten a handle on the EEM components of the port reset, but not how I'd define the logic for the port off hook detection or check of the port following a timer expiry.

Thanks in advance,


9 Replies 9

Joe Clarke
Cisco Employee
Cisco Employee

How would you verify the FXO off hook status manually?  What version of code are the 3945s running?


I was expecting that I'd parse the syslog output (if possible) for a string such as "htsp_process_event: [0/3/0, FXOLS_OFFHOOK". I'm assuming that I'd have to be debugging vpm signaling in order for this to work, so this is a gap.  Alternately, I'd assume that an EEM cli call of "show voice port summary | i 0/3/0" could be parsed for "off-hook".  Is there an EEM event associated with voice port status and signaling events?

The 3945s are running 15.2(2)T1.



Either the debugging method or the show command will work.  No, there is no voice-specific event detector.  The show command would be preferable since you don't have to run any debugs.  You can do this with an applet in your version of code. If you configure two "none" applets to do the port reset (called reset-port-0/3/0 and reset-port-0/3/1, you could do):

event manager environment fxo_ports 0/3/0 0/3/1


event manager applet check-off-hook

event timer watchdog time 60

action 001 cli command "enable"

action 002 foreach port $fxo_ports

action 002 cli command "show voice port summary | inc $port"

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 reset-port-$port"

action 007 cli command "event timer countdown time 120"

action 008 cli command "event manager applet check-off-hook"

action 009 cli command "event none"

action 010 cli command "end"

action 011 end

action 012 end

In your reset-port-PORT applets, make sure you have this at the end:

action 099 cli command "config t"

action 100 cli command "event manager applet check-off-hook"

action 101 cli command "event timer watchdog time 60"

action 102 cli command "event manager applet reset-port-PORT"

action 103 cli command "event none"

action 104 cli command "end"

Very much appreciated, Joseph.  I will look into implementing this, and report back on our testing.

Thanks again.


Hi Cody,
It would be great if you could post your end result after your finished your restart script(s). I'm also interested in doing this, but really lack the know how about EEM scripts.


Sent from Cisco Technical Support iPhone App

Response Signature

Hello Joseph,

This can be done with EEM?




I know this is a old post. I was able to use the solution below, but I am having one problem.

Using the below config I am able to receive a email anytime my voice port is in any other state than ON HOOK. The problem I have is the script runs every 30 seconds and I receive an email every 30 seconds the line is in any other state than "ON-HOOK". 

Is there a way to have only one email generated ONLY when the state changes from the previous state? 

example : the line is on-hook, changes to off-hook or park or whatever- a email would be generated.  ( only One email). not one every 30 seconds...

               The line goes from Off-Hook back to IDLE.  - A email would be generated to advise the line has been restored to a IDLE state. 


scheduler allocate 20000 1000
event manager environment _email_from
event manager environment _email_to email
event manager environment _email_server
event manager applet check_1/0/0_if_NOT_ONHOOK
 event timer watchdog time 30
 action 001 cli command "enable"
 action 002 cli command "show voice port summ | include 1/0/0"
 action 003 foreach line "$_cli_result" "\n"
 action 004  regexp "on-hook" "$line"
 action 005  if $_regexp_result eq "1"
 action 006   exit 0
 action 007  end
 action 008 end
 action 009 syslog msg "PORT_1_is_in_any_other_state_then_on-HooK!"
 action 1.0 mail server "$_email_server" to "$_email_to" from "$_email_from" subject "$_event_pub_time:Test EEM port 1/0/0 is SHORTED ie IN ALARM" body "TEST Body"


Any ideas?



Can you start a new thread for your question?  Thanks.

Thanks, I did. 

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: