Asterisk billing
Created by: oej,Last modification on Thu 29 of May, 2008 [09:53 UTC] by JustRumours
Asterisk CDR Fields
Asterisk generates a CDR (Call Detail Record) for each call. By default, records are stored in comma-separated value file will be created in /var/log/asterisk/cdr-csv. You can specify account codes and AMA (Automated Message Accounting) flags on a per-channel (Zaptel et al) or per-user (IAX, SIP) basis to help with accounting. Look at the top of cdr/cdr_csv.c to see the format for the records.
Page Contents
- Asterisk CDR Storage Methods
- Applications
- Limitations
- Least cost routing (LCR)
- Pre-paid applications
- Post-paid (billing)
- PayPal - IPN - Subscription VoIP Billing Solutions
- Asterisk Billing Resources
- astCDRview:
- AstPP:
- CenIP SoftSwitch:
- Cybex Development VoIP Billing System
- MOR - advanced billing solution for Asterisk
- Omniware Billing System
- YakaVOIP- Integrated web billing solution for Asterisk
- Datatex Dynamics
- Super Technologies - VOIP Billing Solutions
- Vidanetwork Technologies - VOIP Billing Solutions
- Calls Professional for Asterisk PBX - InterAkt Co.
- vspPanel - Integrated Asterisk Billing Solution & Control Panel
- See also
Fields
- accountcode: What account number to use: Asterisk billing account, (string, 20 characters)
- src: Caller*ID number (string, 80 characters)
- dst: Destination extension (string, 80 characters)
- dcontext: Destination context (string, 80 characters)
- clid: Caller*ID with text (80 characters)
- channel: Channel used (80 characters)
- dstchannel: Destination channel if appropriate (80 characters)
- lastapp: Last application if appropriate (80 characters)
- lastdata: Last application data (arguments) (80 characters)
- start: Start of call (date/time)
- answer: Anwer of call (date/time)
- end: End of call (date/time)
- duration: Total time in system, in seconds (integer), from dial to hangup
- billsec: Total time call is up, in seconds (integer), from answer to hangup
- disposition: What happened to the call: ANSWERED, NO ANSWER, BUSY, FAILED (on some CDR backends, e.g. ODBC, these may be integers; note that more detailed info can be found in the dialplan variable $HANGUPCAUSE)
- amaflags: What flags to use: see amaflags: DOCUMENTATION, BILLING, IGNORE etc, specified on a per channel basis like accountcode.
- user field: A user-defined field, maximum 255 characters
In some cases, uniqueid is appended:
- uniqueid: Unique Channel Identifier (32 characters)
Asterisk CDR Storage Methods
- Asterisk cdr csv - Text files with comma separated values
- Asterisk cdr SQLite - CDR records to SQLite database
- Asterisk cdr pgsql - CDR records to PostgreSQL databases
- Asterisk cdr odbc - CDR records to any database that unixODBC supports
- Asterisk cdr mysql - CDR records to MySQL databases
- Asterisk cdr FreeTDS - CDR Records to MS SQL or Sybase database through FreeTDS drivers
- Asterisk cdr yada - CDR records to any database that yada supports
- Asterisk cdr manager - CDR Records to manager API
- cdr_shell - 3rd party solution that executes a script with the cdr data in its argv[] 0-18
- Asterisk cmd DBQuery - CDR Backend to store cdr data into a MySQL database by the use of a customizeable Query.
Account codes and flags are set in the various channel configuration files or in the extension definition in extensions.conf.
Applications
- Asterisk cmd SetAccount: Set account code for billing
- Asterisk cmd SetAMAFlags: Set AMAflags for this call
- Asterisk cmd ForkCDR
- Asterisk cmd NoCDR: Make sure no CDR is saved for a specific call
- Asterisk cmd ResetCDR: Reset CDR
- Asterisk cmd Authenticate - Authenticates and sets the account code
- Asterisk cmd SetCDRUserField - Set CDR user field
- Asterisk cmd AppendCDRUserField - Append data to CDR User field
Limitations
- A CDR record will not be created if you use a .call file that calls an application instead of an extension. Workaround: Use an extension that then starts the desired application. See also: Bug report 240
- You can't use exten => h, if you have any hope of getting accurate billing info. Its wise to call ResetCDR(w) in your exten => h, or not use it at all.
Important note on transfers
In general: As soon as transfers (or parked calls that were resumed) come into play, be it attended, blind or through SIP REFER, it is very likely that you will end up with incorrect and misleading CDR data; see bug 11093 and CDR behaviour changes in 1.4.IAX: If you are trying to collect records on IAX to IAX calls you need to be aware that by default, IAX will attempt to transfer calls in this situation (if DTMF is not required). When the transfer is completed the call is dumped from the middle machine and thus the call detail records will report a short call time. If you want detailed records you must turn off IAX transfer (transfer=no in 1.4 or notransfer=yes in 1.2), but unless your servers are very close together, you will definitely get a latency hit from doing so.
Background info on confusing CDRs
The core of Asterisk is a threading model but a very conservative one. Only origination channels and channels executing an application have threads. The B leg of any call operate only within the same thread as the A leg and when something happens like a call transfer the channel must first be transferred to a threaded mode which often times includes a practice called channel masquerade, a process where all the internals of a channel are torn from one dynamic memory object and placed into another. A practice that was once described in the code comments as being “nasty”.The same went for the opposite operation the thread was discarded by cloning the channel and letting the original hang-up which also required hacking the cdr structure to avoid seeing it as a new call. One will often see 3 or 4 channels up for a single call during a call transfer because of this.
For Asterisk 1.6 (or later) we might see a completely re-designed method to generate and store CDR data.
Least cost routing (LCR)
Especially for EU countries and small offices/home offices: Since the introduction of Call-By-Call (and Carrier Pre-selection) things have become both a lot cheaper and more complicated. The VoIP providers that offer IP-to-phone services add to the complexity of finding the cheapest route for a call. Finally there's the emerging ENUM system.Implementing LCR functionality in Asterisk can be accomplished without too much effort using AGI and a mySQL backend
- Application LCDial Asterisk third-party add-on. Adds LCDial() command, which is just like Dial() but looks up the dialed number in a database, to find a dial-string for that destination.
- LCR tool for i4l: Collection of LCR a variety of LCR tools for Asterisk, i4l etc
- cnum.info realtime Call-by-Call rates for the german market provided as ENUM service
- ZIDial Adds ZIDial() command.Low cost routing with multiple redial (on each route), also multiple redial for multiple provider.
Pre-paid applications
If you have users that you have little or no contact with, or where fraudulent usage can be an issue, it might be worth looking at Pre-paid solutions. With the pre-paid model we need to access a users funds before the call is made in order to see how much cash is available for the call to be made. Next, once the call destination is known, we should start a timer to disconnect the call (or more userfriendly, interrupt the call with an announcement) and finally close the deal.Some considerations when creating a calling card application:
- take care of multiple calls using the same credentials (PIN or username)
- the SIP protocol does not allow for recognition of a client that was disconnected
- cut off the call when the credit has dropped to 0
- the hard part is to correctly rate a call, e.g. attaching the correct tariff
See: Asterisk Prepaid Applications
Post-paid (billing)
The Call Detail Record
Asterisk generates CDR (Call Detail Records) that contain data about which extension made or received calls to or from which number for how long. These records are generally stored in plaintext logfiles located in /var/log/asterisk/cdr-csv, but can also be stored in PostgreSQL or (with the asterisk-addon package) MySQL databases.
Rating the CDR
Since Asterisk does not know about its location or the deals the machine has with Telco providers (your PSTN line or perhaps a VoipJet, NuFone, VoicePulse or IConnectHere account), so it cannot know the cost of each call. To solve this problem the CDR's need to be 'rated'. On each combination of parameters you could technically assign a buyers price and a sellers price. This process is generally called 'rating'.
Billing the users
Only when we have neatly rated CDR's the billing process can start, but this is now a reasonably simple process of accounting all prices linked to an account code or source or destination.
Software out there
There are probably some very decent commercial rating/billing packages out there, but only very few open source ones. Most notably there is Trabas Billing, however the Trabas company seems to be taking further development on the software back from the community.
PayPal - IPN - Subscription VoIP Billing Solutions
- Free PayPal - IPN and PayPal - IPN Subscription Starter Kit Software
- VanAbel.Com -- Free PayPal - IPN Starter Kit
- VanAbel.Com -- Free PayPal - IPN Subscription Starter Kit
- These applications, while not originally written for VoIP back in 2000-2001, can provide excellent insight into using PayPal for small to medium size VoIP businesses.
- Sorry, we can not offer support for free applications.
Asterisk Billing Resources
- INOVAWARE CORPORATION VOIP-Pro http://www.inovaware.com/voip/voip.htm Scalable, robust, full-featured, low-cost billing, rating, provisioning, customer care and help desk software solutions for VoIP carriers of all sizes. VOIP-Pro is pre-integrated with Asterisk platforms.
- Asterisk Billing Software
Free information, guides, and resources to help locate the best Asterisk Billing software for your company.
Streamco Switchboard
Free routing+billing VoIP system based on Asterisk. Suites well for reseller/wholesale and pc2phone business. User-friendly web interface. Flexible routing(lcr, code length, time of the week, priorities...). Financial Module allows to automatically disable customers or end users basing on their balance. Accounting(payments,invoices) is tightly coupled with billing/routing.
Real-time billing. Web interface allows to configure, check dialplan, view active calls and view statistics with selected granularity. High performance. Written in C++.
Real-time billing. Web interface allows to configure, check dialplan, view active calls and view statistics with selected granularity. High performance. Written in C++.
astCDRview:
astCDRview is an open source, licensed under GNU/GPL, lightweight, Web-based, multi-language Asterisk SQLite CDR viewer that supports multiple outgoing carriers, multiple incoming numbers, billing, an address book, and extensions
AstPP:
AstPP is not only a web-based, user friendly billing interface for Asterisk and VOIP. It is also provides a gui editor for REALTIME devices and dialplans. AstPP is Open Source and under constant development. Prepaid, Postpaid and Calling Cards supported as well as resellers, lcr, callbacks,etc.
CenIP SoftSwitch:
CenIP VirtualServer is a full-featured platform for VoIP billing. It provides routes/customers/devices gui manager with support for prepaid, postpaid, callingcard, resellers, lcr, dids and a lot more.
Cybex Development VoIP Billing System
Prepaid & PostPaid Included. Wholesale, End-User, Calling Cards.
We provide the lowest price.
We provide the lowest price.
MOR - advanced billing solution for Asterisk
- More info: MOR
- Homepage: http://www.kolmisoft.com/mor
User friendly/presentable billing. Huge amount of functions. LiveCD available.
Omniware Billing System
Operates a hosted billing system services for ITSPs and ISPs. Also offered as standalone product. Used in two deployments by Bell Canada, and designed to be very flexible.
YakaVOIP- Integrated web billing solution for Asterisk
- Homepage: http://www.yakasoftware.com
YakaVOIP is a fully integrated, open-source -NOT FREE-, web-based, user friendly billing and administration interface for Asterisk and Voice-Over-IP. It leverages existing open-source technologies (Joomla, PHP, MySQL) and ecompases 3rd party payment gateways like Paypal, MyGate, Moneybookers & Google Pay.
Datatex Dynamics
Datatex has been developing software solutions for the telephony industry since 1999.
Topaz Next Generation (TNG)
TNG is the latest Telephone Management System (TMS) or billing system released.
The Asterisk version of TNG has the following features:
TNG is the latest Telephone Management System (TMS) or billing system released.
The Asterisk version of TNG has the following features:
- Generates a call record for each part of a transferred call. (e.g. call transferred 5 times will show 5 call records
- Calls transferred or forwarded to queues will properly show the extension the call ended up on.
- Transferred unanswered calls properly identified.
- Runs on Windows or Linux.
- Connects to the standard Asterisk Manager Interface.
- Report drill down from summary level to detailed calls.
- Report scheduling to email reports automatically.
Super Technologies - VOIP Billing Solutions
^ Super Technologies has been in VOIP service since 1999. Was the first companyin the world to offer a DID number on a IP Device similar to vonage, and got an award
on the service from Internet Telephony Magazine and in the Internet Wrold Show in 2001.
With this experience and software in use for over 5 years now, they are now offering
the same software that they use for their own services, to the world to offer billing to their clients.
They have software for VONAGE Type Service, Net2phone and ip centrex services, sample are all working and live
you can check them out on www.phoneopia.com www.superphoneunlimited.com and ip-pabx.com
Web site for software is www.supertec.com/solutions/
Vidanetwork Technologies - VOIP Billing Solutions
http://www.vidanetwork.net - Powerful billing system that allows you to setup Pre-pay, Post-pay, metered Flat Rate billing plans for residential and Cooperations. Their scalable network management and billing system integrate multiple Asterisk call servers together to work like one system. The web-based solution has 4 levels of access interfaces: Administrator, Operator, VPBX admin, and End User Portal. It also offers Hosted Virtual PBX and Virtual Call Center solutions for offering services to business users. If you already have a Web page and a payment gateway account (like Paypal), they can also integrate them with their software, so that your customers could sign up your services from your web page and make payments online.If you are service providers and would like to offer services to residential and business users, this is definitely the right solution for you!
Calls Professional for Asterisk PBX - InterAkt Co.
Calls Professional for Asterisk PBX - Calls Professional is a program suite, which is designed to manage call statistics and greater review in telephone network. It includes programs Asterisk CDR server and Calls Professional. CDR Server is used to collect data of calls from Asterisk PBX, user settings and program activity, Calls Professional is multi purpose / multi user program for reviewing, making print outs and export call reports. The latter possibility is to create own phone book, and includes a whole palette of other useful settings. Program packet is ideal expedient for traffic control in telephone network and control of expence in company or any other organization.vspPanel - Integrated Asterisk Billing Solution & Control Panel
vspPanel - Asterisk Control Panel - vspPanel is a full control panel system for the Asterisk PBX and has been designed as a "VSP In A Box" solution, much like it's counterpart CPanel in the Web Hosting Industry vspPanel allows users to control all aspects of their Asterisk server from a web interface, along with call routing, adding of providers and customers and most importantly billing (Both Pre-paid and Post-Paid). vspPanel does not require any additional hardware and is already begining to be offered in Data Centers around the world as a VOIP Provider Hosted Solution, however it may be installed on any Linux Server along with Asterisk. vspPanel has been designed to allow any entreprenuer to become a VSP and offer VSP services to their customers and alleviates the need for an operator to be a "technical guru".Current Status: Free Beta Available.
Screenshots of vspPanel in Action: http://www.vsppanel.com/screenshots.html
See also
- VOIP Billing
- Open Source Billing Systems
- Asterisk Prepaid Applications
- CDR mediation
- Asterisk addon rate-engine: An alternative billing solution from Trollphone
- Commercial: http://www.vidanetwork.net - Asterisk turnkey solution for service providers, like Vonage.
- Asterisk CDR Areski GUI - PHP GUI for MySQL/PgSQL CDRs
- Asterisk CDR Jon - Perl GUI for CSV CDRs
- Simple Perl script for a basic calling card application
- Asterisk callingcard application by Bartosz Jozwiak (C, designed for PostgreSQL)
- Asterisk CDR csv conversion mysql
- Asterisk CDR csv mysql import
- Asterisk CDR csv handling
- AstBill - Billing, Routing and Management software for Asterisk and MySQL.
- ASTPP - Open Source VOIP Billing for Asterisk
- AsterBill - Asterisk Billing
- Aeolos Call Accounting A CDR reporting and billing tool supporting the Asterisk PBX. Targeted at SOHO and SME Asterisk setups
- CDRtool: Tool to access CDR records generated by SER, Cisco or Asterisk (RADIUS protocol) - by Adrian Georgescu, free for non-commercial use
- Asterisk administration
- Call Accounting Software
- Hotel/Call Shop Billing system - IPSwitchBoard
- Asterisk Billing Software - Alepo
- AgileVoice VoIP Billing and Provisioning - The ultimate "agile" Asterisk billing and provisioning application for VoIP providers, as it will expand to fit your needs - no matter how small your business is or how large it becomes. For Broadband phone providers, PC to Phone providers, Wholesale providers, IP Centrex, Calling Cards.
- Algorithm to parse country code out a phone number
- Asterisk VOIP AAA Software Aradial - Aradial
- Asterisk: config files | channels | variables | FAQ | CLI | introduction | tips & tricks
- AMS - Open Source Billing and management system (including recording interface)
Comments
333Call Forwarding and CDRs
I have the same problem like with transfer when Call Forwarding is used.
Here is extract from my extensions.conf
macro-stdexten<br>
;
- Standard extension macro (with call forwarding)
-
; ${ARG1} - Extension(we could have used ${MACRO_EXTEN} here as well; ${ARG2} - Device(s) to ring
;
exten => s,1,Set(temp=${DB(CFIM/1${MACRO_EXTEN})})
; Chech Unconditional Forward
exten => s,n,GotoIf(${temp}?cfim:nocfim)
exten => s,n(cfim),SetVar(CALLERID(num)=1${MACRO_EXTEN}) ; change CallerID
exten => s,n,SetVar(CALLERID(name)=${MACRO_EXTEN}) ;
exten => s,n,Dial(local/${temp}@${MACRO_CONTEXT}/n) ; Unconditional
forward
exten => s,n(nocfim),NoOp
; Check No Answer Forward
exten => s,n,Set(temp=${DB(CFNOANS/1${MACRO_EXTEN})})
exten => s,n,GotoIf(${temp}?cfnoans:nocfnoans)
exten => s,n(nocfnoans),Dial(SIP/${MACRO_EXTEN},,tT)
exten => s,n(cfnoans),Dial(SIP/${MACRO_EXTEN},15) ; 15sec timeout
exten => s,n,GotoIf($${DIALSTATUS}=NOANSWER?noanswer:another)
exten => s,n(noanswer),NoOp
exten => s,n,Dial(local/${temp}@${MACRO_CONTEXT}/n) ; Forward on noanswer
A calls to B. On B is Call Forwarding Unconditional to C. A and C converse.
A: 13401539
B: 13401538
C: 3328130
In CDR I get two strings:
1."","13401538","3401538","full","""3401538""
<13401538>","SIP/3401539-08703000","Local/3328130@full-3b95,1","Dial","local/332
8130@full/n","2007-04-11 15:47:58",,"2007-04-11 15:48:00",2,0,"NO
ANSWER","DOCUMENTATION"
Like B called to B.
2. "","13401538","3328130","full","""3401538""
<13401538>","Local/3328130@full-3b95,2","SIP/217.199.224.24-0870d000","Dial","SI
P/3328130@217.199.224.24|90","2007-04-11 15:47:58",,"2007-04-11
15:48:00",2,0,"NO ANSWER","DOCUMENTATION"
Like B called to C
But really I want to get such strings:
1. A called to B.
2. B called to C.
333blind transfers and CDRs
for example A calls B, B transfer the call to C, A and C converse then hang up
in CDR you have only one call from A to C, so if A and B are outside your network, and B is inside, so you should bill him, its transfered calls won't be billed because you have no trace of such calls; according to CDR these calls are outside calls to outside...
Do somebody have any idea on how to get rid of such problems
Thanks
333BILLING
333sunsaturn
333Hold Time
333call quotas
exten => 888,1,Playback(astcc-tone) ;
exten => 888,2,Authenticate(9955,a)
exten => 888,3,NoOp(${ACCOUNTCODE})
exten => 888,4,MYSQL(Connect connid localhost myusername xxxxxx astcc_user)
exten => 888,5,MYSQL(Query resultid ${connid} select\ bal-time_used\ "bal"\ from\ user\ where\ id\ ="${ACCOUNTCODE}")
exten => 888,6,MYSQL(Fetch more ${resultid} bal)
exten => 888,7,GotoIf($${more} != 1?8:6)
exten => 888,8,MYSQL(Clear ${resultid})
exten => 888,9,GotoIf($[${bal} 888,10,Dial(IAX2/guest@misery.digium.com/s@default,,gL(${bal}:6000:3000))
exten => 888,11,GotoIf($"${ANSWEREDTIME}" != ""?13) ;skip over next line if ANSWEREDTIME not null
exten => 888,12,SetVar(ANSWEREDTIME=0); if ANSWEREDTIME is null set it to 0
exten => 888,13,MYSQL(Query resultid ${connid} update\ user\ set\ time_used\ =time_used+${ANSWEREDTIME}\ where\ id\ ="${ACCOUNTCODE}")
exten => 888,14,Goto(16); skip over next line from here
;got to this line only if not enough minutes
exten => 888,15,Playback(astcc-notenough) ; not enough to make call
exten => 888,16,MYSQL(Disconnect ${connid})
333Mysql with Asterisk
I have instaled the Mysql 4.0, mysql-devel, mysql-client, phpmyadmin2.5.7.
Please urgent!!!
333How to enable storing of the field UniqueID
Q: It would appear that the "uniqueid" field is not being populated in the MySQL CDR DB.. Is this an obsolete field or is a bug?
A: You need to define MYSQL_LOGUNIQUEID at compile time for it to use that field.
You have two options in /usr/src/asterisk-addons:
1. Add a CFLAGS+=-DMYSQL_LOGUNIQUEID to the Makefile.
2. Add a #define MYSQL_LOGUNIQUEID to the top of the sourcefile.
Finally perform the usual make clean, make, make install. Be sure to check the Makefile for the presence of this flag after having done a CVS update!
333AMAFLAGS values
default
omit
billing
documentation
333See also: Authenticate()
Authenticate(1234|a)