Jun
28
2012




Agent Auto log-off script for Asterisk

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.

/etc/crontab:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
  * 18  *  *  * root  /etc/asterisk/bin/agent-auto-logoff.sh




 


/etc/asterisk/bin/agent-auto-logoff.sh:

#!/bin/bash
#set -x

LOGGEDIN=$(/usr/sbin/asterisk -rx "queue show" | /bin/grep -o 'SIP/...')

#echo $LOGGEDIN

for i in $LOGGEDIN

do

echo "$i removed"
echo '=========='

/usr/sbin/asterisk -rx "queue remove member $i from sales"
/usr/sbin/asterisk -rx "queue remove member $i from technical-support"
/usr/sbin/asterisk -rx "queue remove member $i from custserv"

done

exit


 

If you like this article tell Google!!









Written by mattb in: Asterisk,Scripts | Tags: , , ,

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment