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 ? Hans Goossen Investigaci?n & Desarrollo Planet S.A. http://www.pla.net.py
On Wed, Nov 16, 2011 at 10:46 AM, Hans Goossen <goossen at planet.com.py> 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 ? > > Hans Goossen > Investigaci?n & Desarrollo > Planet S.A. > http://www.pla.net.pyYou can use the DB[1] to add a table with user and seconds. Then use the start and end seconds to do this. I know there are many ways of doing this with AGI, Manager, Realtime, etc... [1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Function_DB -- ~ Andrew "lathama" Latham lathama at gmail.com http://lathama.net ~
Hello Hans, On 11-16-2011 14:46, Hans Goossen wrote:> 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 would create a macro which calls an agi. The agi searches the CDR table (mine is in sql) and calculates if the call can go through. Then i'd call this macro from every extension in the dial plan just before the dial cmd.> 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. >It depends on the number of simultaneous calls from within the same context. The agi can return a number of seconds (calculated from sql) which the dial cmd can use as an absolute limit and after that amount of seconds it can hang up the call (see S or L flags). regards adam
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.