cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2521
Views
5
Helpful
13
Replies

EEM Scripting

mgordon26
Level 1
Level 1

Trying to write an EEM script to daily report if any dial-peers are in a busyout state.  Nothing seems to work for me.  2921 router running IOS c2900-universalk9-mz.SPA.155-3.M4a.bin

I have built a dial-peer for testing which is always in a busyout state.

 

This is what i have so far.

 

event manager session cli username "xxxxxx"
event manager applet CheckSIP-busyout
event timer cron cron-entry "30 7 * * *"
action 1.1 cli command "enable"
action 2.0 cli command "sh dial-peer voice | in busyout"
action 2.1 regexp "busyout.*=([a-z]+)," "$_cli_result" result result1
action 3.0 if $result1 eq "busyout"
action 3.2 mail server "172.31.xxxxx" to "cn-phones@xxxx" from "r01MC@xxxx" subject " Michigan City gateway is not responding " body "$_cli_result"
action 3.4 end

1 Accepted Solution

Accepted Solutions

Ah!  This helps.  There are more spaces.  Try this:

regexp "ipv4:[0-9]+ +busyout" "$_cli_result"

And your end needs to go at the end to make sure all of the conditional statements are only executed when the regexp matches.

View solution in original post

13 Replies 13

Joe Clarke
Cisco Employee
Cisco Employee

What does the output of "sh dial-peer voice | in busyout" look like?

r01micMAIvg#sh dial-p v su | i busyout
3333 voip up up 654789 0 syst ipv4:10.10.10.10 busyout
r01micMAIvg#

What you want is:

regexp "ipv4:[0-9.]+ busyout" "$_cli_result"

if $_regexp_result eq 1

 mail server "172.31.xxxxx" to "cn-phones@xxxx" from "r01MC@xxxx" subject " Michigan City gateway is not responding " body "$_cli_result"

end

i updated the script as suggested but it is still not working.

 

event manager applet CheckSIP-Trunk
event timer cron cron-entry "* 13 * * *"
action 1.1 cli command "enable"
action 2.0 cli command "sh dial-peer voice su | in busyout"
action 2.1 regexp "ipv4:[0-9.]+ busyout" "$_cli_result"
action 3.0 if $_regexp_result eq "1"
action 3.2 mail server "172.31.xxx" to "cn-phones@ixxx" from "r01MC@ixxx" subject " Michigan City gateway busyout dial-peer " body "$_cli_result"
action 3.4 end

 

Script is running but no message sent.

 

r01micMAIvg#sh even manage his ev
No. Job Id Proc Status Time of Event Event Type Name
8 131 Actv success Wed Jul11 13:18:00 2018 timer cron applet: CheckSIP-Trunk
9 132 Actv success Wed Jul11 13:19:00 2018 timer cron applet: CheckSIP-Trunk
10 133 Actv success Wed Jul11 13:20:00 2018 timer cron applet: CheckSIP-Trunk

 

dial-peer is still in busyout state

 

r01micMAIvg#sh dial-p v su | i busyout
3333 voip up up 654789 0 syst ipv4:10.10.10.10 busyout
r01micMAIvg#

 

what now?

 

 

Enable "debug event manager action cli" and post the output after running the applet.

Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : CTL : cli_open called.


Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : OUT : *****************************************************************************
Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : OUT : r01micMAIvg>
Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : IN : r01micMAIvg>enable
Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : OUT : r01micMAIvg#
Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : IN : r01micMAIvg#sh dial-peer voice su | in busyout
Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : OUT : 3333 voip up up 654789 0 syst ipv4:10.10.10.10 busyout
Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : OUT : r01micMAIvg#
Jul 11 13:31:00: %HA_EM-6-LOG: CheckSIP-Trunk : DEBUG(cli_lib) : : CTL : cli_close called.
Jul 11 13:31:00:
Jul 11 13:31:00: tty is now going through its death sequence
r01micMAIvg#

It could be your SMTP server is rejecting the email.  you might try adding :

 

syslog msg "Found busyout!!!"

 

Just to see if it's matching.  My local tests show there is no logic issue.

i added it and nothing shows in log

i add it following the send message line and still nothing shows

 

action 2.0 cli command "sh dial-peer voice su | in busyout"
action 2.1 regexp "ipv4:[0-9.]+ busyout" "$_cli_result"
action 3.0 if $_regexp_result eq "1"
action 3.1 syslog msg "Found busyout #1"
action 3.2 mail server "172.31.xxx" to "cn-phones@xx from "r01MC@xx" subject " Michigan City gateway busyout dial-peer " body "$_cli_result"
action 3.3 syslog msg "Found busyout #2"
action 3.4 end

i moved the action 3.15 end statement to follow the first syslog msg "Found busyout

 

now i am getting an email message and the second syslog msg "Found busyout message is writing to the log.

 

action 2.0 cli command "sh dial-peer voice su | in busyout"
action 2.1 regexp "ipv4:[0-9.]+ busyout" "$_cli_result"
action 3.0 if $_regexp_result eq "1"
action 3.1 syslog msg "Found busyout #1"
action 3.15 end
action 3.2 mail server "172.31.235.70" to "cn-phones@ivytech.edu" from "r01MC@ivytech.edu" subject " Michigan City gateway busyout dial-peer " body "$_cli_result"
action 3.3 syslog msg "Found busyout #2"
!

i deleted the busyout dial-peer so now there are no busyout dial-peers yet the message is still being sent so it appear the IF test is not working.

 

still sending the message but the body only has

r01micMAIvg#

 

where before i deleted the busyout dial-peer the body contained

3333   voip  up   up             654789             0  syst ipv4:10.10.10.10              busyout  

r01micMAIvg#

Ah!  This helps.  There are more spaces.  Try this:

regexp "ipv4:[0-9]+ +busyout" "$_cli_result"

And your end needs to go at the end to make sure all of the conditional statements are only executed when the regexp matches.

that fixed it!

thank you much.

i see i had a typo, missing the summary part of the command. i correct that and it still fails.

Review Cisco Networking for a $25 gift card