Category Archives: A2Billing

A2Billing Asterisk billing application

A2Billing advanced troubleshooting

This is intended for advanced users – please see here for general A2Billing troubleshooting tips –

Sometimes it can be really useful to figure out what’s going on behind the scenes in A2Billing. This is useful for tracking down bugs.

It’s very unlikely you’d want to do this unless you have a good understanding of editing Linux files, PHP and MySQL.

To find out what queries A2Billing is running when we look at things in the GUI we can turn on “PHP Quick Profiler”

On a SysAdminMan VPS you turn this on by editing the file –


Continue reading

Troubleshooting common A2Billing problems

I see customers having the same issues with A2Billing so thought I’d do a list of the most common ones. This list must account for at least 90% of the issues I see. This list applies where A2Billing is installed correctly, but you’re having issues making calls.

Does the call work in the simulator?

The first thing to check is whether the call works OK in the A2Billing call simulator. You can find out how to do this here –

If the call does work OK in the simulator then it’s likely your customers and rate cards are setup correctly and the issue is with your trunk. If the call works OK in the simulator then check your outbound trunk is setup correctly and that you have call credit with your call provider.

If the call doesn’t work in the simulator then check out this list of potential problems …

Is the number in the correct format?

When your customers dial the number they want to call they could do it in a variety of formats. For example when calling a number in London where the country code is 44 and the city code is 20 they might dial –

  • 00 44 20 XXXX XXXX  – international format when calling form the UK
  • 011 44 20 XXXX XXXX  – international format when calling from the US
  • 44 20 XXXX XXXX  – international format with no international access code
  • 020 XXXX XXXX  – local dialling from within the UK

So there are lots of ways the number could be dialled, but the number will be in your A2Billing rate cards in a particular format. You need to ensure when the number is matched against the rate card it is in the correct format. It’s easy to confirm if this is the issue by entering the number in the simulator in the same format it is in your rate cards.

It does depend a little on your circumstances but I normally recommend customers have their rate cards formatted as number 3 in the list above, just starting with the country code, not an international access code.

The international access code can be removed from the number called by …

Setting Yes to “Remove International Prefix” on the rate card –

remove international prefix

Setting the numbers that should be removed on the agi-conf being used –

international prefixes
Continue reading

Using a GoIP for an A2Billing access number

This post follows on from the one on using the GoIP for outbound calls

You should check that post for some general advice. We are going to use the same software and devices for this guide. This guide was written using a clean SysAdminMan VPS –


Setting up the trunk in Asterisk is the same as for outbound calls, apart from we are going to set a ‘context’ to pass the incoming call to A2Billing. These lines are added to /etc/asterisk/sip_custom.conf –


Continue reading

Using a GoIP with A2Billing for outbound calls

This is a quick guide to using a GoIP GSM gateway with A2Billing as an outbound trunk. It doesn’t go through setting up rate cards and customers in A2Billing, guides for that are already available on this site.

First some general info and tips.

This guide was written using the following. The thing most likely to cause issues is a SIP ALG in your router. NAT issues are a pain to track down!

Continue reading

New GoIP (GSM to SIP gateway)

For quite a while now I’ve had lots of enquires from customers wanting to use a GoIP with A2Billing on their SysAdminMan VPS. So I thought I’d order a test one and write some documentation!

A GoIP is a small box that accepts a full size GSM SIM. It can then take Asterisk/SIP calls and send them via a mobile phone provider, or pass incoming mobile calls to Asterisk.

I ordered from this e-bay seller on 23/11/13 – and the GoIP was delivered today, 10 days later.


It was delivered with a 2 pin (rather than UK) plug which is no great surprise. So you’ll need a power adapter for it. Alternatively you could use a different power adapter, which is 12v 500mA output.

A couple of things to consider if you are thinking about trying a GSM/SIP gateway –

  • You are likely breaking your mobile operators terms of service. If you abuse it be prepared to be disconnected!
  • You will not be able to pass a caller ID to the GSM network. The person being called will see either the SIM card caller ID, or no caller ID

Asterisk and A2Billing software update

The software versions on the SysAdminMan templates have been updated as follows …

SysAdminMan FreePBX

  • CentOS 5.10
  • Asterisk 11.6
  • FreePBX 2.11

SysAdminMan FreePBX & A2Billing

  • CentOS 5.10
  • Asterisk 11.6
  • FreePBX 2.11
  • A2Billing 2.0.7

SysAdminMan FreePBX & A2Billing & OpenVPN Server

  • CentOS 5.10
  • Asterisk 11.6
  • FreePBX 2.11
  • A2Billing 2.0.7
  • OpenVPN Server

All new servers will be deployed with the software versions above. See here to order –

Asterisk outbound call status page

I recently wrote this as a simple web page to show the current calls in progress on an Asterisk PBX. It was written for an A2Billing system.

It just runs a ‘core show channels concise’ and then shows lines that contain certain text. By default it shows lines that are ‘Up’ and running the ‘Dial’ application, but this could be changed. It uses twitter bootstrap to add some formatting to the table.

The div containing the table is refreshed every 3 seconds. This is what it looks like –

SysAdminMan active calls

Continue reading

A2Billing useful MySQL queries

I am not condoning anyone who does not understand MySQL or the internal workings of A2Billing to be messing around with MySQL commands; however occassionally you do need to, to save yourself a lot of time and effort. I’m intending to update this page with MySQL commands for specific jobs as I work them out, for my future reference mostly.

I’ve posted before about various A2Billing MySQL queries, so this is a down-and-dirty page of commands, not a full explanation of what each does or why you might need them.

Here’s the first one:
You have 2 tarrifs setup, and you need to change the sellprice of all the rates in tariff 2 to match those of tariff 1:

use mya2billing;
update cc_ratecard as a, cc_ratecard as b
set a.rateinitial = b.rateinitial where a.dialprefix=b.dialprefix and a.idtariffplan=2


Next up it’s bills. How to find out the total bill for calls ever, for all customers?

use mya2billing;
select sum(sessionbill),card_id, stoptime from cc_call group by card_id

And similaly to get the unbilled usage (assuming a billing date of 1st of the month):

select sum(sessionbill),card_id, stoptime from cc_call where stoptime >
DATE_FORMAT(LAST_DAY(DATE_SUB(NOW(), INTERVAL 0 MONTH)),'%Y-%m-01 00:00:00')  group by card_id

Next is useful sort of query – it gives you the outgoing calls made by a customer between 2 dates, and finds the name of the destination as well as naming the columns for a nicely exportable CSV from MySQL Workbench:

select cc_call.starttime as "Time",cc_call.sessiontime as "Seconds",cc_call.calledstation as "Called Number",cc_call.sessionbill as "Cost",cc_call.src as "Source",cc_prefix.destination as "Destination" from cc_call left join cc_prefix on cc_call.destination=cc_prefix.prefix where cc_call.card_id = "1" and cc_call.starttime between '2015-02-01 00:00:00' and '2015-03-01 23:59:00' order by cc_call.starttime DESC;

Note this query has been updated to account for your destinations not being complete (IE some may not have a name, and would not have shown up in your list).

Manually adding customer payment in A2Billing

If you use Post Pay customers in A2Billing then you have 2 options for maintaining the customers credit limit and balance. You could invoice the customer directly from A2Billing but it can be complex to set up and many businesses already have an invoicing system in place.

The other option is to invoice the A2Billing customer on an external billing system, and then credit the A2Billing account manually on receipt of payment. You will want to credit the A2Billing account or once the customer reaches their credit limit they will be unable to make calls.

Setting up the customer as Post Pay and their credit limit is done when creating the A2Billing account –

Once you have invoiced the customer for their calls and received the payment you will want to credit the account  by going to BILLING / Refills –

and then clicking Add Refill on the right hand side –

Once there enter the customer ID, amount to refill and select No to creating an invoice –

A2Billing refill information

That payment should then get added to the customers balance.

A2Billing – invalid rate card expiry date 0000-00-00

Recently I’ve had a few calls about rate cards in A2Billing not working as expected. Everything looked good except the expiry date on the rate card was showing as 0000-00-00 00:00. This caused the rates in that rate card not to be evaluated as part of the call plan.

It looks like this is caused by a limitation in 32 bit Linux with the last date able to be represented as 19 January 2038. See here for more information about this –

When you create a new rate card, A2Billing tries to add 25 years to the current date to generate the expiry date for the rate card. Since 19 January 2013 this would have taken it past the last valid date in 32 bit Linux – causing the 0000-00-00 00:00

Continue reading