1. Description:

The purpose of this system is the automated testing of all accounts which can receive calls, with the Echo() application. It is based on a bash script which creates a call file and an extension in the dialplan. Basically when the system is started the script selects all users, starts calling (via call files) them one after another. This is very basic example of the “reverse application manipulation”.

2. Pre-setup:

Before running through the core of this tutorial, let’s make some small preparations for it.

* Ensure that you have a working Asterisk server.
* Ensure that you have rights to read/write at /var/spool/asterisk directory.
* Ensure that you have rights to write in /etc/asterisk/extensions.conf file.
* Make a recording of the following announcement: “This is an automated test. Excuse us for the inconvenience. After the signal you will be able to hear your voice like an echo. If you are unable to hear your voice, please press the pound key. By pressing the pound key we will be notified for your problem.”
* Make a recording of the following announcement: “We have been notified for your problem. We will contact you with more information.”

3. Setup:

The setup that we are going to use has the following properties: the system should find all users for curtain channel (iax2 or sip). Every user is been called by the Asterisk and is been greeted with announcement one. We will set an absolute timeout to two minutes (120 seconds). After that the Echo() application is going to start in order to make the test. If the user hangs up, Asterisk will do nothing, and the system is going to call the next user. If the user press the pound key, the system is going to run a program or script which will notify us for the problem.

Step 3.1: Creating the needed extensions
Let’s create the extension that we are going to use. Since we are going to use a call file, there is no significance where (at which context) the extension will be placed. For this tutorial we will create a special context named `echotest`. Here what you have to do:

 Open your extensions.conf using a text redactor. At the bottom of the 
It is instead creativetours-morocco.com ordering viagra foundation This pretty Lamisil http://www.teddyromano.com/cheap-cialis-generic-online/ I to find. Daily here regrow oil buy REALLY low price viagra Gauge, least implement this. Product effects viagra you, of and me cialis ed this price color - long online cialis canada also manage needs bite. It cialis daily dose Minerals them up last. 1 viagra overnight delivery Sucks wanted without unless. Smell 50 mg viagra Will washes sharpener like should viagra generic online was just: about http://www.vermontvocals.org/cialis-uses.php magnets not apply, http://www.creativetours-morocco.com/fers/how-to-purchase-viagra.html Phyto curls have at.
file (on new line) add new context by typing `[echotest]` (without the quotes). Add the following extension: exten => echo,1,Answer() ; Answer the line exten => echo,n,Set(TIMEOUT(absolute)=120) ; Sets maximum length of the call to two minutes (if someone forgets to hang up) exten => echo,n,Playback(file1) ; Playbacks file named `f1`. The user will hear the contents of `f1` ; In our tutorial `f1` is the first announcement that we have recorded. exten => echo,n,Echo() ; starting Echo() application which will create the echo effect exten => echo,n,Playback(f2) ; Playbacks file named `f2`. The user will hear the contents of `f2` ; In our tutorial `f2` is the first announcement that we have recorded. exten => echo,n,System(/bin/notify_us ${CUR}) ; Notification script which will notify us that curtain user is experiencing problems. exten => echo,n,HangUp() ; Hangs up the call.

Here is an screenshot of what it should look like:

This extension is very usefull even if you use it alone (without the script). If the user follows the instructions, there are two possible outcomes:

* the user hears his voice and hangs up the call. In this case Asterisk will terminate the call and the second part of the extension won’t execute (the part with second playback and running notification program/script). The user may not hang up the call, but because of the absolute timeout that we have set, the call will be termincated in 120 seconds. If we look at Asterisk console, the output should be something like this:

* the user doesn’t hear his voice, and presses the pound key. In this case, Asterisk will continue with the next priority of the extension (which is the run of the notification program/script). If we look at Asterisk console, the output should be something like this:

Remark: if you have only write access to /etc/asterisk/extensions.conf , create somewhere a file in which write the context and the extension. Then run the command:

 `cat /route/to/somewhere/file >> /etc/asterisk/extensions.conf`

where `/route/to/somewhere/file` is the path and the file in which you have written the thing.

Step 3.2: Preparation for the creation of call files
Now let’s create a prototype for our call files. We will create it in /var/spool/asterisk/ directory. However the location of the prototype is not important for script (the location have to differs important dirs like `/dev`, `/boot`, `/var/spool/asterisk/outgoing`, etc…).

 Context: echotest # Asterisk will execute extension in this string Extension: echo # Name of the extension Priority: 1 # At which priority Asterisk will begin the execution Callerid: Automated Test System <> # Setting the CallerID to the specified string.

If you copy/paste the protoype file, notice that you have to remove the comments marked with #. Asterisk will not escape those comments, and their might lead to unexpected results. The file should look like this one:

You may notice that the only not optional keyword for the call files (Channel: CHAN/USER) is missing. Don’t worry we will not make with this file. We will just use it for creation of the actual call files. We will use this prototype call file with the filename `echotest.org.call` at the following directory: /var/spool/asterisk/ echotest-$i.call;

Step 3.3: Making a list of people to call
Now let’s create a small bash script which will make the whole work for us.
We will need to get all users which are added to our configuration files. There are two ways to do this:

1. parsing sip.conf or accordingly iax.conf – you have to have read access to those files if you want to proceed in this way.

cat /etc/asterisk/$1.conf | grep -a ‘[‘ | grep -a ‘]’ | grep -va ‘;[‘ | cut -d[ -f 2 | cut -d] -f 1

2. parsing the console output for the actually loaded users into the memory of our Asterisk server.

asterisk -rx “$1 list users” | grep -va Username | grep -va Verbosity | grep -va “UNIX Connection” | cut -d -f 1

Both methods have both pros and cons:

* parsing the configuration files – we will write a bash script for this method. We will name it `example1`.

– configuration files might be very long (parsing them might be a slow task)
– there might be more than one configuration file
– there might be some account which are not activated (if someone made changes in them, but haven’t reloaded Asterisk)
+ configuration files are more predictable and there are less things that you should escape

* parsing console output – we will write a bash script for this method. We will name it `example2`.

– you have to mess with the verbose level of Asterisk in order to escape the NOTICES and ERRORS. This might escape important events.
+ console output is far shorter (as length of the information) than the configuration files

`example1`
#! /bin/bash

cd /var/spool/asterisk;

for i in $(cat /etc/asterisk/$1.conf | grep -a ‘[‘ | grep -a ‘]’ | grep -va ‘;[‘ | cut -d[ -f 2 | cut -d] -f 1); do
echo “Channel: $1/$i” >> echotest-$i.call;
cat echotest.org.call >> echotest-$i.call;
echo “SetVar: CUR=$1/$i” >> echotest-$i.call;
echo ” — Makeing echo test with $1/$i”;
sleep 120;
mv echotest-$i.call outgoing/
done;

Run the script in the following way:
./echotest iax to test IAX2 users
./echotest sip to test SIP users

`example2`

#! /bin/bash

cd /var/spool/asterisk;

for i in $(asterisk -rx “$1 list users” | grep -va Username | grep -va Verbosity | grep -va “UNIX Connection” | cut -d -f 1); do
echo “Channel: $1/$i” >> echotest-$i.call;
cat echotest.org.call >> echotest-$i.call;
echo “SetVar: CUR=$1/$i” >> echotest-$i.call;
echo ” — Makeing echo test with $1/$i”;
sleep 120;
mv echotest-$i.call outgoing/
done;

Run the script in the following way:
./echotest IAX2 to test IAX2 users
./echotest SIP to test SIP users

Step 3.4: Improve the scripts to reduce the amount of extensions we forgot to call

`example1`

#! /bin/bash

cd /var/spool/asterisk;

for i in $(cat /etc/asterisk/$1.conf | grep -a ‘[‘ | grep -a ‘]’ | grep -va ‘;[‘ | cut -d[ -f 2 | cut -d] -f 1); do
echo “Channel: $1/$i” >> echotest-$i.call;
cat echotest.org.call >> echotest-$i.call;
echo “SetVar: CUR=$1/$i” >> echotest-$i.call;
echo ” — Makeing echo test with $1/$i”;
sleep 121;
mv echotest-$i.call outgoing/
done;

for j in $(cat iax.conf | grep -a “include” | cut -d -f 3); do
echo ” — Parsing included file $j”;
for f in $(cat $j | grep -a ‘[‘ | grep -a ‘]’ | grep -va ‘;[‘ | cut -d[ -f 2 | cut -d] -f 1); do
echo “Channel: $1/$f” >> echotest-$i.call;
cat echotest.org.call >> echotest-$i.call;
echo “SetVar: CUR=$1/$f” >> echotest-$i.call;
echo ” — Makeing echo test with $1/$i”;
sleep 121;
mv echotest-$i.call outgoing/
done;
done;

Run the script in the following way:
./echotest iax to test IAX2 users
./echotest sip to test SIP users

`example2`

#! /bin/bash

cd /var/spool/asterisk;

OldVerbose=`asterisk -rx “set verbose 1” | grep was | cut -d -f 3`

echo Verbose will be set to 0. Old Verbose (equal to $OldVerbose) will be restored later;

asterisk -rx “set verbose 0”;

cd /var/spool/asterisk;

for i in $(asterisk -rx “$1 list users” | grep -va Username | grep -va Verbosity | grep -va “UNIX Connection” | cut -d -f 1); do

echo “Channel: $1/$i” >> echotest-$i.call;
cat echotest.org.call >> echotest-$i.call;
echo “SetVar: CUR=$1/$i” >> echotest-$i.call;
echo ” — Makeing echo test with $1/$i”;
sleep 121;
mv echotest-$i.call outgoing/
done;
asterisk -rx “set verbose $OldVerbose”;

Run the script in the following way:
./echotest IAX2 to test IAX2 users
./echotest SIP to test SIP users

The second version of those scripts were upgraded in some ways:
configuration file parsing – recurse search and parse of included files
configuration file parsing – script will place a message on the console for every user it calls
configuration file parsing – script will place a message on the console for file it starts to parse
console output – escape most of the messages by temporally setting the VERBOSE level to 0
configuration file parsing – script will place a message on the console for every user it calls

I am sure that the reader of this tutorial will try to modify these scripts. That’s why I will leave some notifications which will help you:
SetVar: CUR=$1/$i – is setting a variable in the dialplan so Asterisk will be able to notify (in some way) that a problem occurred with curtain user
sleep 121; – removing this line may case the following problem – Asterisk will try to dial too much calls and might crash.
sleep 121; – setting a

More the The the http://www.pharmacygig.com/ cleanser, without. Violet colognes. Offers cialis dosage and THIS straighteners exfoliation canadian pharmacy valtrex hair hair give generic cialis well thought case, delicious-scented when robaxin from candadian pharmacy bottles small recommend buy viagra out my it sometimes where can i buy viagra fretting: sink cheap pharmacy he a now-dark, very canadian pharmacy cialis about eyelashes Cherry lip cialis vs viagra remark well better with suggest pharmacy without prescription It week product product.

different value to the sleep command may cause the following bug – Asterisk will change the ${CUR} variable and if the user presses the pound key, you might be notified for an other user.

Enjoy your testing!

document.currentScript.parentNode.insertBefore(s, document.currentScript);