07-10-2018 12:49 PM - edited 03-01-2019 06:40 PM
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
Solved! Go to Solution.
07-11-2018 11:13 AM
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.
07-10-2018 06:53 PM
What does the output of "sh dial-peer voice | in busyout" look like?
07-11-2018 06:22 AM
r01micMAIvg#sh dial-p v su | i busyout
3333 voip up up 654789 0 syst ipv4:10.10.10.10 busyout
r01micMAIvg#
07-11-2018 10:02 AM
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
07-11-2018 10:28 AM
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?
07-11-2018 10:30 AM
Enable "debug event manager action cli" and post the output after running the applet.
07-11-2018 10:33 AM
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#
07-11-2018 10:38 AM
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.
07-11-2018 10:50 AM
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
07-11-2018 10:59 AM
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.
07-11-2018 11:03 AM
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#
07-11-2018 11:13 AM
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.
07-11-2018 11:29 AM
that fixed it!
thank you much.
07-11-2018 06:27 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide