[asterisk-users] asterisk at 100% CPU, 1000's of log files

Tony Mountifield tony at softins.clara.co.uk
Thu Aug 30 08:17:35 CDT 2007


In article <094A73044298734FB7D58CAAA319E1D66AC5D7 at UBIQ-SERV1.ubiquisys.local>,
Adrian Marsh <Adrian.Marsh at ubiquisys.com> wrote:
> Thanks for the answers Tony/Tzafrir
> 
> I checked the disk usage stats, and they are constant throughout the
> period.  I have a script that runs through on-the-hour to clean out
> recordings >3hours old, and I monitor disk usage via SNMP.
> 
> I wonder though if a log file could also cause this? Maybe the debug
> logfile..  However, again the space "free" stats for the system are
> constant, and I'd be able to see a 2Gb drop when I cleaned the log
> directory..

Well if it were a logfile, Asterisk's auto-rotate when it receives a
SIGXFSZ would stop it writing to the huge logfile and so the signals
would stop. In your case they didn't stop, so it must have been another
kind of file.

Deleting a recording that is in progress will hide it from the directory
structure, but the file will still exist and keep growing until the
recording is terminated. In this case, you would not see the file using
"ls", but the free space would keep decreasing as the invisible file
grows. You would see a 2GB drop in disk usage, not when you deleted the
file, but when the (deleted) recording was terminated and the file closed,
e.g. by restarting Asterisk.

You can always use "lsof -p<pid>" to list the open files of an Asterisk
process. If a still-open file has been deleted, it will indicate that
with the comment "(deleted)".

> My logrotate setup is :
> 
> [root at ubiphone log]# grep asterisk /etc/logrotate.d/*
> /etc/logrotate.d/asterisk:/var/log/asterisk/messages
> /var/log/asterisk/debug /var/log/asterisk/*log {
> /etc/logrotate.d/asterisk:       /usr/sbin/asterisk -rx 'logger reload'
> > /dev/null 2> /dev/null
> [root at ubiphone log]#
> 
> Webmin  shows that logrotate (my first suspect) runs at 4:02 AM each
> day, but the CPU rate spiked at 11:25PM, so that doesn't match either..
> 
> 
> Is it "logrotate" or A*k itself that rotates the logs?  I thought it was
> A*k itself..

"logger rotate" tells Asterisk to do its own rotation, and Asterisk does
its own rotation if it gets a SIGXFSZ.

"logger reload" as in the logrotate example above just tells Asterisk to
close and re-open its logfiles, since the actual rotation was done by
logrotate instead.

Using logrotate with "logger reload" is just more flexible.

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list