cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5796
Views
5
Helpful
7
Replies

EEM help - cli_result

Andrew Grech
Level 1
Level 1

Hi looking for some help with my EEM script to check sip-ua register status

See below

event manager applet checksipregister

description applet to do a show run command to check SIP registration. If not registered, a critical syslog will be created. Runs every 300 seconds.

event timer watchdog time 300

action 1 cli command "show sip-ua register status | include no"

action 2 string length "$_cli_result"

action 3 if $_string_result gt 10

action 4 syslog priority critical msg "SIP status is not registered. Please check service."

action 5 end

Output of commands

When trunk is down

ef-dc-vgw02-r2c6#show sip-ua register status | i no

99051000229971                   -1         86           no 

When trunk is up

(no output)

Without pipe

ef-dc-vgw02-r2c6#show sip-ua register status

Line                             peer       expires(sec) registered P-Associ-URI

================================ ========== ============ ========== ============

99051000229971                   -1         239          yes


unfortuently the script keeps sending triggering when the trunk is up.

2 Accepted Solutions

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

You likely want to do this:

event manager applet checksipregister

event timer watchdog time 300

action 1.0 cli command "enable"

action 2.0 cli command "show sip-ua register status | include no"

action 3.0 regexp "[0-9]+.*no" $_cli_result

action 4.0 if $_regexp_result eq 1

action 5.0  syslog priority critical msg "SIP status is not registered.  Please check service."

action 6.0 end

View solution in original post

You need to add:

event manager session cli username USER

Where USER is a user authorized to run all of the CLI commands in this applet.

View solution in original post

7 Replies 7

Joe Clarke
Cisco Employee
Cisco Employee

You likely want to do this:

event manager applet checksipregister

event timer watchdog time 300

action 1.0 cli command "enable"

action 2.0 cli command "show sip-ua register status | include no"

action 3.0 regexp "[0-9]+.*no" $_cli_result

action 4.0 if $_regexp_result eq 1

action 5.0  syslog priority critical msg "SIP status is not registered.  Please check service."

action 6.0 end

Thanks Joseph,

I gave that one a try however it didn't trigger, is it becouse of the - in the output?

Thanks for your help.

No.  It works for me in local testing.  Are you sure you copied the regular expression correctly?  What does "debug event manager action cli" report when the applet runs?

Thanks for the reply, see results from the debug.

ef-dc-vgw02-r2c6#

*Mar  3 15:57:21: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : CTL : cli_open called.

*Mar  3 15:57:21: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : OUT : ef-dc-vgw02-r2c6#

*Mar  3 15:57:21: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : IN  : ef-dc-vgw02-r2c6#enable

*Mar  3 15:57:21: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : OUT : % Authorization failed.

*Mar  3 15:57:21: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : OUT :

*Mar  3 15:57:21: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : OUT : ef-dc-vgw02-r2c6#

*Mar  3 15:57:21: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : IN  : ef-dc-vgw02-r2c6#show sip-ua register status | include no

*Mar  3 15:57:22: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : OUT : ef-dc-vgw02-r2c6#

*Mar  3 15:57:22: %HA_EM-6-LOG: checksipregister : DEBUG(cli_lib) : : CTL : cli_close called.

*Mar  3 15:57:22: tty is now going through its death sequence

Perfomed by me

ef-dc-vgw02-r2c6#show sip-ua register status | include no

99051000229971                   -1         83           no        

ef-dc-vgw02-r2c6#

You need to add:

event manager session cli username USER

Where USER is a user authorized to run all of the CLI commands in this applet.

Thanks heaps Joseph! All setup

and how change above script ,to send the router to wr and reload if 1 SIP account is missing in "sh sip-ua register status"

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: