Category Archives: Asterisk

Asterisk OpenSource PBX

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

Asterisk call drops after 30 seconds – SIP disallowed_methods

I had a customer today struggling with an issue where certain incoming calls were being automatically dropped after around 30 seconds. They did some debugging and found the solution that I thought I’d share.

In this case it only affected incoming calls to an IVR, but I’ve since read other reports of it affecting certain outgoing calls. It’s caused by a call provider ignoring SIP UPDATE messages sent by Asterisk. After a certain number of these messages are ignored the call gets disconnected.

You can only really tell if this is the cause of the call being disconnected by capturing the SIP packets and checking what’s going on but the SIP UPDATE messages can be disabled in Asterisk by adding –

disallowed_methods=UPDATE

to the SIP trunk in question.

At least 2 providers that seem to do this are CallCentric and Spitfire. For more information see here – http://forums.asterisk.org/viewtopic.php?f=1&t=80237

Another possible cause of calls dropping are SIP session timers

AstriCon – the place to be for Asterisk users, developers and implementers

This year the 10th Annual AstriCon is being held in Atlanta from the 8th – 10th October.

If you use Asterisk in your organisation, or implement Asterisk for other organisations, then AstriCon is packed full of useful sessions on current usage possibilities and the future direction of Asterisk.

There are also lots of sessions regarding Asterisk/VoIP security, which everyone should be paying attention to!

For more information check out the AstriCon website – http://www.asterisk.org/community/astricon-user-conference

If you decide to book then use the special promo code “AC13BLO” for a 20% discount on the price of an AstriCon pass

Integrating Asterisk, FreePBX and vTiger

vTiger is a free, fully-featured open source CRM solution that can be used to manage your customers and sales leads. It can also integrate with Asterisk to provide click-to-call and call notification from within vTiger itself.

While the Elastix distribution comes with both Asterisk and vTiger installed it may not be desirable to have your CRM and VOIP system running on the same server for performance reasons. You don’t want vTiger interfering with the call quality. Also vTiger on Elastix is not normally at the latest version, which has resulted in security issues in the past.

The solution is to run vTiger and Asterisk on different servers. The instructions below were kindly provided by a SysAdminMan customer on the steps required to integrate Asterisk and vTiger. If you want assistance with this please open a support ticket.

This would work well with a SysAdminMan FreePBX server – sysadminman.net/sysadminman-freepbx-hosting.html

1 – Whitelist the vTiger server IP addresses in the Asterisk server firewall

Continue reading

Asterisk control panel for Windows

I came across an interesting project today called AstchannelsLive. It’s a Windows panel for monitoring and managing Asterisk calls in progress. A little like FOP2 but instead of being web based and running on the Asterisk server, it’s a native Windows application.

It was very easy to install, just run the installer and point it at your Asterisk server. You will need to allow the application access to your Asterisk server. If you’re a SysAdminMan customer and want help with this just open a support ticket.

You can see all of the extensions and trunks and perform actions such as park, hangup, transfer etc. I only spent a few minutes testing it, and it’s maybe not the prettiest looking application, but it worked fine and definitely looks promising.

Check it out here – http://www.astchannelslive.com/

AstchannelsLive

Do bear in mind there’s an inherent risk with allowing any software to connect to your Asterisk server.

Asterisk active calls from the command line

Here’s a quick way of keeping track of how many concurrent calls are in progress on your Asterisk system.

From the command line we can run –

asterisk -rx "core show channels" | grep "active call"
10 active calls

That works for Asterisk 1.8 and probably all other versions. It will just report how many active calls are in progress.

If we wanted it with the date and time we could run –

echo `date +"%d/%m/%y %H:%M"` - `asterisk -rx "core show channels" | grep "active call"`

and if we wanted to run it every 5 minutes and write the output to a log we could add it to cron like this –

echo 'echo `date +"%d/%m/%y %H:%M"` - `/usr/sbin/asterisk -rx "core show channels" | grep "active call"`' > /usr/local/bin/asterisk.calls
chmod 700 /usr/local/bin/asterisk.calls
crontab -l | (cat;echo '*/5 * * * * /usr/local/bin/asterisk.calls >> /var/log/asterisk_calls.log') | crontab

and check that it’s now in crontab with –

crontab -l

That should write how many calls are in progress every 5 minutes to a file called /var/log/asterisk_calls.log.
Remember the log file will just keep growing over time if it’s not manually emptied.

Asterisk / FreePBX queue and agent wallboard

This is an update the this post (http://sysadminman.net/blog/2012/asterisk-elastix-queue-and-agent-wallboard-3604) which had some code for a basic wallboard. This version is updated a little with better handling of some of the output from Asterisk. It also uses Twitter Bootstrap to make the wall board a little prettier. Here is an example screenshot of the new version –

Asterisk wall board

Continue reading

Customising Asterisk Dialplan for dummies

Today’s (this week’s!) project was to try to allow users to dial out from Asterisk, but prefix the phone number so they can dial out ‘as’ someone else. In our case we want to change the outgoing CLI and also the account code, so someone else on our A2Billing system gets billed for the call. The setup is that there are PA’s who take and make calls on behalf of different clients. The clients are to be billed for any calls a PA makes on their behalf.

The idea was to have a prefix per-client, starting *01* for client 1, *02* for client 2 etc. Whilst a database-linked solution would be better, I am not that good with asterisk dialplan yet, nor with PHP, so here is the down-and-dirty method.

One thing I learned whilst looking at the dialplan, a very useful feature is the dumpvars macro. You can add it into a context (such as the macro-dialout-trunk-predial-hook context in our case) to find out what the status of various variables are just where you are trying to program them. You call it like this:

exten => s,n,Macro(dumpvars)

Continue reading

CDR Reports AKA PHP programming 101

So you want to create a customised report from your sysadminman VPS, to email you some call stats maybe once per week? You may find this info invaluable.

Setup: Asterisk 1.8, FreePBX 2.9, sysadminman VPS

Goal: some call stats via email

Originally I had wanted to install something like CDRstats or asternic but this is now a critical VPS and my backups aren’t what they should be… so yes I was scared partly and also when I installed CDRstats on a test system I couldn’t really get it to work properly. So I wrote my own, following on from the very basic database querying I started with in this post.

So I will assume some basic knowledge of programming or at least the ability to copy/paste/edit. Familiarity with HTML would be useful.

I like Notepad++ because I use Windows, and so using WinSCP to connect to the box and then right-click to edit my PHP script was very handy rather than editing in an SSH console via nano. Also the MySQL Workbench allows connection via an SSH tunnel to your MySQL database, so you can check that your MySQL queries are going to work.

Create your script in /var/www/html/admin
Mine is called Weekly-call-stats.php

Continue reading

Asterisk CPU usage at 100% with FreePBX

Yesterday I spent way too long troubleshooting an issue with an Asteirsk server that I hadn’t seen before, so I thought I’d do a short write-up here in case anyone else sees similar symptoms.

The system is running Asterisk 1.8 with FreePBX 2.8 and FOP2.

The symptoms were a little erratic but included –

– CPU for Asterisk process climbed to 100% and stayed there

– FreePBX gave message when trying to Apply Setting regarding a problem with retrieve_conf

– Running ‘sip show peers’ in the Asterisk console would not list any peers (there were around 50)

– Running ‘sip show peers’ again would cause the Asterisk console to freeze

– Asterisk process showed 800mb of VIRT mem usage

– Starting Asterisk would cause 3 or 4 SEGFAULT messages before safe_asterisk finally managed to start the Asterisk process

What I tried to resolve the issue –

– Upgraded Asterisk to the latest 1.8 release made no difference

– Restore the Asterisk .conf files from a previous days backup made no difference

– Disabling some of the Asterisk modules would sometimes cause the Asterisk process to start correctly, with low CPU usage. This was intermittent though and there was no clear pointer to any specific module

The solution

It actually turned out to be a corrupt Asterisk Database (AstDB) file. This is normally stored here – /var/lib/asterisk/astdb and records some settings about follow-me’s, caller ids, etc. Renaming this file enabled Asterisk to start correctly. Asterisk will create another file but if you’re running FreePBX you need to go to every extension and click ‘Submit’ and then ‘Apply Changes’ at the end to recreate the extension settings in that file.

Additional

If you’re having to track down what is causing high CPU usage in Asterisk then here is a really great blog post describing a process to find exactly what part of the Asterisk code is causing the issue.

It might give you some pointers to where the problem lies –

Why does Asterisk consume 100% CPU?