#!/bin/sh # ${1} = number of call files to create . Must be <= ${2} , Must be < 10000 . # ${2) = Number of call files to process per ${3} second(s) . # ${3) = Number of Second(s) between chinks to preocess . # usage() { cat << USAGE ${0} [[Number of Files] [Number of files to Process] [Number of Seconds between processing]] \${1} = number of call files to create . Must be <= \${2} , Must be < 10000 . \${2) = Number of call files to process per \${3} second(s) . \${3) = Number of Second(s) between chunks to process . ex: make-callfiles.sh 100 10 10 USAGE } [ -z "${1}" -o -z "${2}" -o -z "${3}" ] && usage && exit case ${1} in [Uu][Ss][Aa][Gg][Ee]) usage && exit ;; esac case ${2} in [Uu][Ss][Aa][Gg][Ee]) usage && exit ;; esac case ${3} in [Uu][Ss][Aa][Gg][Ee]) usage && exit ;; esac NUMF=${1} INCR=${2} SECS=${3} DATE=`date "+%Y%m%d%H%M%S"` [ ! -e /tmp/test.calls ] && \ mkdir /tmp/test.calls cd /tmp/test.calls/ cat << CALLFILE > CALLFILE.call Channel: SIP/test/8005551212 Callerid: 8005551212 MaxRetries: 3 RetryTime: 5 WaitTime: 20 Context: test-perf Extension: 100 Priority: 1 CALLFILE for ((XXX=1; XXX<=NUMF; XXX++)); do [ ${XXX} -lt 100000 ] && XX1="0${XXX}" [ ${XXX} -lt 10000 ] && XX1="00${XXX}" [ ${XXX} -lt 1000 ] && XX1="000${XXX}" [ ${XXX} -lt 100 ] && XX1="0000${XXX}" [ ${XXX} -lt 10 ] && XX1="00000${XXX}" cp -f CALLFILE.call ${DATE}${XX1}.call done SPOOL="/var/spool/asterisk/outgoing" # SPOOL="/tmp/spool" [ ! -e ${SPOOL} ] && \ mkdir ${SPOOL} # Now mv the files to /var/spool/asterisk/outgoing for processing . while /bin/true ; do [ ! -e ${DATE}${XX1}.call ] && break FILES=`ls -1 ${DATE}*.call | head -n ${INCR} | sort -n | awk -vORS=" " '{print $1}'` mv -f ${FILES} ${SPOOL}/ sleep ${SECS} done # Cleanup after ourselves . [ -e /tmp/test.calls ] && \ rm -rf /tmp/test.calls # if testing clean it up ... [ -e /tmp/spool ] && \ rm -rf /tmp/spool