[asterisk-users] Limit monthly calls by context

Danny Nicholas danny at debsinc.com
Wed Nov 16 13:21:18 CST 2011


If you store the Global in DB and read it back from DB, it can persist
across reboots and reloads.

-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of A J Stiles
Sent: Wednesday, November 16, 2011 1:13 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] Limit monthly calls by context

On Wednesday 16 November 2011, Hans Goossen wrote:
> Hello group,
> 
> I have this situation:
> 
> I have several contexts with a few extensions each one. I need to give 
> every context a limited quantity of minutes they can use. All the 
> extensions in the context will share the same "bag" of minutes. 
> Meaning ext 101 use 1900 mins, ext 102 60 mins and ext 40 mins. The 
> limit must be monthly.
> 
> I guess some "billing" solution can do the trick, but I think it's too 
> much for that little. I don't need any other feature.
> 
> I was thinking something like checking the CDR before make the call, I 
> know it may permit some "extra" minutes to be used, but it really 
> doesn't need to be that exact. A couple of extra minutes won't hurt.
> 
> Ideas, suggestions ?

Set a global variable or several in the beginning of the dialplan with the
monthly allowance for each context.  In the "h" extension of each
time-limited context, subtract the duration of the call just made from the
global.  In each extension which is time-limited, replace Dial() with a call
to a macro which either actually executes the Dial() if there is any time
remaining  (and uses that as an absolute timeout value), otherwise plays a
message.

If you need the remaining allowances to persist across reboots / dialplan
reloads, you'll have to have an AGI write them to a file which you can
#include in the [globals] section of the dialplan.  A cron job can then be
used to reset the allowances at the beginning of each month, by copying a
"pristine" 
file over it.

Note it's still possible to go over with this method, because the remaining
time is only recalculated at hangup, but you said it didn't have to be
exact.

--
AJS

Answers come *after* questions.

--
_____________________________________________________________________
-- 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




More information about the asterisk-users mailing list