Many times an Agent will forget to logoff. This can cause call routing, payroll, and queue statistic problems with Asterisk. With a handy BASH script it is easy to log all the agents out the queues automatically. Below is the shell script and an example of the crontab entry for execution at 6:00 PM every day.
This is a simple script for logging out Dynamic Agents in Asterisk. The most common use would be to logout Agents automatically each day in case they forget or are on PAUSE. Edit the “LOGGEDIN” variable below to match the correct length of digits. By default it is three, ‘SIP/…’.
You can add as many or as few Queues in place of QUEUE1, QUEUE2, & QUEUE3. This is the ‘foreach’ section of the script. Whatever that is here will be applied to each instance of SIP/xxx detected by grep. Good luck.
# Execute from the command line, Asterisk or by cron
LOGGEDIN=$(/usr/sbin/asterisk -rx “queue show” | /bin/grep -o ‘SIP/…’)
for i in $LOGGEDIN
echo “$i removed”
# Add in all queues that should be included
/usr/sbin/asterisk -rx “queue remove member $i from QUEUE1”
/usr/sbin/asterisk -rx “queue remove member $i from QUEUE2”
/usr/sbin/asterisk -rx “queue remove member $i from QUEUE3”
I told a customer for the company I for that I would figure out how to logout agents by CID(Caller ID). So I figured, why not kill two birds with one stone. Today we will create a single Queue, Agent, and dial plan to accomplish this goal. I’m using Asterisk 1.4, Fedora 10 and a Polycom IP SIP phone for my demonstration purposes.
When I started this project four hours ago, I thought I would google my way to another successful blog post(and happy customer), but no… logging out agents in Asterisk is very unintuitive. The agentcallbacklogin utility has the exact same prompts for logging in as out. AgentCallbackLogin (when initiated, from the dial plan) asks for three things, agent, agent password, and call back number. To eliminate all these prompts I’m using the ‘$CallerID(num)’ variable to automatically answer the agent and call back number. So the user 8888 dials ‘1000’ and and AgentCallbackLogin assumes he is AGENT/8888 with a password of ‘8888’.
; Default settings for queues (currently unused)
context = savelono-queue-out
musiconhold = default
strategy = leastrecent
timeout = 10
retry = 5
announce-frequency = 90
announce-holdtime = no
announce-round-seconds = 30
queue-youarenext = queue-youarenext
queue-thereare = queue-thereare
queue-callswaiting = queue-callswaiting
queue-thankyou = queue-thankyou
monitor-format = wav
monitor-join = yes
joinempty = yes
;memberdelay = 1
member => Agent/8888
; Agent configuration
musiconhold => default
agent => 8888,8888,Lono