SANOG10 NOC Voip Asterisk Advanced
SANOG10 NOC Voip Asterisk Advanced
Jonny Martin
jonny@jonnynet.net
Variable Expressions
• Variables used to
• add clarity
• ${variable:offset:length}
• ${string1}${string2}
Variable Operators
• Boolean operators (non-zero = true, zero=false)
• Or - var1 | var2
• Mathematical operators
• Basic syntax:
• FUNTION_NAME(argument)
• ${FUNCTION_NAME(argument)}
• Many more...
Functions
*CLI> show functions
Installed Custom Functions:
--------------------------------------------------------------------------------
URIENCODE URIENCODE(<data>) Encodes a string to URI-
safe encoding.
URIDECODE URIDECODE(<data>) Decodes an URI-encoded
string.
SQL_ESC SQL_ESC(<string>) Escapes single ticks for
use in SQL statements
ODBC_PRESENCE ODBC_PRESENCE(<arg1>[...[,<argN>]]) Runs the referenced
query with the specified arguments
ODBC_ANTIGF ODBC_ANTIGF(<arg1>[...[,<argN>]]) Runs the referenced
query with the specified arguments
ODBC_SQL ODBC_SQL(<arg1>[...[,<argN>]]) Runs the referenced
query with the specified arguments
TXTCIDNAME TXTCIDNAME(<number>) TXTCIDNAME looks up a
caller name via DNS
ENUMLOOKUP ENUMLOOKUP(number[,Method-type[,opt ENUMLOOKUP allows for
general or specific querying of NAPTR records or counts of NAPTR types for ENUM or
ENUM-like DNS pointers
CALLERID CALLERID(datatype) Gets or sets Caller*ID
data on the channel.
ARRAY ARRAY(var1[,var2[...][,varN]]) Allows setting multiple
Asterisk Database
• Data stored in a file, so is retained across Asterisk reloads and server reboots
;
; Standard extension macro:
; ${ARG1} - Extension (we could have used ${MACRO_EXTEN} here as well
; ${ARG2} - Device(s) to ring
;
; ring the interface for 20sec max
exten => s,1,Dial(${ARG2},20)
; jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
exten => s,2,Goto(s-${DIALSTATUS},1)
• AGI script can write to STDERR to send debug information to the console
• Agents functionality still quite buggy - best not to use for anything complex
agents.conf
/etc/asterisk/agents.conf
[general]
; Define whether callbacklogins should be stored in astdb for persistence
persistentagents=yes
[agents]
;autologoff=15 ; time (s) before agent auto logoff if no answer
;ackcall=no
wrapuptime=1000
;musiconhold => default
;updatecdr=no
; Enable recording calls addressed to agents. It's turned off by default.
recordagentcalls=yes
;recordformat=gsm
[general]
; Store each dynamic agent in each queue in the astdb for persistence
persistentmembers = yes
; Queue(queuename|[options]|[optionalurl]|[announceoverride]|[timeout])
; example: Queue(dave|t|||45)
[noc]
musiconhold = default
strategy = ringall ; ringall, roundrobin, leastrecent, fewest calls, random, rrmemory
servicelevel = 30 ; SLA setting (s). stats for calls answered in this time
timeout=15 ; How long the phone rings before it's considered a timeout
retry=0 ; How long do we wait before trying all the members again?
; Weight of queue - when compared to other queues, higher weights get preference
weight=2
wrapuptime=5 ; how long before sending agent another call
maxlen = 0 ; of queue, 0 for no maximum
; How often to announce queue position and/or estimated holdtime to caller (0=off)
announce-frequency = 0
;announce-holdtime = yes|no|once
;announce-round-seconds = 10
; How often to make any periodic announcement (see periodic-announce)
;periodic-announce-frequency=60
Queuing Example
; Using Agents
; agent login to helpdesk queue
exten => *4,1,Answer()
exten => *4,n,AddQueueMember(noc|Agent/${CALLERID(NUM)})
exten => *4,n,AgentCallbackLogin(${CALLERID(NUM)}||q${CALLERID(NUM)}@sip)
exten => *4,n,Hangup()
; Or, using dynamic login of channel instead of agents, doesn't send triggers to flash panel
exten => *4,1,Answer()
exten => *4,n,AddQueueMember(noc|${CALLERID(NUM)})
exten => *4,n,Playback(logged-in)
exten => *4,n,Hangup()
• http://www.cstr.ed.ac.uk/projects/festival/