[HELP] Count outgoing minutes, then switch outbound provider

Help!

Is there a way to get Asterisk (or A@H) to count the number of outgoing minutes used in a month, then switch outbound providers when a certain threshold is reached?

Say I have a business plan that allows 1000 minutes, but then addtional minutes are 4 cents a minute. Now, obviously I can do a lot better than 4 cents/minute with a minutes provider, but I sure don’t want to lose my first 1000 “free” minutes every month.

Ideally, Asterisk tracks all outbound calls to this provider (doesn’t have to be “super” precise, just approximately- even willing to round all calls up to nearest minute, etc.) then automatically switches my preferred outbound provider when a preset limit (in my case 1000 minutes) is reached. Of course, at the end of a month Asterisk would need to switch back to the original provider, until the threshold is met again.

Any provision for that, that anyone knows of?

Thanks!

  • Paul

Bump…

Hi there,

If you’re using some SQL backend for CDR records you can just run a query like this “SELECT SUM(billsec) FROM cdr_table WHERE MONTH(calldate) = MONTH(NOW())” from an AGI script and see how much seconds you have used for the current month.

Hope this helps you.

Stoyan

Thanks Stoyan.

MySQL, for CDR, so I’ll take your query and see if I can’t write something to change the ordering of the outbound trunks based on minutes used.

I was hoping there was an “automatic” way in which Asterisk could be instructed to do that itself, but apparently not!

  • Paul