Foniva Contact Center Software
Asterisk Experts Support

Watch and monitor asterisk activity

If you want to watch and monitor your asterisk server ativities, you may need to run peridicly (every 10s for example) the same asterisk command.

The linux wacth command can help you do that.

For example, if you want a table to display the list of channels every 10 seconds in a “top like” mode, you can run :

watch -n 10 asterisk -rx \”show channels\”

That will run the same command every 10 seconds and display it in full screen.

Press Ctrl+C to exit.

asterisk users : september maillist

Here is asterisk mailling users questions for september month.

http://www.astblog.com/maillist/asterisk-users/2008-September/thread.html

Asterisk : generate core dump files

We all know that asterisk in still a work in progress and some people can have crash time to time.

If you want to know where asterisk did crash and generate coredump files, you need the followings :

- set the maximum size of coredump file that can be generate. Usually coredump files are very large file. So, to make sure that you have it, set it to unlimited. Must be done before starting asterisk.

ulimit -c unlimited

- tell asterisk to generate coredump file if crash happens. So, start asterisk with the g flag

asterisk -g

Then, when the asterisk service will crash it will generate a coredump file in the process root directory. To know what the process current working directory is, find the running asterisk process id (ps -ef |grep asterisk) and then run

ls -l /proc/<processid>

The ‘cwd’ (for current working directory) symlink is where your coredump file will be generate.

You can use gdb to see what happened.

asterisk bug : Unlimited call for limits under 1 second

Hi all,

i’ve found out and report a bug to asterisk in version 1.4.21.2.

The danger of this bug is, if, example in your code or ag, you used to setup calls limits in miliseconds, make sure that you limit is at least 1 second ie 1000 ms. For anything under 1 second, asterisk will execute the dial and bridge the calls for an unlimited amount of time.

For more informations :

http://insects.digium.com/view.php?id=13851

asterisk cli : execute linux command from cli

In the category did-you-know :

If you are in asterisk command line interface and need to run a linux command without quiting your cli,

you can prepend an exclamation point to your cli and it will execute your command.

Action

*CLI> !date
Thu Nov  6 10:43:15 EST 2008

Use asterisk to dial outbound number with extension

Sometimes, you want to reach an outbound number and when it answers, press some digits to naviguate through IVR.

The most common case where this can happens is when you want the callers from your PBX to reach a number and go direclty to a given extension. This prevents the caller to enters himself the extension number of the foreign side.

To make it done, you can use asterisk Dial option D.

D([called][:calling]) - Send the specified DTMF strings *after* the called
party has answered, but before the call gets bridged. The ‘called’
DTMF string is sent to the called party, and the ‘calling’ DTMF
string is sent to the calling party. Both parameters can be used
alone.

Situation : From your office, you want to have a “speed dial” extension (eg: 2025) that will allow users to reach the other office (eg: at phone number 5140000000) sales departement (eg: at extension 1234). So, instead of calling the phone number 5140000000 and then dialing 1234, your dialplan can look like :

exten => 2025,1,Noop(Caller ${CALLERID(all)} want to reach foreign office and extension 1234)

exten => 2025,n,Dial(Zap/g1/5140000000,30,D(1234))

exten => 2025,n,Hangup

So, what will happen is, as soon as the foreign office system (at 5140000000) will answer, asterisk will “auto press” digits 1234 and then bridge the call to the caller.

You can also send digits to the caller channel.

Asterisk dialplan to limit number of call in ‘x’ seconds

Here is a quick trick that you can use to limit the number of inbound calls from the same callerid in a certain time window.

It has the advantage to not use any database but a small file for each caller.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; With some adjustments:
;
;   1. adding a dir to the system /var/spool/asterisk/inbound_count
;   2. routing inbound channel into proper queue, menu, dialstatement or other destination
;   3. adjusting the number of attemps and the timeframe
;   4. adjusting GMT to your own situation, just to have the time right.

;  ;the script can be used.
;;;;;;;;;;;;;;;;;;;;;;;;;;;
; written by Erik de Wild
;  Tripple-o
; Your Asterisk migration partner
; info   at  tripple-o.nl
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  This is free software licensed under the GNU General Public
;  License version 2; you are welcome to redistribute it under
;  certain conditions.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; this script limmits the number of inbound call attempts within a certain timeframe.
; this script can help to prevents denial of service attacks or to prevent callers to spam you with incoming calls
;;;;;;;;;;;;;;;;;;;;;;;;;;;

[max_inbount_trials]

exten => s,1,Set(FILE_EXISTS=0)
exten => s,n,SET(PAD=/var/spool/asterisk/inbound_count/${CALLERID(num)})
exten => s,n,SET(FILE_EXISTS=${STAT(e,${PAD})})                                                   ; check if file already exists
exten => s,n,GotoIf($[ "${FILE_EXISTS}" : "1"]?check_last_read)
exten => s,n,System(echo -E “xx” > ${PAD})                                                                   ; create new file and add 1 line with xx
exten => s,n,MusicOnHold()                                                                                               ; just for now. This is the place to route call into queue, menu, dial statement or whatever
exten => s,n,Hangup()

exten => s,n(check_last_read),Set(LAST_READ=${STAT(A,${PAD})})                     ;EPOCH of last read
exten => s,n,NoOp(XXXXXXXXXXXXXXXXX ${LAST_READ})
exten => s,n,SET(SECONDS_AGO=$[${STRFTIME(${EPOCH},GMT-1,%s)} - ${LAST_READ}])

exten => s,n,Set(TIME_WINDOW=3600)                                                                         ; this is where the timefram for control the number is set in seconds
exten => s,n,GotoIf($[ ${SECONDS_AGO}<${TIME_WINDOW}]?add_line)
exten => s,n,NoOp( the last attemt was ${SECONDS_AGO} seconds ago)
exten => s,n,System(echo -E “xx” > ${PAD})                                                                   ; create new file, last attempt was more then 1 hour ago
exten => s,n,MusicOnHold()                                                                                               ; just for now. This is the place to route call into queue, menu, dial statement or whatever
exten => s,n,Hangup()

exten => s,n(add_line),System(echo -E “xx” >> ${PAD})                                              ; add line to file
exten => s,n,Set(SIZE_FILE=${STAT(s,${PAD})})                                                          ; check for number of bytes in file
exten => s,n,Set(MAX_SIZE=6)    ; This is where the number of attempts within the timeframe is set.
; two attempts with in the timeframe, every attempt add 3 bytes to the file (xx and a line return)
exten => s,n,GotoIf($[ ${SIZE_FILE}>${MAX_SIZE}]?hang_up)                                 ; Just two attempts within time frame
exten => s,n,MusicOnHold() ; just for now. This is the place to route call into queue, , menu, dial statement or whatever
exten => s,n,Hangup()
exten => s,n(hang_up),Playback(beep)
exten => s,n,Wait(2)
exten => s,n,Goto(hang_up)

Set dial maximum time and play warning audio

The topic of this post is to show how you can use the Dial cmd option in the dialplan

to limit the duration of a call and tell caller/callee that call is about to finish.

To do this, you can use the L option in your dialplan.

L(x[:y][:z]) - Limit the call to ‘x’ ms. Play a warning when ‘y’ ms are
left. Repeat the warning every ‘z’ ms. The following special
variables can be used with this option:
* LIMIT_PLAYAUDIO_CALLER   yes|no (default yes)
Play sounds to the caller.
* LIMIT_PLAYAUDIO_CALLEE   yes|no
Play sounds to the callee.
* LIMIT_TIMEOUT_FILE       File to play when time is up.
* LIMIT_CONNECT_FILE       File to play when call begins.
* LIMIT_WARNING_FILE       File to play as warning if ‘y’ is defined.
The default is to say the time remaining.

Example :

If you want to set a maximum of 10 minutes conversation and atone minute before the end, tell both the caller and the callee that the call is about to be drop :

exten => 5140000000,1,Set(LIMIT_PLAYAUDIO_CALLER=yes)

exten => 5140000000,n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)

exten => 5140000000,n,Set(LIMIT_WARNING_FILE=call-about-to-drop)

exten => 5140000000,n,Dial(${EXTEN},30,L(600000:60000))

exten => 5140000000,n,Hangup

So, after 9 minutes of conversation, the caller and the callee will hear call-about-to-drop audio file.


Our sponsors


Asterisk Experts Support