Sunday, November 23, 2008

Rates setting in asterbilling for asterisk billing

There are three rates in asterBilling, reseller rate, callshop rate and customer rate.

  • reseller rate: the rate admin sell to reseller
  • callshop rate (group rate): the rate reseller sell to callshop (group)
  • customer rate: the rate callshop sell to customers

Rates in asterBilling could be inherited, for example, here’s two records in resellerrate

dialpreifx = 0086
number length = 0
connect charge = 0.2
init block = 60
rate = 0.2
billing block = 60
resellerid = 0

dialpreifx = 0049
number length = 0
connect charge = 0.4
init block = 60
rate = 0.4
billing block = 60
resellerid = 0

Because we dont specify which reseller is this rate for (resellerid = 0), this rate could be used for all resellers.  So what if some resellers want to change this rate rather than use this “default” rate? quite simple, just add another rate for the reseller:

dialpreifx = 0086
number length = 0
connect charge = 0.2
init block = 60
rate = 0.2
billing block = 60
resellerid = 1

so for this reseller (resellerid=1), when customer dial a number begin with 0086, it will use this new rate, we  can call it “overwrite”, but for other resellers who dont set their rate, it would use the one admin setted.

Just like reseller rate, group rate could also be inherited.

A:
dialpreifx = 0086
number length = 0
connect charge = 0.2
init block = 60
rate = 0.2
billing block = 60
resellerid = 1
grouprid = 1

B:


dialpreifx = 0086
number length = 0
connect charge = 0.4
init block = 60
rate = 0.4
billing block = 60
resellerid = 1
grouprid = 0

C:

dialpreifx = 0086
number length = 0
connect charge = 0.4
init block = 60
rate = 0.4
billing block = 60
resellerid = 0
groupid = 0

so rate C is a rate for all reseller and all group,  rate B is for all groups in reseller 1, rate A is only for group 1.

Through inherit rate, admin could be much easier to control the rates, like just set one rate for all resellers, and adjust some when they require some difference, also reseller could just set one rate for his callshops, and only do minor change to provide different rate plan.

Posted by solo at 04:57:55 | Permalink | No Comments »

asterbilling and asterisk2billing (a2billing) for asterisk billing

a2billing is a widly used billing system, so what’s the difference between a2billing and asterbilling?

system theory:

a2billing work with asterisk through AGI, each call would be handled by a2billing.agi, so you need change your astierks context so that when your phone make calls it will go to a2billing.agi, of course you need to copy a2billing scripts to your asterisk server.

asterbilling runs as linux daemons, connect to asterisk via AMI over tcp,  no need change anything on your asterisk, asterbilling can bill it. Even asterbilling could work with a2billing.

license & free:

a2billing: 100% open source and free to use.

asterbilling: only web scripts are open source, and provides 5 free simultaneous channels, have to purchase when need more channels.

performance:

a2billing: like 100 simultaneous calls on single server? i didnt test, :(

asterbilling: passed 240 simultaneous calls testing, but didnt test more.

best usage:

a2billing: calling card, callback or wholesale solutions

asterbilling: billing for embedded astiersk, pbx (like all freepbx based system), callshop, hosted callshop soltution

other keywords:

a2billing: openser

asterbilling: realtime billing, reseller

Posted by solo at 04:55:33 | Permalink | No Comments »

Thursday, February 28, 2008

get realtime CDR to your mysql from asterisk

Many a time we want to know who is calling and how long it lasts, but asterisk only provide our the cdr when the call is finished, we have to use some agi script or special dialplan to get the real time data, but now we could use “astercc” to get the data in real time no matter what’s the dialplan in your system, which means we can get CDR in real time from any asterisk based system.

astercc works as a daemon in linux, it get events from asterisk AMI and store the CDR to two mysql table.
the first table is “curcdr” which will store all simultaneous calls, when call starts there would be a new record in the table, and when it stops, the record would be removed to another table “mycdr”

the record could be:

mysql> select * from curcdr;
+——+——+———-+—————+—————–+———————+———————+—————–+—————–+————-+———+——–+——–+—————-+—————-+————-+
| id | src | dst | srcchan | dstchan | starttime | answertime | srcuid | dstuid | disposition | groupid | userid | credit | callshopcredit | resellercredit | creditlimit |
+——+——+———-+—————+—————–+———————+———————+—————–+—————–+————-+———+——–+——–+—————-+—————-+————-+
| 3880 | 8807 | 8806 | SIP/8807-6fc2 | SIP/8806-d962 | 2008-02-28 12:26:01 | 2008-02-28 12:26:10 | 1204172801.3813 | 1204172801.3814 | link | 0 | 0 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| 3881 | 8000 | 84350822 | SIP/8000-1684 | SIP/trunk1-a73d | 2008-02-28 12:26:13 | 0000-00-00 00:00:00 | 1204172812.3815 | 1204172813.3816 | dial | 0 | 0 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
+——+——+———-+—————+—————–+———————+———————+—————–+—————–+————-+———+——–+——–+—————-+—————-+————-+

and the record in mycdr could be

mysql> select * from mycdr order by id desc limit 0,2;
+——+———————+——+———-+—————+—————–+———-+———+————-+————-+———–+—————–+—————–+———-+——–+—————-+—————-+———+——–+
| id | calldate | src | dst | channel | dstchannel | duration | billsec | disposition | accountcode | userfield | srcuid | dstuid | calltype | credit | callshopcredit | resellercredit | groupid | userid |
+——+———————+——+———-+—————+—————–+———-+———+————-+————-+———–+—————–+—————–+———-+——–+—————-+—————-+———+——–+
| 3682 | 2008-02-28 12:26:13 | 8000 | 84350822 | SIP/8000-1684 | SIP/trunk1-a73d | 5 | 0 | NO ANSWER | | UNBILLED | 1204172812.3815 | 1204172813.3816 | | 0.0000 | 0.0000 | 0.0000 | 0 | 0 |
| 3681 | 2008-02-28 12:24:40 | 8806 | 8807 | SIP/8806-c36f | SIP/8807-0139 | 8 | 6 | ANSWERED | | UNBILLED | 1204172719.3811 | 1204172720.3812 | | 0.0000 | 0.0000 | 0.0000 | 0 | 0 |
+——+———————+——+———-+—————+—————–+———-+———+————-+————-+———–+—————–+—————–+———-+——–+—————-+—————-+———+——–+
2 rows in set (0.00 sec)

so if you want to get real time cdr datas from your asterisk for your application, you can try astercc, it provide 5 free channels, means it could catch 5 simultaneous calls in your asterisk, it has been tested that astercc could catch as much as 240 simultaneous calls.

astercc daemon could be download from http://sourceforge.net/project/showfile … _id=202441, if you only want to get the calls information, you just need astercc and astercc.conf in directory daemon in the package

Posted by solo at 13:10:03 | Permalink | No Comments »

Tuesday, January 29, 2008

two new features in astercc

1. two level billing, administrator -> callshop -> customer
2. profit report
Posted by solo at 03:07:08 | Permalink | No Comments »