Tag Archives: asterisk

Monitoring your Peers (Asterisk extensions) and Trunks

As an admin for a telephone system, possibly one of the most useful things you can do is monitoring your peers and trunks. There are 2 great reasons you should do so:

1. You can respond to and resolve issues with your system before your users know about it, and you can be in the know if someone reports “none of the phones are working” when in fact only 1 or 2 are not working

2. You can actually know when there is a problem with the system – where you otherwise might not know there is a problem until someone calls on your mobile to say your office number is not working

 

I have 2 scripts running every 15 minutes to email me with the details of any down extensions and trunks. This is done in Crontab with the line:

*/15 8-18 * * Mon-Fri /usr/Peermonitor.sh

and similar for Trunkmonitor.sh. This line says to run every 15 minutes between 08:00 and 18:00 every Monday-Friday

Continue reading

Improving Asterisk call quality with SIP jitter buffers

I had a customer let me know that they had improved their call quality from WiFi and 3G connections by turning on the Asterisk jitter buffers for SIP connections. If you have any extensions where connection quality is intermittent it could be worth trying.

This can by done with the FreePBX SIP Settings module or by adding the following lines to –

/etc/asterisk/sip_general_custom.conf

jbenable=yes
jbimpl=adaptive

 

After changing you should restart Asterisk or ‘sip reload’ from the console.

If you are just using Asterisk the change would go in the [general] section of sip.conf

If you try this option and notice any difference to call quality please post a comment below. Thanks!

Using SysAdminMan OpenVPN template with pfSense

I’ve had a few customers recently using the SysAdminMan VPN:PBX template with an existing on-site pfSense gateway. The VPN:PBX template has Asterisk, FreePBX and A2Billing installed, along with OpenVPN setup to allow secure connections to the VPS.

pfSense can be used as an OpenVPN client/gateway so this makes a great combination for a secure off-site PBX.

Here are some setup instructions for configuring pfSense with the SysAdminMan VPN:PBX template.

1 – Obtaining the OpenVPN client certificates

When your SysAdminMan server is created 3 files will be generated that are required to configure pfSense as an OpenVPN client. These files can be e-mailed to you or retrieved from the VPS using a program like WinSCP. The 3 files are –

/etc/openvpn/keys/ca.crt
/etc/openvpn/keys/tplink.key
/etc/openvpn/keys/tplink.crt

These 3 files identify an individual OpenVPN client. If you are just connecting a single gateway this is all you will need. If you’d like instructions for creating more certificates please open a support ticket.

2 – Installing the Certificates on pfSense

Next we need to install the 3 certificates above in pfSense. The 3 files (ca.crt, tplink.key and tplink.crt) are text files which we can open with notepad, or something similar, and copy and paste the contents in to the correct place in pfSense.

First select “System/Cert Manager” from the pfSense menu. Then we click to add a CA –

pfsense add CA

Continue reading

Using Android with FreePBX – CSipSimple extension

I’ve used a few different Android SIP clients as extensions on FreePBX and my current favourite is CSipSimple

Installation and setup is straight forward. There are several built in configuration profiles for call providers, or you can choose advanced and enter your FreePBX server details to use CSipSimple as a FreePBX extension.

CSipSimple account setupCSipSimple add accountCSipSimple Registered Account

Continue reading

Integrating OpenSIPS with Asterisk and A2Billing

Below are links to the 3 parts of a post covering integrating OpenSIPS with Asterisk and A2Billing. The setup described uses OpenSIPS handling A2Billing customer SIP requests for calls (for example when providing a wholesale service to other SIP PBXs).

It’s based on OpenSIPS v1.8 / Asterisk v1.8 / A2Billing v2.01

Please take security in to consideration with VOIP whether testing or in a live situation.

Part 1 – Overview of using A2Billing and OpenSIPS together

Part 2 – Setting up the OpenSIPS MySQL database and integrating it with the A2Billing MySQL database

Part 3 – The opensips.cfg config file

A2Billing and OpenSIPS – Part 3

This post has the actual config of OpenSIPS described in part 1 and part 2. Some of this config will not make sense unless you read those parts.

First a warning … many, many people want to use your call credit!! Make sure that your systems are secure. If only the OpenSIPS server needs to talk to your A2Billing/Asterisk servers over SIP then use a fierwall to block other connections.

In the configuration below OpenSIPS does not handle the Audio/RTP traffic, this is passed directly to the Asterisk/A2Billing server.

The code below is the whole opensips.cfg file, just broken up with some description. All indentation has been removed, apologies if this sometimes makes it difficult to read.

First some global settings, including the IP address of the OpenSIPS server –

listen=udp:1.1.1.1:5060 # CUSTOMIZE ME
debug=1
log_stderror=no
log_facility=LOG_LOCAL6
fork=yes
children=4
dns_try_ipv6=no
auto_aliases=no
disable_tcp=yes
disable_tls=yes
server_signature=no

next we load the modules that are required –

mpath="/usr/local/lib/opensips/modules/"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "sipmsgops.so"
loadmodule "mi_fifo.so"
loadmodule "uri.so"
loadmodule "db_mysql.so"
loadmodule "avpops.so"
loadmodule "acc.so"
loadmodule "dispatcher.so"
loadmodule "permissions.so"
loadmodule "dialog.so"
loadmodule "siptrace.so"
loadmodule "auth.so"
loadmodule "auth_db.so"

Continue reading

A2Billing drops call when * (star) pressed

I saw this on a customer’s system where calls were being disconnected when the * button was pressed during the call.

This was being caused by 2 settings. The first being the default Asterisk feature code for disconnecting a call. You can see these at the Asterisk CLI like this –

Connected to Asterisk 1.8.5.0 currently running on uk1 (pid = 5257)
server1*CLI> features show
Builtin Feature           Default Current
---------------           ------- -------
Pickup                    *8      *8
Blind Transfer            #       #
Disconnect Call           *       *

So you can see there is a default feature code for disconnecting the call by pressing * 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?

Using Android with FreePBX – a SIP extension for free

FreePBX is an opensource VOIP PBX system that is built on top of Asterisk and therefore can use SIP to communicate with extensions. This means that we can use any of this SIP clients that are available for Android.

3CXPhoneOne such SIP compliant softphone is called 3CXPhone. This is a simple client that will work over both WiFI and 3G.

Bandwidth!! – One thing to consider when using a softphone on your Android handset is bandwidth. This might be a problem if you have a cap on your WiFi, but is much more likely to be an issue if you use 3G to make VOIP calls. Here are some quick facts and number to help you decide which codec to use –

G711 – good audio quality – uses around 72MB per hour    * also referred to as ulaw and alaw.

GSM – ok call quality – uses around 25MB per hour

G729 – ok call quality – uses around 21MB per hour    * not included with Asterisk or 3CXPhone

So above are 3 common codec choices with Asterisk. G711 has good quality audio but the trade-off is the amount of bandwidth it uses. If you have a small 3G cap you could quite quickly burn through it. The audio quality with GSM and G729 is OK. It’s perfectly understandable, and whether it’s acceptable or not will depend on the person making/receiving the call and their expectations.

G729 has the lowest bandwidth requirements of the 3 but it is not included with Asterisk by default (and is not available for 3CXPhone at all) as there are license costs to run it. You can add G729 to Asterisk but there is a license cost from Digium (there is an opensource version of G729 for Asterisk but you should be aware of any license restrictions – http://asterisk.hosting.lv/). You will also find that there is a higher cost for Android softphones that can run G729.

I would also recommend something like 3G Watchdog if you need to keep track of how much bandwidth you are using – https://play.google.com/store/apps/details?id=net.rgruet.android.g3watchdog&hl=en

Setup – Installation was straight forward. Just create an extension in FreePBX and then you just need the server IP (or name), extension number and extension secret in 3CXPhone. One thing I did notice was that disabling codecs in 3CXPhone did not seem to work for me. I disabled G711 in 3CXPhone and had G711 and GSM enabled in FreePBX for the extension. The call was still make using G711 and I don’t think that should be the case. If you want to use GSM I would just have GSM enabled for that extension in FreePBX. It would also be worth double checking what codec is used by checking a call in progress!

Continue reading

Managing files on your VPS – clearing up disk space

An Asterisk PBX usually requires very little disk space. One of the few exceptions is for voicemail and recordings storage. If a customers VPS runs out of disk space you can pretty much guarantee that the space is being used by recordings.

The easiest way to either delete or mass archive the recordings is via SCP. This works over the SSH port (22) and you use the root/ssh login details that were provided in the welcome e-mail.

If you’re a Windows user then there a nice, simple, free application called WinSCP – http://winscp.net/eng/index.php

Just enter your VPS IP address and the root username and password –

winscp login

and then browse to /var/spool/asterisk/monitor where the recordings are stored –

winscp browse

from there you can either delete the “.wav” files directly or move them off your VPS and on to your PC