EEM Script to supervise FXO analog lines.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2013 11:16 AM
Software Version: 15.0(1r)M6
Problem Details: I need some help developing a EEM script to supervise an FXO line. The command I'm using to see whether or not an FXO phone lines are operational is
test voice port 0/0/0 si-reg-read 29 1
test voice port 0/0/1 si-reg-read 29 1
I would like to run these command everyday and if the output is ever
Register 29 = 0x00
I would like it to email me.
------------------------------------
We need to know if the analog lines in the back of the router are active and have dialtone each day. We had an incident in the past where the site tried to use 911, and it failed because the PSTN line was disconnected at the service provider but we didn't know. I would like to use the
test voice port 0/0/0 si-reg-read 29 1
command to verify line voltage/dialtone on the line. Furthermore I would like to script this so that if the output of that test command = 0x00 ( no voltage) will send an email to us letting us know something has happened to that analog line. Here is an example of how far I was able to get with it. (this code doesn't work right , but you should get the gist.)
event manager environment _mail_smtp *****.****.org
event manager environment _mail_domain ******.org
event manager environment _mail_rcpt1 *****@******.org
event manager environment _mail_rcpt2 ******@*****.org
event manager applet test
event timer watchdog time 86400
action 1.0 cli command "enable"
action 2.0 cli command "test voice port 0/0/0 si-reg-read 29 1"
action 3.0 cli command "test voice port 0/0/1 si-reg-read 29 1"
action 4.0 regexp " 0x00 " $_cli_result result
action 5.0 if $_regexp_result eq 1
action 6.0 info type routername
action 7 .0 mail server "$_mail_smtp" to "$_mail_rcpt1" from "$_info_routername@$_mail_domain" subject "Analog line down on $_info_routername" body "$_cli_result"
action 8.0 mail server "$_mail_smtp" to "$_mail_rcpt2" from "$_info_routername@$_mail_domain" subject "Analog line down on $_info_routername" body "$_cli_result"
action 9.0 else
action 11.0 end
Any help you guys can give is greatly aprpeciated. TAC said they can't help me. But they said your the ones to ask.
Thanks.
- Labels:
-
EEM Scripting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2013 12:17 PM
This applet looks okay for the most part. What you'll need to do, though, is store the value of $_cli_result after each test command and check each output. For example:
action 2.1 set port_0_0_0 $_cli_result
action 3.1 set port_0_0_1 $_cli_result
action 3.2 set bad_line 0
action 4.0 regexp "0x00" $port_0_0_0
action 4.1 if $_regexp_result eq 1
action 4.2 append mail_result $port_0_0_0
action 4.3 set bad_line 1
action 4.4 end
action 4.5 regexp "0x00" $port_0_0_1
action 4.6 if $_regexp_result eq 1
action 4.7 append mail_result $port_0_0_1
action 4.8 set bad_line 1
action 4.9 end
action 5.0 if $bad_line eq 1
...
Then use $mail_result instead of $_cli_result in your email body. And delete action 9.0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2013 02:28 PM
Thanks for the advice. I took what you gave me there and added in the important bits. I also specified a port which would have a result of 0x00 for testing purposes however I see no output on the screen and I do not receive an email. This is what I have.I'm using event trigger none, and running it by "event manager run test" .. I think that should work?
event manager applet test
event none
action 1.0 cli command "enable"
action 2.0 cli command "test voice port 0/0/0 si-reg-read 29 1"
action 2.1 set port_0_0_0 "$_cli_result"
action 3.0 cli command "test voice port 0/0/2 si-reg-read 29 1"
action 3.1 set port_0_0_1 "$_cli_result"
action 3.2 set bad_line "0"
action 4.0 regexp "0x00" "$port_0_0_0"
action 4.1 if $_regexp_result eq 1
action 4.2 append mail_result "$port_0_0_0"
action 4.3 set bad_line "1"
action 4.4 end
action 4.5 regexp "0x00" "$port_0_0_1"
action 4.6 if $_regexp_result eq 1
action 4.7 append mail_result "$port_0_0_1"
action 4.8 set bad_line "1"
action 4.9 end
action 5.0 if $bad_line eq 1
action 7.0 mail server "$_mail_smtp" to "$_mail_rcpt2" from "$_info_routername@$_mail_domain" subject "Analog line down on $_info_routername" body "$mail_result"
!
end
Thanks again for your response!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2013 05:52 PM
You need to add:
action 8.0 end
You should also enable "debug event manager action cli" and "debug event manager action mail" to confirm that the CLI output is looking and what is going on during execution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2013 08:09 PM
Thanks for catching that! I turned on the debugs and re-ran it. Im a little concerned that the "test voice" command is not reutrning results before the script ends and therefore nothing is being checked... There is about a second delay before the results from the test are displyaed in the CLI... any thoughs on that? Here is the output from the CLI.
Sep 24 02:58:24.792: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : CTL : cli_open called.
.Sep 24 02:58:24.792: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : OUT : CC
.Sep 24 02:58:24.792: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : OUT : Connected to GATEWAY-ROUTER.ssusd.org on 645.
.Sep 24 02:58:24.792: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : OUT : Use of this system constitutes your consent to monitoring.
.Sep 24 02:58:24.792: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : OUT :
.Sep 24 02:58:24.792: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : OUT : GATEWAY-ROUTER>
.Sep 24 02:58:24.792: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : IN : GATEWAY-ROUTER>enable
.Sep 24 02:58:24.804: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : OUT : GATEWAY-ROUTER#
.Sep 24 02:58:24.804: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : IN : GATEWAY-ROUTER#test voice port 0/0/0 si-reg-read 29 1
.Sep 24 02:58:24.816: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : OUT : GATEWAY-ROUTER#
.Sep 24 02:58:24.816: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : IN : GATEWAY-ROUTER#test voice port 0/0/2 si-reg-read 29 1
.Sep 24 02:58:24.816:
Values read from SiLabs Codec connected to DSP 0, channel 0:
--------------------------------------------------------------
Register 29 = 0xCC
.Sep 24 02:58:24.816:
GATEWAY-ROUTER#
.Sep 24 02:58:24.828: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : OUT : GATEWAY-ROUTER#
.Sep 24 02:58:24.828: %HA_EM-6-LOG: test : DEBUG(cli_lib) : : CTL : cli_close called.
.Sep 24 02:58:24.828:
Values read from SiLabs Codec connected to DSP 0, channel 2:
--------------------------------------------------------------
Register 29 = 0x00
.Sep 24 02:58:24.828:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 07:52 AM
If the commands aren't synchronous, then this applet approach will not work. It looks like the results are sent via syslog. If you register this applet, what do you see printed:
event manager applet test-test
event syslog pattern "Values read"
action 1.0 syslog msg "XXX: Result is '$_syslog_msg'"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 09:31 AM
This is the result when I try to run that applet.
GATEWAY-ROUTER#event manager run test-test
EEM policy test-test not registered with event none Event Detector
GATEWAY-ROUTER#

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 09:33 AM
No, this policy is not run that can be run manually. You'll need to run the test commands again so that they generate their result messages. Then look at the results from this applet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 10:01 AM
Ok so when I execute the test command this is what I see in the console.
GATEWAY-ROUTER#
.Sep 24 16:59:38.885:
Values read from SiLabs Codec connected to DSP 0, channel 2:
--------------------------------------------------------------
Register 29 = 0x00
.Sep 24 16:59:38.885:
GATEWAY-ROUTER#
.Sep 24 16:59:38.885: %HA_EM-6-LOG: test-test: XXX: Result is '
.Sep 24 16:59:38.885:
Values read from SiLabs Codec connected to DSP 0, channel 2:
'
GATEWAY-ROUTER#
Looks as if It sees part of it but not the value of the register..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 01:14 PM
Yeah, I don't have a good answer for you. Is there any way to go back and use a show command to look at the results of the last test?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 01:53 PM
Best I can come up with is this, but it does not show the value were looking for.
GATEWAY-ROUTER#show event manager history events detailed
No. Job Id Proc Status Time of Event Event Type Name
1 6 Actv success Tue Sep24 07:15:41 2013 none applet: test
argc 0
2 7 Actv success Tue Sep24 07:17:10 2013 none applet: test
argc 0
3 8 Actv success Tue Sep24 09:57:18 2013 syslog applet: test-test
msg
.Sep 24 16:57:18.161:
Values read from SiLabs Codec connected to DSP 0, channel 2:
4 9 Actv success Tue Sep24 09:58:26 2013 syslog applet: test-test
msg
.Sep 24 16:58:26.597:
Values read from SiLabs Codec connected to DSP 0, channel 2:
5 10 Actv success Tue Sep24 09:58:47 2013 syslog applet: test-test
msg
.Sep 24 16:58:47.594:
Values read from SiLabs Codec connected to DSP 0, channel 1:
6 11 Actv success Tue Sep24 09:58:59 2013 syslog applet: test-test
msg
.Sep 24 16:58:59.311:
Values read from SiLabs Codec connected to DSP 0, channel 2:
7 12 Actv success Tue Sep24 09:59:38 2013 syslog applet: test-test
msg
.Sep 24 16:59:38.885:
Values read from SiLabs Codec connected to DSP 0, channel 2:
8 14 Actv success Tue Sep24 10:00:13 2013 syslog applet: test-test
msg
.Sep 24 17:00:13.095:
Values read from SiLabs Codec connected to DSP 0, channel 0:
9 13 Actv success Tue Sep24 10:00:13 2013 none applet: test
argc 0
10 15 Actv success Tue Sep24 10:00:13 2013 syslog applet: test-test
msg
.Sep 24 17:00:13.107:
Values read from SiLabs Codec connected to DSP 0, channel 2:
GATEWAY-ROUTER#
I do appreciate the amount of time you've put in to help me try and figure it out. I wish there was a way to do this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 02:03 PM
I was hoping for a voice-specific command that would show the value of the last test. The command would need to map the port to the value in some way. You might try seeing what you get with:
event manager applet test-test
event tag 1 syslog patterm "Values read"
event tag 2 syslog pattern "Register 29"
trigger occurs 1 period 1
correlate event 1 and event 2
action 1.0 syslog msg "XXX: Value is '$_syslog_msg'"
The problem is, even if this works, there's no way to truly tie the two messages together. You could wait for two seconds between test commands and that would almost ensure the correctness, but it wouldn't necessarily be 100% valid.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 02:42 PM
Could we cat the results of the output to a file then grep the file? and delete it afterwards?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 02:44 PM
No. The command produces no output directly. Instead, it runs the test, then prints the results via logging messages.
