Asterisk tips & tricks
here a useful contribution to use for Asterisk 1.x memory safety
still Astersik 1.x can be hang after many current processes
this shell script clean_up.sh provide to save the memory
#!/bin/sh
###########################################################################
#
# clean-up Asterisk zombies
# file clean_up.sh
# $Id: clean_up all parent dead Asterisk AGI processes, v 1.0 2006/05/10 bb Exp $
# (c)2006 Claude Fanac http://www.a-enterprise.ch
#
# used as cron task */30 * * * * root /usr/local/sbin/clean_up.sh
#
###########################################################################
LOG=/var/log/asterisk/cleanUP.log
date=`date`
t1=`cat /proc/stat | grep btime | awk '{print $2}'`
t3=`date +%s`
echo "$date New Clean UP " >> $LOG
for parent in `ps -ef | grep safe_asterisk | awk '$3 == '1'{print $2}'`
do
for ppid in ` ps -ef | awk '$3 == '${parent}' { print $2 }' `
do
for i in ` ps -ef | awk '$3 == '${ppid}' { print $2 }' `
do
t2=`cat /proc/$i/stat| awk '{print $22}'`
b=$(($t3-$t1));
c=$(($t2/100));
d=$((($b-$c)/60));
if [ $d -gt 30 ] ; then
kill -9 $i
echo "$date killing $i" >> $LOG
fi
done
done
done
Questions? dont hesitate to ask me: [email protected]
More tips & tricks? Find here https://www.a-enterprise.ch/