cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3642
Views
0
Helpful
4
Replies

EEM Script to send alerts

packetdictator
Level 1
Level 1

Hi Im seeking your assistance in creating an eem script

 

EEM Task

-ping the sip server every 1 minute(already done with this script)

-email the recipient "once" the Sip Server of the Sip provider doesn't respond to ping request and email again once the Sip Server of Sip Provider is responding again

 

i have already created variables below appreciate your advise and response.

 

event manager applet Check_Globe-Pldt_SIP_Trunk
event timer cron cron-entry "*/1 * * * *"
action 1.0 cli command "enable"
action 2.0 foreach host "PLDT_SIP GLOBE_SIP"
action 2.1 cli command "ping $host repeat 5 timeout 1"
action 2.2 regexp "(.*)!!!(.*)" "$_cli_result"
action 3.0 if $_regexp_result eq "1"
action 3.1 puts "$host - TRUNK UP"
action 3.2 elseif $_regexp_result eq 0
action 3.3 puts "$host - TRUNK DOWN"
action 4.0 end

!
event manager applet Email-PLDT-Sip-Trunk-Status-Down
event syslog occurs 2 pattern "PLDT_SIP - TRUNK DOWN" period 1
action 0.1 info type routername
action 1.0 comment "#### PLDT ####"
action 1.1 mail server "$_mail_smtp" to "$_mail_rcpt" from "sip_trunk_alert@$_info_routername" subject "PLDT SIP - TRUNK DOWN" body "PLDT SIP TRUNK IS DOWN!!!, PLEASE CONTACT PLDT"
action 1.2 syslog msg "E-mail Alert sent"

!
event manager applet Email-GLOBE-Sip-Trunk-Status-Down
event syslog occurs 2 pattern "GLOBE_SIP - TRUNK DOWN" period 1
action 0.1 info type routername
action 2.0 comment "#### GLOBE ####"
action 2.1 mail server "$_mail_smtp" to "$_mail_rcpt" from "sip_trunk_alert@$_info_routername" subject "GLOBE SIP - TRUNK DOWN" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE"
action 2.2 syslog msg "E-mail Alert sent"

!
event manager applet Email-PLDT-Sip-Trunk-Status-UP
event syslog occurs 2 pattern "PLDT_SIP - TRUNK UP" period 1
action 0.1 info type routername
action 1.0 comment "#### PLDT ####"
action 1.1 mail server "$_mail_smtp" to "$_mail_rcpt" from "sip_trunk_alert@$_info_routername" subject "PLDT SIP - TRUNK UP" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS"
action 1.2 syslog msg "E-mail Alert sent"

!
event manager applet Email-GLOBE-Sip-Trunk-Status-UP
event syslog occurs 2 pattern "GLOBE_SIP - TRUNK UP" period 1
action 0.1 info type routername
action 2.0 comment "#### GLOBE ####"
action 2.1 mail server "$_mail_smtp" to "$_mail_rcpt" from "sip_trunk_alert@$_info_routername" subject "GLOBE SIP - TRUNK UP" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS"

action 2.2 syslog msg "E-mail Alert sent"

1 Accepted Solution

Accepted Solutions

Hi Balaji,

 

i tested script above i created but it did not work,  so i used track instead and it is working below is the scripts sharing to the other as well

thanks for the reply though appreciated your response

 

track 1 ip route GLOBE_SIP_IP 255.255.255.255 reachability
delay down 10 up 10
!
track 2 ip route PLDT_SIP_IP 255.255.255.255 reachability
delay down 10 up 10
!
event manager applet Email-GLOBE-Sip-Trunk-Status-Down
event track 1 state down
action 1.0 info type routername
action 1.1 comment "#### Globe SIP ####"
action 1.2 syslog msg "$Globe_Sip Trunk is Down!"
action 1.3 mail server "$_mail_smtp" to "$_mail_rcpts" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS DOWN ####" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE SIP TRUNK PROVIDER! for Outgoing Call use Dial 9"
action 1.4 mail server "$_mail_smtp" to "$_mail_rcpt1" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS DOWN ####" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE SIP TRUNK PROVIDER! for Outgoing Call use Dial 9"
action 1.5 mail server "$_mail_smtp" to "$_mail_rcpt2" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS DOWN ####" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE SIP TRUNK PROVIDER! for Outgoing Call use Dial 9"
action 1.6 mail server "$_mail_smtp" to "$_mail_rcpt3" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS DOWN ####" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE SIP TRUNK PROVIDER! for Outgoing Call use Dial 9"
action 1.7 syslog msg "E-mail Alert sent"

!
event manager applet Email-PLDT-Sip-Trunk-Status-Down
event track 2 state down
action 1.0 info type routername
action 1.1 comment "#### PLDT SIP####"
action 1.2 syslog msg "$Pldt_Sip Trunk is Down!"
action 1.3 mail server "$_mail_smtp" to "$_mail_rcpts" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS DOWN ####" body "PLDT SIP TRUNK IS DOWN!!! PLEASE CONTACT PLDT SIP TRUNK PROVIDER!"
action 1.4 mail server "$_mail_smtp" to "$_mail_rcpt1" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS DOWN ####" body "PLDT SIP TRUNK IS DOWN!!! PLEASE CONTACT PLDT SIP TRUNK PROVIDER!"
action 1.5 mail server "$_mail_smtp" to "$_mail_rcpt2" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS DOWN ####" body "PLDT SIP TRUNK IS DOWN!!! PLEASE CONTACT PLDT SIP TRUNK PROVIDER!"
action 1.6 mail server "$_mail_smtp" to "$_mail_rcpt3" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS DOWN ####" body "PLDT SIP TRUNK IS DOWN!!! PLEASE CONTACT PLDT SIP TRUNK PROVIDER!"
action 1.7 syslog msg "E-mail Alert sent"

!
event manager applet Email-GLOBE-Sip-Trunk-Status-Up
event track 1 state up
action 1.0 info type routername
action 1.1 comment "#### Globe SIP ####"
action 1.2 syslog msg "$Globe_Sip Trunk is Up!"
action 1.3 mail server "$_mail_smtp" to "$_mail_rcpts" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS UP ####" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 8"
action 1.4 mail server "$_mail_smtp" to "$_mail_rcpt1" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS UP ####" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 8"
action 1.5 mail server "$_mail_smtp" to "$_mail_rcpt2" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS UP ####" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 8"
action 1.6 mail server "$_mail_smtp" to "$_mail_rcpt3" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS UP ####" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 8"
action 1.7 syslog msg "E-mail Alert sent"

!
event manager applet Email-PLDT-Sip-Trunk-Status-Up
event track 2 state up
action 1.0 info type routername
action 1.1 comment "#### PLDT SIP ####"
action 1.2 syslog msg "$Pldt_Sip Trunk is Up!"
action 1.3 mail server "$_mail_smtp" to "$_mail_rcpts" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS UP ####" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 9"
action 1.4 mail server "$_mail_smtp" to "$_mail_rcpt1" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS UP ####" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 9"
action 1.5 mail server "$_mail_smtp" to "$_mail_rcpt2" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS UP ####" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 9"
action 1.6 mail server "$_mail_smtp" to "$_mail_rcpt3" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS UP ####" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 9"
action 1.7 syslog msg "E-mail Alert sent"

View solution in original post

4 Replies 4

balaji.bandi
Hall of Fame
Hall of Fame

what you seeing issue here ? high level script looks ok, as long as your email server access the mail relay for the router IP.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Hi Balaji,

 

thanks

 

as of now no issue but my concern is weather the email alert will send continuously or just once

 

also is there a way that i can combine both script?

 

Regards,

 

 

Email will be sent once the case is matched. 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Hi Balaji,

 

i tested script above i created but it did not work,  so i used track instead and it is working below is the scripts sharing to the other as well

thanks for the reply though appreciated your response

 

track 1 ip route GLOBE_SIP_IP 255.255.255.255 reachability
delay down 10 up 10
!
track 2 ip route PLDT_SIP_IP 255.255.255.255 reachability
delay down 10 up 10
!
event manager applet Email-GLOBE-Sip-Trunk-Status-Down
event track 1 state down
action 1.0 info type routername
action 1.1 comment "#### Globe SIP ####"
action 1.2 syslog msg "$Globe_Sip Trunk is Down!"
action 1.3 mail server "$_mail_smtp" to "$_mail_rcpts" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS DOWN ####" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE SIP TRUNK PROVIDER! for Outgoing Call use Dial 9"
action 1.4 mail server "$_mail_smtp" to "$_mail_rcpt1" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS DOWN ####" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE SIP TRUNK PROVIDER! for Outgoing Call use Dial 9"
action 1.5 mail server "$_mail_smtp" to "$_mail_rcpt2" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS DOWN ####" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE SIP TRUNK PROVIDER! for Outgoing Call use Dial 9"
action 1.6 mail server "$_mail_smtp" to "$_mail_rcpt3" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS DOWN ####" body "GLOBE SIP TRUNK IS DOWN!!!, PLEASE CONTACT GLOBE SIP TRUNK PROVIDER! for Outgoing Call use Dial 9"
action 1.7 syslog msg "E-mail Alert sent"

!
event manager applet Email-PLDT-Sip-Trunk-Status-Down
event track 2 state down
action 1.0 info type routername
action 1.1 comment "#### PLDT SIP####"
action 1.2 syslog msg "$Pldt_Sip Trunk is Down!"
action 1.3 mail server "$_mail_smtp" to "$_mail_rcpts" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS DOWN ####" body "PLDT SIP TRUNK IS DOWN!!! PLEASE CONTACT PLDT SIP TRUNK PROVIDER!"
action 1.4 mail server "$_mail_smtp" to "$_mail_rcpt1" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS DOWN ####" body "PLDT SIP TRUNK IS DOWN!!! PLEASE CONTACT PLDT SIP TRUNK PROVIDER!"
action 1.5 mail server "$_mail_smtp" to "$_mail_rcpt2" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS DOWN ####" body "PLDT SIP TRUNK IS DOWN!!! PLEASE CONTACT PLDT SIP TRUNK PROVIDER!"
action 1.6 mail server "$_mail_smtp" to "$_mail_rcpt3" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS DOWN ####" body "PLDT SIP TRUNK IS DOWN!!! PLEASE CONTACT PLDT SIP TRUNK PROVIDER!"
action 1.7 syslog msg "E-mail Alert sent"

!
event manager applet Email-GLOBE-Sip-Trunk-Status-Up
event track 1 state up
action 1.0 info type routername
action 1.1 comment "#### Globe SIP ####"
action 1.2 syslog msg "$Globe_Sip Trunk is Up!"
action 1.3 mail server "$_mail_smtp" to "$_mail_rcpts" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS UP ####" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 8"
action 1.4 mail server "$_mail_smtp" to "$_mail_rcpt1" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS UP ####" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 8"
action 1.5 mail server "$_mail_smtp" to "$_mail_rcpt2" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS UP ####" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 8"
action 1.6 mail server "$_mail_smtp" to "$_mail_rcpt3" from "globe_sip_trunk_alert@$_info_routername" subject "#### GLOBE SIP TRUNK IS UP ####" body "GLOBE SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 8"
action 1.7 syslog msg "E-mail Alert sent"

!
event manager applet Email-PLDT-Sip-Trunk-Status-Up
event track 2 state up
action 1.0 info type routername
action 1.1 comment "#### PLDT SIP ####"
action 1.2 syslog msg "$Pldt_Sip Trunk is Up!"
action 1.3 mail server "$_mail_smtp" to "$_mail_rcpts" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS UP ####" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 9"
action 1.4 mail server "$_mail_smtp" to "$_mail_rcpt1" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS UP ####" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 9"
action 1.5 mail server "$_mail_smtp" to "$_mail_rcpt2" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS UP ####" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 9"
action 1.6 mail server "$_mail_smtp" to "$_mail_rcpt3" from "pldt_sip_trunk_alert@$_info_routername" subject "#### PLDT SIP TRUNK IS UP ####" body "PLDT SIP TRUNK IS UP!!!, PLEASE TEST CALLS USING Prefix 9"
action 1.7 syslog msg "E-mail Alert sent"

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: