Categories
asterisk asterisk-addons astierks-mysql freepbx mysql Ubuntu

Final Asterisk clean up

This time I’m going to go through the final pieces of the Asterisk clean up on my Ubuntu 10.04 setup.

There were two annyoing things left behind by my install and setup of Asterisk.

  1. When I shutdown freepbx (aka amportal) the Asterisk instance would crash and then restart
  2. Ubuntu would want to update asterisk-mysql package

I’m going to show you how I got around these two issues. Firstly the amportal startup string and how to kill that nasty Asterisk crash and core dump.

The script I use to startup freepbx is below


#!/bin/bash
### BEGIN INIT INFO
# Provides: asterisk
# Required-Start: \$network \$syslog
# Required-Stop: \$network \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Asterisk daemon.
# Description: This script handles start/stop states of asterisk.
### END INIT INFO

set -e
set -a
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Asterisk"
NAME=amportal
DAEMON=/usr/sbin/$NAME

#test -x $DAEMON || exit 0

d_start() {
amportal start
}
d_stop() {
amportal stop
}
d_reload() {
amportal restart
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 10
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
exit 0

Save this to /etc/init.d/amportal and then do the following


update_rc.d amportal defaults 80 20
update_rc.d -f asterisk remove

so that FreePBX will come up when you boot and remove the Asterisk from starting on its own. You could also use the sysv-rc-conf tool which allows you to do this visually.
You notice that this runs the amportal script which is located at /usr/local/sbin. Inside of there andother script is invoke called freepbx_engine. This is typically located at /var/lib/asterisk/bin. Inside there you will see lines like


killall -9 safe_asterisk
.
.
.
/usr/sbin/safe_asterisk -U asterisk ...
.
.
.
/usr/sbin/asterisk -rx "core stop gracefully" | grep -v "No such command"
/usr/sbin/asterisk -rx "stop gracefully" | grep -v -E "No such command|deprecated"

What is Safe_Asterisk? This is a script which starts a loop and runs Asterisk inside the loop. If Asterisk was to die for some reason then it detects this and restarts Asterisk.

There are two problems which I had with this. Firstly safe_asterisk starts Asterisk in the foreground, so my startup script would appear to hang after Asterisk started. Second when I killed the script (by using Ctrl+C), Asterisk would stop and crash and then restart and sometimes it would fail to restart and keep re-trying.

Getting Asterisk to start in the background was simple enough, but the crashes and attempted restarts still happened when I shutdown freepbx.

The solution I found was to do utilize the existing Asterisk startup script. I replaced the above lines with this


#killall -9 safe_asterisk
killall -9 asterisk
.
.
.
#/usr/sbin/safe_asterisk -U asterisk -G $AMPASTERISKGROUP
/etc/init.d/asterisk start
.
.
.
#/usr/sbin/asterisk -rx "core stop gracefully" | grep -v "No such command"
#/usr/sbin/asterisk -rx "stop gracefully" | grep -v -E "No such command|deprecated"
/etc/init.d/asterisk stop

That solved all my problems with the starting and stopping of freepbx.

Now, if you’ve added on the Asterisk Addon from my previous post. You may find that next time you do a apt-get or aptitude to update your OS that it wants to pull down an “updated” asterisk-mysql. Do not do this! It will overwrite the addons and they will then not load. To keep from being prompted you need to pin this package at the version that its on and you will not be prompted anymore. This is thanks to this page.

echo asterisk-mysql hold | dpkg --set-selections

and to check that worked you do


dpkg --get-selections | grep asterisk

asterisk install
asterisk-config install
asterisk-mysql hold
asterisk-sounds-extra install
asterisk-sounds-main install

what more could a man want!

I hope that helps a lot more of you with using FreePBX which just gets better and better.

Categories
add ons asterisk cdr freepbx Linux mysql

Getting those Asterisk Addons into Ubuntu

I have this VOIP server in my office which is running FreePBX and Asterisk. Well its not in my office, its in a server room down the hall. Its a small AMD Duron of about 1Ghz, which is enough.

FreePBX is a great GUI and management interface for Asterisk and I encourage anyone to use it. I originally used the AsteriskGUI, but that was buggy and had severe limitations. Also, development had basically stopped on it. You know when Digium (the sponsors of Asterisk) start shipping FreePBX with Asterisk in its AsteriskNOW package – their own GUI is dead.

It took a bit of trial and error to get FreePBX installed on Ubuntu 10.04 – as there is no package for it. I also managed to get it working with lighty (lighttpd) which saved a lot of memory. And as an additional tip, disable innoDB in MySQL which will save you even more memory.

By default Asterisk logs all the calls to a CSV file. These files are very ugly and impossible to read. There is a panel in FreePBX which allows you to interrogate CDR or call records. This panel queries a MySQL database. This database is part of the FreePBX install script which managed to work for me. But to log to the database Asterisk must have the cdr_mysql addon. This does not come straight with a ubuntu package. There are a couple of steps you need to go through.

First, do not go out an grab the svn sources from digium site and compile and install. This will not work. You will most likely get these types of errors in your Asterisk full log:

Module 'app_addon_sql_mysql.so' was not compiled with the same compile-time options as this version of Asterisk.
Module 'app_addon_sql_mysql.so' will not be initialized as it may cause instability.
Module 'app_addon_sql_mysql.so' could not be loaded.


Follow these steps though and you will have success:

~# apt-get build-dep asterisk-mysql
~# apt-get -b source asterisk-mysql
~# dpkg -i asterisk-mysql_1.6.2.0-1_i386.deb

So what does this do? The first step downloads all the build dependencies for the add ons. The next builds the addons from the source. The last step installs the addons into the Asterisk modules folder. Thanks to the guys as Launchpad for helping everyone sort this out. See here.

Then restart your Asterisk server and you are done. I think next time I’ll show you how to get around the core dump when you shutdown Asterisk using the scripts which come with FreePBX.

Now if we could only nail down the call quality, me and the other guys at chameeya would be so happy.

Categories
asterisk CRM freepbx iax sip sip trunks social crm voip

What is Social CRM and why do beans taste so damn good

I recently read an article in one of the rags I get on a weekly basis – or is that monthly. No matter, it was an interesting article on the business merits and real necessity of employing social media as part of a new strategy to engage with customers.

This overall area is known as SocialCRM. Its not a single package, its a strategy. A company would employ their website, forums, Twitter, Facebook and other websites in engaging with customers and the general public. For example my broadband ISP allows customers to open service tickets in different ways. A customer can do this by phone, e-mail, ticketing on their site iself or by posting to their forums. Almost immediately one of the ISP service reps. will pick up the conversation and assist the user.

Such interaction is open to the public and is searchable. When I shop I now not only look for a product that fits my needs and budget I also search the web for reviews of the product. I then base my decision on what I find. A company can either win my business with great reviews and feedback and great customer service, or lose it by doing neither of these.

So the challenge then becomes keeping track of all of this information. How does staff do all this. Are they sitting inside their CRM with RSS feeds of hot topics flowing in. Are they responding withing the CRM or directly to the social media. I’m just getting my head around this now. It is a huge area and a potential for about £10bn in the CRM market.

Now that I’ve completed the latest project I’ve been working on. I’ve no time to do what I love. Fiddling with my wife’s office network. I’ve just installed a Asterisk server in the office. Asterisk is a VOIP office server which builds a small office PBX as quite a low price. I mean you can’t get much lower than free can you? It is then necessary to get a SIP/IAX supplier so you can make outside calls. The call rates are quite good and the service is usually excellent – unless the power goes out.

Installing Asterisk was simple – its part of the Ubuntu libraries and a simple apt-get Asterisk did the trick. Then…the hard work starts. Luckily there are two simpler solutions.

One, get AsteriskNOW. This is basically a iso which has a prebuilt Asterisk server using CentOS 5.1 distribution. This comes with a Asterisk web GUI which makes life soo much easier than fiddling with .conf files.
Two, install Asterisk and then install FreePBX. This is a great Web GUI front end to Asterisk.

I did neither. Though I am presently evaluating whether doing number 1 is the way to go. None the less I have it installed and have installed the AsteriskGUI manually. The instructions for that all over the web so I won’t repeat them here.

Now I’ve been looking for a IAX/SIP provider. Some a better than others. Some have no idea that I can install Asterisk myself – others are more clued up. As always, shop around and choose the best for you.

Of course you can avoid all this and just get it hosted. You pay more, but then you don’t have the headache of running a server. Now, to buy some IP phones. They sure are expensive. I think its time for some beans on toast. They sure do taste nice don’t they.