Re: [asterisk-users] Limit total length of calls to a specifig SIP peer

2010-06-09 Thread Laurent CARON
On 08/06/2010 19:19, Steve Edwards wrote:
 The ONLY way (how's that for humble) to do this in a reliable and robust
 method is to use a real database. Personally, I like MySQL and I prefer to
 do database work in an AGI in a compiled language like C.

 Maintaining the accumulated duration in a global variable will fail if you
 need to restart Asterisk at any time. A global variable will also fail
 if you have more than 1 call finish at the same time.

 Parsing log files is guaranteed to be a resource pig and still has race
 conditions.


Hi,

I'm gonna follow your advice and store the CDR in a PostgreSQL database. 
It will allow to easily plug an AGI script to it.

Thanks

Laurent

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


[asterisk-users] Limit total length of calls to a specifig SIP peer

2010-06-08 Thread Laurent CARON
Hi,

I'm currently using a cheap SIP provider for outbound calls.

I do have 6 channels to them.

In their terms of service there is the following limit:

The total duration of calls during one single day should not exceed 24 
hours or we do have the right to terminate the contract...blah blah

What is the best way to use this provider as long as we are below let's 
say 22h in a single day ?

Thanks

Laurent

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Limit total length of calls to a specifig SIP peer

2010-06-08 Thread Mike
If your server is good enough to handle those queries, I would have a cron
job use the CDR to calculate the time spent this current day every minute or
so, put this value in a text file (or anywhere really) and read it every
call you make to check, and use this as the absolute timeout value for your
call. Then again, if you have one hour left, you should divid this by six
(in case everyone calls out at the same time). 

So if you have 2 hours left, only allow one call to use 120minutes/6

Mike.



 -Original Message-
 From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-
 boun...@lists.digium.com] On Behalf Of Laurent CARON
 Sent: Tuesday, June 08, 2010 8:53
 To: Asterisk Users Mailing List - Non-Commercial Discussion
 Subject: [asterisk-users] Limit total length of calls to a specifig SIP
 peer
 
 Hi,
 
 I'm currently using a cheap SIP provider for outbound calls.
 
 I do have 6 channels to them.
 
 In their terms of service there is the following limit:
 
 The total duration of calls during one single day should not exceed 24
 hours or we do have the right to terminate the contract...blah blah
 
 What is the best way to use this provider as long as we are below let's
 say 22h in a single day ?
 
 Thanks
 
 Laurent
 
 --
 _
 -- Bandwidth and Colocation Provided by http://www.api-digital.com --
 New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
 
 asterisk-users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users


-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Limit total length of calls to a specifig SIP peer

2010-06-08 Thread Danny Nicholas
My .02 - I would set up a context for dialing with this provider that counts
minutes and stops the dial with a message once you get to 1321 minutes (22
hours).

Exten = _8X.,1,noop(call using Cheap sip)
Exten = _8X.,2,macro(call_out,${EXTEN:1})
Exten = _8X.,3,hangup

[macro-call_out]
Exten = s,1,Gotoif($[${GLOBAL(SECUSED)}  79200]?4)
Exten = s,n,playback(out-of-minutes)
Exten = s,n,hangup
Exten = s,n,dial(SIP/${ARG1}...)
Exten = s,n,Set(GLOBAL(SECUSED)=${GLOBAL(SECUSED)} + ${DIALEDTIME})
Exten = s,n,hangup
Exten = h,1,Set(GLOBAL(SECUSED)=${GLOBAL(SECUSED)} + ${DIALEDTIME})

By using DIALEDTIME instead of ANSWEREDTIME, you reduce the possibility of
going over on your minutes, but you could squeeze in an extra 2-20 seconds
per call using AT vs DT.

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Laurent CARON
Sent: Tuesday, June 08, 2010 7:53 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] Limit total length of calls to a specifig SIP peer

Hi,

I'm currently using a cheap SIP provider for outbound calls.

I do have 6 channels to them.

In their terms of service there is the following limit:

The total duration of calls during one single day should not exceed 24 
hours or we do have the right to terminate the contract...blah blah

What is the best way to use this provider as long as we are below let's 
say 22h in a single day ?

Thanks

Laurent

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Limit total length of calls to a specifig SIP peer

2010-06-08 Thread Laurent CARON
On 08/06/2010 15:21, Danny Nicholas wrote:
 My .02 - I would set up a context for dialing with this provider that counts
 minutes and stops the dial with a message once you get to 1321 minutes (22
 hours).

 Exten =  _8X.,1,noop(call using Cheap sip)
 Exten =  _8X.,2,macro(call_out,${EXTEN:1})
 Exten =  _8X.,3,hangup

 [macro-call_out]
 Exten =  s,1,Gotoif($[${GLOBAL(SECUSED)}  79200]?4)
 Exten =  s,n,playback(out-of-minutes)
 Exten =  s,n,hangup
 Exten =  s,n,dial(SIP/${ARG1}...)
 Exten =  s,n,Set(GLOBAL(SECUSED)=${GLOBAL(SECUSED)} + ${DIALEDTIME})
 Exten =  s,n,hangup
 Exten =  h,1,Set(GLOBAL(SECUSED)=${GLOBAL(SECUSED)} + ${DIALEDTIME})

 By using DIALEDTIME instead of ANSWEREDTIME, you reduce the possibility of
 going over on your minutes, but you could squeeze in an extra 2-20 seconds
 per call using AT vs DT.


I'm using the following:

exten = 0145381068,1,NoOp()
exten = 0145381068,2,Gotoif($[${GLOBAL(SECUSED)}10]?4)
exten = 0145381068,3,hangup
exten = 0145381068,4,Dial(SIP/1...@sipoperator)
exten = 0145381068,5,Set(GLOBAL(SECUSED)=${GLOBAL(SECUSED)} + 
${DIALEDTIME})
exten = 0145381068,6,hangup


I place a test call of 20 secs, hangup, and I can place another call 
again through the same provider.

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Limit total length of calls to a specifig SIP peer

2010-06-08 Thread Steve Edwards
On Tue, 8 Jun 2010, Laurent CARON wrote:

 I'm currently using a cheap SIP provider for outbound calls.

 I do have 6 channels to them.

 In their terms of service there is the following limit:

 The total duration of calls during one single day should not exceed 24
 hours or we do have the right to terminate the contract...blah blah

 What is the best way to use this provider as long as we are below let's
 say 22h in a single day ?

The ONLY way (how's that for humble) to do this in a reliable and robust 
method is to use a real database. Personally, I like MySQL and I prefer to 
do database work in an AGI in a compiled language like C.

Maintaining the accumulated duration in a global variable will fail if you 
need to restart Asterisk at any time. A global variable will also fail 
if you have more than 1 call finish at the same time.

Parsing log files is guaranteed to be a resource pig and still has race 
conditions.

-- 
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
Newline  Fax: +1-760-731-3000

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users