Posted: July 21st, 2010 | Author: Gregg | Filed under: Asterisk VoIP, Linux, Tech | Tags: appointment, appointment reminder calls, asteris, call blasting, office reminder, ontime1405, ontime1405.com, voip, wake up call | 8 Comments »
A while back I had a meeting with a friend in Orlando, FL. He came up with the idea to provide an appointment reminder service to companies that would benefit from such a service. Doctor’s offices, Dentists, Mechanics, Repairmen, etc. I drew up the logistics of the program and began working on it in the fall of 2008. Since then we have had customers use the software to easily call their customers and remind them of appointments and also use the software for call blasting. Call blasting is a feature to call an unlimited amount of numbers and playback a message. Since I have experience in the Asterisk VoIP platform I programmed the system to allow for options and the customer to enter in input with their keypad.
The purpose of this article is to detail the logistics and share it with the Asterisk community.
There are a few different ways to originate calls with Asterisk.
-From the Asterisk CLI directly with the “originate” command
-From the AMI (Asterisk Manager Interface)
-From .call files placed in /var/spool/asterisk/outgoing
I went with .call files because of a few reasons:
-I can generate all of the call files ahead of time because they are read based on the timestamp of the file (less load)
-It is straightforward and easy to follow, and also leaves behind the .call file that is archived after the call is finished
-Asterisk will parse and execute based on timestamp, so to burst 100 calls would require much less overhead than through AMI/CLI
There are some negative effects to the .call files too:
-Changes made need to remove and add another .call file (If the customer changes their appointment time after the file was generated)
-The lowest interval to generate calls is every minute, so we can burst to 400 calls/minute (also more difficult to throttle calls)
Now you know how the calls are originating on the system, let’s move on to the database and interface.
I hired someone to program the interface in AJAX and PHP. That way it is secure and saved a lot of time if I were to attempt it myself. The interface is very clean and easy to use for customers. They also have the ability to import 1,000 records at a time via CSV files. Feel free to demo the interface via the link on ontime1405.com for “Demo the Interface”.
The interface stores the call data in MySQL which is then scanned hourly to process and create all of the .call files according to their timestamp. We only care about the calls that will be made by the system in the next hour, so those are the only .call files that are generated. The script is a PHP script that connects to the database with the query of calls to be made, strips them down, then does a loop to create the .call file, set the timestamp based on the variable, then move the .call file to /var/spool/asterisk/outgoing.
The .call files include 1 custom variable that is comma-delimited so we can parse out the appointment time, AM/PM, and any other custom variables.
The other important lines in the .call file point to the context in the Asterisk dialplan that the customer’s announcement and options are defined.
Now you may ask yourself, It will be a pain to manually add customer’s options and dialplan for every sign up, right? It was at first, but I created several automated scripts to generate the dialplan for the customer and “dialplan reload” when complete.
The rest of the accounting/etc is accomplished via bash cleanup scripts that write to the database and provide reporting/etc.
The same system can be used for call-blasting to a large group of number for a survey, snow day announcement, marketing message.
Please let me know if you have any questions or advice/constructive-criticism for me regarding the program.
And feel free to try out the demo interface and hear a reminder call!
Posted: April 27th, 2009 | Author: Gregg | Filed under: Asterisk VoIP, Linux, Tech, Uncategorized | Tags: asterisk backup, Asterisk VoIP, at backup asterisk, atd, automated asterisk backup, automated backup, automatic ftp connection, backup asterisk, backup asterisk files, backup asterisk script, backup etc/asterisk, bash, centos, connect ftp bash, cron, cron backup, cron backup asterisk, ftp bash, gz, gz asterisk, interactive backup, Linux, safe1405, tar, tar asterisk, voip | 6 Comments »
Safe1405 is a bash script that will backup the popular Asterisk directories and place them in a tar.gz file. The script can be used in 1 of 2 modes.
The first mode is interactive, with a menu to choose:
- Backup Everything (/etc/asterisk, Voicemail, Recordings, Sounds)
- Just VM
- Just Recordings
- Just Sounds
After the file is created, it will prompt to upload to a remote FTP server.
The second mode is silent, and is best suited for automated execution via cron or at.
Just enable the UNATTENDED and PUT_FTP variables by setting them to “1”. You can directly edit the paths to each directory if yours are non-standard.
The script can be directly downloaded here: Safe1405 Download Link
# Author: Gregg Hansen - www.thiscoolsite.com
# Safely tar and gzip Asterisk files
# Version 1.0 20090427
#-Backs up all important Asterisk files - Tar/Gz
#-Choose the file name, or Date by default
#-GUI-like. Able to be silent for cron, or interactive
#EDIT the below ABSOLUTE paths to match your directory structure:
#Filename is FILEDATE-SERVERNAME.tar.gz
#Enable unattended mode/Remote FTP put (useful for Cron):
# Backup of /etc/asterisk ONLY (default)
# 1 = On, 0 = Off
### Interactive Mode Functions ###
echo -n "Prompt> "
case $INPUT in
tar cfvz $FILENAME $ETC_AST $VM $MON $VAR_LIB
tar cfvz $FILENAME $ETC_AST
tar cfvz $FILENAME $VM
tar cfvz $FILENAME $MON
tar cfvz $FILENAME $VAR_LIB
echo -en "Upload $FILENAME to FTP? (y or n) "
if [ "$INPUT" == "y" ]; then
### Unattended Mode Functions ###
tar cfvz $FILEDATE-$SERVERNAME-ETC-AST.tar.gz $ETC_AST ##Uncomment##$VM #$MON #$VAR_LIB
ftp -ivn <<EOF
user $FTP_USER $FTP_PASS
#### Start Program Flow ###
#Unattended Function Call(s)
if [ "$UNATTENDED" == "1" ]; then
if [ "$PUT_FTP" == "1" ]; then
#Interactive Function Calls
Leave a comment if you have questions/suggestions or would like help setting up the script.
Posted: October 24th, 2008 | Author: Gregg | Filed under: Asterisk VoIP, Linux, Tech | Tags: Asterisk VoIP, automated, call center, centos, dialer, easy, gnudialer, kickstart, Linux, open-source, voip | 11 Comments »
I’ve had the task of installing GNUDialer for testing and call-centers tend want dialers all the time. Many dialer platforms are extremely bloated and their support fees are enormous! I like GNUDialer because they decided to make an open-source dialer platform that is minimal and functional.
Disclaimer: I am not responsible for any loss of data, server explosions, recessions, depressions, or anything negative that may arise from you running the dialer kickstart script. It was meant with good intentions, but I am not going to be liable for any of your actions.
Glad that is out of the way.
You can read through each script that runs and know exactly how the install was done. Make sure you watch the console throughout the install to catch any possible errors that may be thrown out (2)stderr.
–Prerequisites (Have your server connected to a DHCP-enabled network with internet access)
1. Download and Burn CentOS 4.5 or 4.6 ISO CD1 Here or Here.
2. Start the server with the CD and set the BIOS to boot from CD first
3. You will see this screen if it booted from the CD properly. At the prompt type ‘linux ks=http://www.thiscoolsite.com/scripts/ks_dialer/ks.cfg’ just like it did in the screenshot. Then hit enter.
4. If you typed the command incorrectly you will see this screen asking you to ‘test your media’. If you see this screen reboot your server and try typing the command again, but correctly.
5. After a minute you should see a screen that looks like this. That means you typed the ‘linux ks’ command correctly and it is installing in txt mode. It will take at least 10 minutes, then it will look like it is paused at the end of the install. Don’t worry, it is using yum to install all the latest packages you need to run Asterisk and Gnudialer. The install will reboot itselft, so don’t mess with it.
Upon first boot, the main script runs that will be doing the MySQL databse config, Asterisk install, astcrm, and GNUDialer installs. The script will exit and you will be prompted with a login screen. The default user is ‘root’ and password is ‘star1405’.
Change your root password immediately with the ‘passwd’ command.
Once you are logged in you can check to see that Asterisk is running by typing Asterisk -r and getting in to the console. You can then start the gnudialer daemon for the first time by typing ‘gnudialer –safe’. You should be up and running now! Good Job.
Navigate to http://InternalIPAddress/gnudialer to login to the management interface. Password is ‘gnudialer’.
Make sure you read all of the readme and install files in /usr/src/gnudialer so you can actually setup working campaigns and use the settings properly. Also, a few people are always available for live help in IRC.freenode.net’s #gnudialer channel. Be aware, ignorance is not allowed. If you didn’t attempt to troubleshoot the issue yourself or read everything available to you on the internet, you will be chastised and humiliated in front of your peers. <G>
As always, leave a comment with your email and I will try to help in any way that I can.
Happy automated-dialing trails…to you!
Posted: October 24th, 2008 | Author: Gregg | Filed under: Asterisk VoIP, Linux, Tech | Tags: Asterisk VoIP, bash, convert, cron wav to mp3, g729 to mp3, gsm to mp3, Linux, record, record calls, recordings, scripting, scripts, voip, wav to mp3 | 29 Comments »
From a helpful contributor. Since the encoding has changed and I haven’t had to do file conversion in years and years.
Check out Ernesto’s script here.
I have had many jobs (consulting and Salary) that have involved using Asterisk in a “Call-Center” environment. Whenever an agent would make a sale, the call would need to be recorded for verification purposes. Now I could talk about Asterisk and call-recording for pages upon pages, but I will be focusing on large .wav to .mp3 conversion jobs on the Linux/Asterisk server itself. First off, Asterisk can record calls using several different methods. The first method being that you setup a feature called Automon in /etc/asterisk/features.conf and use *1 (or whatever you specify) to record a call in progress. The second method is recording every call that comes in through a specific DID or enters a specific queue. Another method is to setup a ‘call genie’ that you conference your phone to and it records the entire call-bridge. There are pros and cons to every type of recording method and format. You can use GSM, wav, g729, etc. to record calls. Not matter what method you use, the simple script I wrote will convert your .wav files to .mp3 and also retain the timestamp of when the file was initially created (recorded). The options I use for mlame are what makes this script retain its awesome-ness over time. The options allow the final-result mp3 to be compressed and compatable with Asterisk. This means that you can playback your .mp3 files that you converted over Asterisk if you are using a ‘call-genie’ setup. I have also written scripts to convert your .g729/.gsm/etc => .mp3 so if you need one of those scripts leave a comment and I will email it to you (20090908 UPDATE: Check end of post for .g729 to MP3 file conversion script)
1. Download the script to your server. wget http://www.thiscoolsite.com/scripts/convertwav/convert_recordings.sh or download it here.
2. Put the script anywhere you wish, I tend to leave it in my home directory
3. chmod +x convert_recordings.sh
4. You need to install lame. Get the file from the lame site.
5. Extract the tarball. For Example… tar -zxvf lame-398-2.tar.gz
6. cd lame-398-2
9. make install
10. Now copy the mlame file from lame-398-2/misc/mlame to your .wav directory /var/spool/asterisk/monitor (or wherever your .wavs are)
11. chmod +x mlame
12. Edit the convert_recordings.sh recorddir variable to match your .wav directory path (no trailing ‘/’). The default directory is set to /var/spool/asterisk/monitor
13. Run the script by navigating to the directory and ./recordings_convert.sh
You should see it take a few seconds for each file and go on. I usually test it out by letting it convert a few files then Cntrl + C and ls -l the directory to check the filesizes and timestamps. There is a commented out section at the bottom of recordings_convert.sh that moves the .wav files to a separate directory (easier to check if it worked) and in my case, I keep the old files for a month or so for job security reasons. If you lose a bunch of verification recordings, you are going to have major problems.
Cron it, at it, and happy converting.
Code for .g729 to MP3 script. Very dirty, but works, please test on a small group of test files first.
Leave a comment if you need further assistance.
#Author: Gregg Hansen 20080414
#Used to convert from .g729 -in and -out files to .mp3
#Run on Recordings server
for i in `ls /ramdiskunload/*.g729`;
#convert all .g729 to wav first, then soxmix
DST=`echo $i | sed 's/.g729/.wav/g'`
asterisk -rx "file convert $i $DST"
rm -f $i
mv $DST /recordings
#all files should now be in the /recordings directory
#use soxmix and mlame to convert them to one file => mp3
for j in `ls /recordings/*-in.wav`;
INFILE=`echo $j | sed 's/-in/-out/g'`
MIXED=`echo $j | sed 's/-in//g'`
soxmix $j $INFILE $MIXED
rm -f $j
rm -f $INFILE
/root/test/mlame -f -o "-b 16 -m m -q 9 --resample 8" $MIXED
As always, leave a comment if you need help or clarification.
Posted: July 12th, 2008 | Author: Gregg | Filed under: Asterisk VoIP, Linux, Mac, Tech | Tags: asterisk failover, asterisk redundancy, Asterisk VoIP, bash, centos, failover, flip 1405, flip 1405 failover, flip1405, flip1405 failover, gregg hansen, Linux, redundancy, script, technology, uptime, voice over ip, voip, voip-info | 57 Comments »
Flip1405 is an Asterisk Failover solution that was created in early 2008. I found the need to create an easy to install failover solution for Asterisk servers. After a couple hours on a Sunday night, I had the first version completed. In 2009 someone who came across this script reworked the code to add new features, and I updated the site. Now, in 2011 I am glad to announce that there is a new version that has many new features and improvements over my existing code. Many thanks to Jonathan Bayer for updating the script again. His site is http://linuxnotes.us
Excerpt taken from his site:
Congratulations! You have now set up your first Asterisk-based VOIP server.
Next question (probably the first your boss will ask you): What happens when the server crashes, or loses power, or needs to be upgraded, or…….; well, you get the idea. If you only have a single server, you lose your phones until it is rebooted. Given that you probably installed this on a cheap, inexpensive piece of hardware, these questions are not out of the question, especially for a business.
We had the same questions, and have implemented a failover solution. I started with a script I got from this web page, but was dissatisfied with it. It seemed to be a bit of a kludge, in that it wasn’t a true HA solution, but was only a backup solution.
I did a massive reworking of the script, and the result downloadable from here:
This script is used to synchronize the /tftpboot with the /var/ftp/ directory:
The only dependencies for Flip1405.sh are nmap and arping
To use, first get your primary Asterisk server running smoothly. When ready, you can either clone it using Clonezilla (or some other utility) or just install Asterisk on the second box. Then follow these steps:
Setup shared-keys so the servers can copy between each other without user intervention. Setup Login without password
Set up ftp (I use vsftp), if needed. We use it to download the configurations for the Aastra phones. Usually we would use tftp, but since we have some phones outside our office we simply use ftp for everything.
Install this script into /usr/local/sbin on the primary/active system.
Run the script with the -s option:
The second script: syncftp.sh, is used to synchronize the /tftpboot directory with the /var/ftp directory. If you need it, install the syncftp.sh script into /usr/local/sbin
Open up the flip1405.sh in an editor, and check the various settings. I would recommend that if you need to change them, to use a config file (/etc/sysconfig/flip1405) rather than editing each file. The config file is NOT sync’d between the systems, so you can have system specific options in the file.
There is no need to specify the device, or whether the system is a master or slave. The script determines this at run time. The most important lines to set are the first three variables: MASTERIP, SLAVEIP, and FLOAT. These are:
MASTERIP IP address of the master system (arbitrary name)
SLAVEIP IP address of the slave system
FLOAT IP address that will float between the Master and Slave, and which your phones will access
All other variables are set for an Elastix system. Elastix is based on the following:
Make sure to set the bindaddr to the virtual IP address in /etc/asterisk/sip.conf or
bindaddr=192.168.1.12 ;IP of Virtual interface
Add the following line(s) to the root crontab (only install the syncftp.sh line if you are using it):
* * * * * /usr/local/sbin/flip1405.sh
*/5 * * * * /usr/local/sbin/syncftp.sh
If you like, you can add the following lines to /etc/crontab instead:
* * * * * root /usr/local/sbin/flip1405.sh
*/5 * * * * root /usr/local/sbin/syncftp.sh
If you have phones outside your network, you will need to configure your firewall to direct the following ports to the FLOAT address:
tcp 21 (if you are using ftp)
Click below to see previous versions (20090327)