07-27-2020 02:07 PM - edited 07-27-2020 03:25 PM
I need to monitor FXO ports on a 4331 by detecting whether or not there is tone on a line.
Example:
csim start [number]
Parse for "failed = 1" and email if it finds that in the output.
I'm having difficulty coming up with a working EEM.
The following is probably completely wrong, but here is what I have. Any help would be appreciated.
dial-peer voice 9999 pots
description ** Test CSIM calling **
destination-pattern 91234567890
progress_ind setup enable 3
port 0/1/1
forward-digits 10
no sip-register
event manager environment _mail_smtp example@domain.com
event manager environment _mail_domain domain.com
event manager environment _mail_rcpt1 user1@domain.com
event manager environment _mail_rcpt2 user2@domain.com
event manager environment _info_routername Router
event manager applet CSimAnalogueMonitor
event timer watchdog time 86500
action 1.0 cli command "enable"
action 2.0 cli command "csim start 91234567890"
action 3.2 set bad_line "0"
action 4.0 regexp "0x00" "$port_0_1_1"
action 4.1 if $_regexp_result eq "failed = 1"
action 4.2 append mail_result "$port_0_1_1"
action 4.3 set bad_line "1"
action 4.4 end
action 5.0 if $bad_line eq "1"
action 5.1 mail server "$_mail_smtp" to "$_mail_rcpt1" from "$_info_routername@$_mail_domain" subject "Analogue line down on $_info_routername" body "$mail_result"
action 6.0 end
end
Solved! Go to Solution.
08-06-2020 08:03 AM - edited 08-17-2020 08:05 AM
I resolved this myself after realizing syntax needs to be perfect throughout the entire command otherwise nothing works. I am getting alerts only when the router fails a test call to the assigned numbers on each voice-port at midnight.
Dial Peers to force test calls through FXO ports:
dial-peer voice 9999 pots
destination-pattern 91234567890
progress_ind setup enable 3
port 0/1/1
forward-digits 10
no sip-register
dial-peer voice 99999 pots
destination-pattern 912345678912
progress_ind setup enable 3
port 0/1/0
forward-digits 11
no sip-register
Declaring variables:
event manager environment _mail_smtp smtp.domain.com
event manager environment _mail_rcpt1 user1@domain.com
event manager environment _mail_rcpt2 user2@domain.com
event manager environment _info_routername Router1
event manager environment _mail_domain domain.com
Applet per voice-port:
event manager applet MonitorVP010
event cron cron-entry @Midnight (run daily at midnight)
action 10 cli command "enable"
action 20 cli command "csim start 912345678912"
action 30 regexp "[0-9]+.*failed = 1" "$_cli_result" (regular expression looking for 'failed = 1' within the entire cli output)
action 31 puts "$_regexp_result" (for manual testing purposes only)
action 32 if $_regexp_result eq "1" (if regular expression finds the string 'failed = 1' then send alert email to two users)
action 33 mail server "$_mail_smtp" to "$_mail_rcpt1 $_mail_rcpt2" from "$_info_routername@$_mail_domain" subject "$_info_routername voice-port 0/1/0 down" body "$_cli_result"
action 34 snmp-trap strdata "Voice-port 0/1/0 Failed" (create snmp trap)
action 40 end
event manager applet MonitorVP011
event cron cron-entry @Midnight
action 05 wait 10
action 10 cli command "enable"
action 20 cli command "csim start 91234567890"
action 30 regexp "[0-9]+.*failed = 1" "$_cli_result"
action 31 puts "$_regexp_result"
action 32 if $_regexp_result eq "1"
action 33 mail server "$_mail_smtp" to "$_mail_rcpt1 $_mail_rcpt2" from "$_info_routername@$_mail_domain" subject "$_info_routername voice-port 0/1/1 down" body "$_cli_result"
action 34 snmp-trap strdata "Voice-port 0/1/1 Failed"
action 40 end
08-06-2020 08:03 AM - edited 08-17-2020 08:05 AM
I resolved this myself after realizing syntax needs to be perfect throughout the entire command otherwise nothing works. I am getting alerts only when the router fails a test call to the assigned numbers on each voice-port at midnight.
Dial Peers to force test calls through FXO ports:
dial-peer voice 9999 pots
destination-pattern 91234567890
progress_ind setup enable 3
port 0/1/1
forward-digits 10
no sip-register
dial-peer voice 99999 pots
destination-pattern 912345678912
progress_ind setup enable 3
port 0/1/0
forward-digits 11
no sip-register
Declaring variables:
event manager environment _mail_smtp smtp.domain.com
event manager environment _mail_rcpt1 user1@domain.com
event manager environment _mail_rcpt2 user2@domain.com
event manager environment _info_routername Router1
event manager environment _mail_domain domain.com
Applet per voice-port:
event manager applet MonitorVP010
event cron cron-entry @Midnight (run daily at midnight)
action 10 cli command "enable"
action 20 cli command "csim start 912345678912"
action 30 regexp "[0-9]+.*failed = 1" "$_cli_result" (regular expression looking for 'failed = 1' within the entire cli output)
action 31 puts "$_regexp_result" (for manual testing purposes only)
action 32 if $_regexp_result eq "1" (if regular expression finds the string 'failed = 1' then send alert email to two users)
action 33 mail server "$_mail_smtp" to "$_mail_rcpt1 $_mail_rcpt2" from "$_info_routername@$_mail_domain" subject "$_info_routername voice-port 0/1/0 down" body "$_cli_result"
action 34 snmp-trap strdata "Voice-port 0/1/0 Failed" (create snmp trap)
action 40 end
event manager applet MonitorVP011
event cron cron-entry @Midnight
action 05 wait 10
action 10 cli command "enable"
action 20 cli command "csim start 91234567890"
action 30 regexp "[0-9]+.*failed = 1" "$_cli_result"
action 31 puts "$_regexp_result"
action 32 if $_regexp_result eq "1"
action 33 mail server "$_mail_smtp" to "$_mail_rcpt1 $_mail_rcpt2" from "$_info_routername@$_mail_domain" subject "$_info_routername voice-port 0/1/1 down" body "$_cli_result"
action 34 snmp-trap strdata "Voice-port 0/1/1 Failed"
action 40 end
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