asterisk’s zombie processes

Home » Asterisk Users » asterisk’s zombie processes
Asterisk Users 3 Comments

Hi,

You can run the script below as an hourly cron. Works for me.

#!/bin/sh

# clean-up Asterisk zombies

# file clean_up.sh

# $Id: clean_up all dead parent processes

# use as cron task */30 * * * * root /usr/local/sbin/clean_up.sh

#########

##LOG=/var/log/asterisk/agi-cleanup.log

date=`date +%d-%m-%Y_%Hh%Mm`

t1=`cat /proc/stat | grep btime | awk ‘{print $2}’`

t3=`date +%s`

echo “$date – Asterisk Zombies Clean up started…..” #### >> $LOG

echo “”

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 “Zombie found – killing $i” ### >> $LOG

fi

done

done

done

exit

From: asterisk-users-bounces@lists.digium.com
[mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Steve Edwards
Sent: Wednesday, May 18, 2011 1:48 PM
To: Asterisk Users Mailing List – Non-Commercial Discussion
Subject: Re: [asterisk-users] asterisk’s zombie processes

On Wed, 18 May 2011, vip killa wrote:

> I’m monitoring Asterisk with Nagios. Nagios constantly alerts because of
> too many zombie processes. I eventually had to disable the notification
> for the alert but why does Asterisk create so many zombie processes,
> I’ve see more than 30 at times and it generally stays in the 20s… just
> seems unusual and wondering if it’s harmful, thanks in advance.

Asterisk creates threads, not processes.

Trace back from the PPID of the zombies to see who created them

3 thoughts on - asterisk’s zombie processes

  • I’m sure it’s not nagios. I’m not running “check_sip” and i’m running
    nagios’ NRPE on several other machines that do not have asterisk running.

  • Actually not sure if it is asterisk generating these zombies… i’m starting
    to believe it’s the enswitch_routed daemon, anybody familiar with enswitch?