Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
Notify by email when remote server returns 486 BUSY
Author Message
dstu
Brekeke Talented


Joined: 06 Feb 2006
Posts: 72

PostPosted: Sun Sep 29, 2013 1:18 am    Post subject: Notify by email when remote server returns 486 BUSY Reply with quote

1. Brekeke Product Name and Version:
Brekeke SIP Server , Version 3.1.9.0 Advanced

2. Java version:
Tomcat 6.0.35.0

3. OS type and the version:
Debian Linux 6.0

4. UA (phone), gateway or other hardware/software involved:

5. Your problem:
I would like to be notified by when a certain remote server returns 486 BUSY to an INVITE request.
I was told to create a HEARTBEAT and then to "add an action" of sending an email, but a heartbeat seems to me like a new message I send (with predefined interval), but it's not what I want. I want normal INVITEs being sent normally that are answered by BUSY (should never happen from this specific destination server) to be alerted.
How do I do that?

Thanks.
Back to top
View user's profile
Harold
Brekeke Master Guru


Joined: 21 Sep 2008
Posts: 286
Location: Japan

PostPosted: Sun Sep 29, 2013 9:47 am    Post subject: Reply with quote

The HeatBeat doesn't send normal INVITE.
The session plugin will meet the requirement but you need to write a code.
Back to top
View user's profile
dstu
Brekeke Talented


Joined: 06 Feb 2006
Posts: 72

PostPosted: Mon Sep 30, 2013 12:58 am    Post subject: Reply with quote

Harold wrote:
The HeatBeat doesn't send normal INVITE.

That's what I said. I don't expect the heartbeat to send anything. I want to capture busy responses, just like in example 4 in this page and except for rerouting, to be notified:
http://wiki.brekeke.com/wiki/How-to-make-Failover-in-the-Dial-Plan

Harold wrote:
The session plugin will meet the requirement but you need to write a code.

Can you assist with that? Are there any examples available?

Thanks
Back to top
View user's profile
james
Brekeke Master Guru


Joined: 10 Dec 2007
Posts: 494

PostPosted: Mon Sep 30, 2013 10:14 am    Post subject: Reply with quote

Create a new file "config.properties" in <Tomcat>/webapps/sip/WEB-INF/work/sv.

And put the line below in the file.
Code:
com.brekeke.siptool.haman.HeartbeatSIP.SIP_METHOD=INVITE

Save the file and restart the SIP Server.

Now the SIP server sends INVITE instead of OPTIONS.
Back to top
View user's profile
voipwell.com
Partner PBX


Joined: 20 Sep 2005
Posts: 528
Location: Tannersville, Pennsylvania

PostPosted: Fri Oct 04, 2013 7:26 pm    Post subject: Reply with quote

email alert when Any call to a specific IP returns busy.
Is that what you are looking for?

We had a similar needed to email alert when a deivice failed registration so we could see if anyone is trying to hack. We used windowsh shell program to check the Brekeke log file every 30 seconds for new failed registrations and email alert. Each pass knew where the other left off so only new failures were emailed.

In linux using tail it's much easier than windows. a simple shell looping thru the Brekeke call log pattern mathing 486 busy as it appears in the log should be able to email you. I guess you could write a plugin to do the same thing live in java.

If you are comfortable in the dial plan then you could make a failover route that takes the call information and can post it to a web page for recording and notification. Lookup how to do the webget.

We use webget to add caller-id name to a call. it takes the callers number and posts it to a website that returns the name. You can just as easily use that type of function to post your caller's number to a website that then emails that number to you letting you know that a busy occured.
Back to top
View user's profile
james
Brekeke Master Guru


Joined: 10 Dec 2007
Posts: 494

PostPosted: Fri Oct 04, 2013 11:12 pm    Post subject: Reply with quote

Hi

> We had a similar needed to email alert when a deivice failed registration


Try this.

In the [DialPlan] page
Matching Patterns
$request = ^OPTIONS
$if($registered(To),"200","404") = (.+)
Deploy Patterns
$response = %1

If the To-URI's SIP user is registered, it returns the response "200". Otherwise, it returns the response "404".


In the [Redundancy]->[Heartbeat] page
Heartbeat
----------------------------------
Monitoring Method: SIP
SIP URI: sip:user@localhost <--- replace user with the actual username which you want to monitor.
Interval: 30000 <---- 30 seconds
Response Codes: 404 <---- It is the trigger for sending the email.
----------------------------------

Action 1
----------------------------------
Type: Send Email
and setup it with your mail account
----------------------------------
Back to top
View user's profile
dstu
Brekeke Talented


Joined: 06 Feb 2006
Posts: 72

PostPosted: Sat Oct 05, 2013 3:02 am    Post subject: Reply with quote

But in this case, we (the brekeke) is sending the invites to a remote server and i want a failover to happen automatically if the primary destination returns busy, that in our specific case, can only happen if there a crash on the remote server or if it's full, so I'll use this procedure:

Quote:

If sip:100@192.168.0.100 responds with error code 486 (Busy), the SIP Server sends the INVITE to sip:101@192.168.0.101.
Deploy Patterns
To = sip:100@192.168.0.100
$session = failover sip:101@192.168.0.101
&failover.pattern.response = 486

I don't want an email for every busy in the system, but only those related to that specific action in this specific rule.

Is that at all possible?

Thanks
Back to top
View user's profile
voipwell.com
Partner PBX


Joined: 20 Sep 2005
Posts: 528
Location: Tannersville, Pennsylvania

PostPosted: Sat Oct 05, 2013 5:57 am    Post subject: Reply with quote

Yes, you can elect to failover only if you are sending to a particular address.
Back to top
View user's profile
voipwell.com
Partner PBX


Joined: 20 Sep 2005
Posts: 528
Location: Tannersville, Pennsylvania

PostPosted: Sat Oct 05, 2013 12:05 pm    Post subject: Reply with quote

I see your point.

How do we send an email from a dialplan that is getting executed for busy calls to 192.168.0.100 without sending an email for all calls. We only want email for busy calls to 192.168.0.100. The quandry is both successful calls and busy calls would be handled by the same dial plan so how can you fire the webget for only the failed calls?

Before we tackle that i want to make sure you understand my reference to webget and it's purpose. You would have to develop a web page that you could post values to that would cause it to send you emails. If you have the capability to do that then a webget function in the dial plan can do this for you.

James suggestion with the heartbeat suggests that you set up a heartbeat to send invites to number@192.168.0.100 and if there is no response or a busy response that it fire off an email. That can assure you that the server at 192.168.0.100 is operational and if you use a valid number that would cause that server at 192.168.0.100 to connect to another server you could go another level deep into knowing if the server is functioning or not.

Are you concerned if 192.168.0.100 is functioning and properly responding to invite packets then heartbeat is best.

Are you concerned that some of the destinations that 192.168.0.100 is sending calls to may be returning busy and you need to know that?
Where some calls may be going thru and others not and you want to know what is not going thru? Then you need to do it thru webget or a plugin. I hope that helps.
Back to top
View user's profile
dstu
Brekeke Talented


Joined: 06 Feb 2006
Posts: 72

PostPosted: Mon Oct 07, 2013 2:38 am    Post subject: Reply with quote

voipwell.com wrote:
I see your point.

How do we send an email from a dialplan that is getting executed for busy calls to 192.168.0.100 without sending an email for all calls. We only want email for busy calls to 192.168.0.100. The quandry is both successful calls and busy calls would be handled by the same dial plan so how can you fire the webget for only the failed calls?

Before we tackle that i want to make sure you understand my reference to webget and it's purpose. You would have to develop a web page that you could post values to that would cause it to send you emails. If you have the capability to do that then a webget function in the dial plan can do this for you.

James suggestion with the heartbeat suggests that you set up a heartbeat to send invites to number@192.168.0.100 and if there is no response or a busy response that it fire off an email. That can assure you that the server at 192.168.0.100 is operational and if you use a valid number that would cause that server at 192.168.0.100 to connect to another server you could go another level deep into knowing if the server is functioning or not.

Are you concerned if 192.168.0.100 is functioning and properly responding to invite packets then heartbeat is best.

Are you concerned that some of the destinations that 192.168.0.100 is sending calls to may be returning busy and you need to know that?
Where some calls may be going thru and others not and you want to know what is not going thru? Then you need to do it thru webget or a plugin. I hope that helps.


Thank you for your detailed response.

1. Using webget is not a problem. I can easily prepare a small PHP page that would send an email, but the condition is that a failover event has occurred. I'm not sure how to implement that (that's the main issue, actually).

2. Referring to James' suggestion, put in your words, seems like another approach that I didn't consider, i.e. to initiate HEARTBEAT INVITE messages that are not related to live traffic and and see the response to determine the remote server's health. It's not a bad idea, but I still need to check if a BUSY would be returned in all cases,or only for specific apps, so I'll have to investigate that point once it happens again.

Thank you both for your assistance.

Regards.
Back to top
View user's profile
voipwell.com
Partner PBX


Joined: 20 Sep 2005
Posts: 528
Location: Tannersville, Pennsylvania

PostPosted: Mon Oct 07, 2013 5:13 am    Post subject: Reply with quote

So we have the question presented more clearly now. Since the webget is in the matching pattern side of the dialplan, how do we make it conditional upon a 486 busy response? I don't see a way to change the webget values based on the response of the invite. But the question is clearer now so let's see what the others on the forum have to offer.
Back to top
View user's profile
james
Brekeke Master Guru


Joined: 10 Dec 2007
Posts: 494

PostPosted: Mon Oct 07, 2013 11:06 am    Post subject: Reply with quote

ok
I have another idea. It doesn't use Heartbeat function.


Rule-1:
Matching Patterns
$request = ^INVITE
$localhost = true
To = sip:222@
$webget("http://your-web.com/sendmail.php?user%3D222") = .+
Deploy Patterns
To = sip:222@192.168.1.222

Rule-2:
Matching Patterns
$request = ^INVITE
To = sip:111@
Deploy Patterns
To = sip:111@192.168.1.111
$session = failover sip:222@localhost
&failover.pattern.response = 486

If 111@192.168.1.111 returns "486 Busy", the Rule-2 catches it and sends "INVITE sip:222@localhost" to the SIP server itself.
The Rule-1 catches new INVITE and calls the php webpage, and then forwards the call to the final destination sip:222@192.168.1.222.

In the above case, web url is http://your-web.com/sendmail.php?user=222
you can send an e-mail in your php.


Last edited by james on Mon Oct 07, 2013 11:29 am; edited 2 times in total
Back to top
View user's profile
voipwell.com
Partner PBX


Joined: 20 Sep 2005
Posts: 528
Location: Tannersville, Pennsylvania

PostPosted: Mon Oct 07, 2013 11:18 am    Post subject: Rule to Rule Dialplan Pass Reply with quote

Since it's fo-otball season you could call this a dial plan rule to rule pass. I don't recall ever seeing one on this forum before. Thank you James and dstu!
Back to top
View user's profile
dstu
Brekeke Talented


Joined: 06 Feb 2006
Posts: 72

PostPosted: Thu Oct 10, 2013 2:02 am    Post subject: Reply with quote

james wrote:
ok
I have another idea. It doesn't use Heartbeat function.


Rule-1:
Matching Patterns
$request = ^INVITE
$localhost = true
To = sip:222@
$webget("http://your-web.com/sendmail.php?user%3D222") = .+
Deploy Patterns
To = sip:222@192.168.1.222

Rule-2:
Matching Patterns
$request = ^INVITE
To = sip:111@
Deploy Patterns
To = sip:111@192.168.1.111
$session = failover sip:222@localhost
&failover.pattern.response = 486

If 111@192.168.1.111 returns "486 Busy", the Rule-2 catches it and sends "INVITE sip:222@localhost" to the SIP server itself.
The Rule-1 catches new INVITE and calls the php webpage, and then forwards the call to the final destination sip:222@192.168.1.222.

In the above case, web url is http://your-web.com/sendmail.php?user=222
you can send an e-mail in your php.


That looks like a great idea. I'll call this rule "Wide_Receiver" Smile

Thanks!!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1