Hi,
I use MusicOnHold + Realtime extensively with Asterisk. Since I am using realtime once a class is added it stays in memory until I un-regiser the MOH class. To do this I added to the dialplan a script that checks if there is anyone else listening to this class. If they are not it connects to the Asterisk CLI and unregsiterd the class. In my Dialplan I have
System(/opt/dovid/radio/check_moh_class.sh ${MOH_ID}&)
The script has in it
CALLS=$(/usr/sbin/asterisk -rx'core show channels concise' | grep WaitDigit | grep moh_$1 |wc -l)
if [ "$CALLS" -eq "0" ]; then
asterisk -rx"moh unregister class $1"
exit;
fi
I have been having random CPU and load spikes on my boxes and I was never able to figure out why. Today I was manually hanging up on a bunch of calls (about 75 calls) and this was invoked once per call. The audio quality became horrible and I saw that the load and CPU usage spiked. I did this test a few time and every time I got the same result. I have since changed over to a script that connects via the AMI and checks every 60 sesconds all calls and see’s if there are any classes that can be unregistered.
I am writing this question more to understand what I was doing that was causing Asterisk to spike the load on the box so I can further learn.