Need help with asterisk script

Hey guys.

I need a custom asterisk script to do the following.

It would basically be something which i would add to an hourly cron job.

Basically the script need to execute asterisk -rx ‘show channels’

If the asterisk says it has more than 300 active calls then the program would send me an email saying the asterisk server x.x.x.x has reached X amount of calls.

Is there a different way of doing this?

can anyone please give me a hand in doing so??
thanks!!

Hi Do you mean channels or calls ?
either way you just need to grep the response as

2 active channels 1 active call
are the last 2 lines, then handle this when the varible you set it as goes above 300 and pass to an email script

Ian

X=`asterisk -rx 'show channels'|grep call | awk '{ print $1 }'` MAIL=me@x.x if [ $X -ge 300 ] ; then echo "CALLS $X" |mailx -s "COMPANY REACHED $X calls" $MAIL fi