Tuesday, October 09, 2007

Asterisk "too may open files"

Another quick Asterisk pointer.

If you are running a large amount of traffic on your Asterisk box you are likely to come across this message.

"unable to create from pipe: too many open files"

What this means is that Asterisk has exceeded the per-process limit on open files.

You can get the per-process limit for you system by opening a shell and typing 'ulimit -n'. My system, Ubuntu 7.04 is set at 1024.

I find that the easiest way to set this is by opening the /usr/sbin/safe_asterisk script and finding the existing line 'ulimit -c unlimited', and adding a line below that of 'ulimit -n 65536'.

The safe_asterisk script is a script commonly used to launch Asterisk because it will also monitor and restart Asterisk if it crashes. So when you use it to launch Asterisk, the line we added will be executed and will increase the limit for Asterisk.

Please note that you should only need to do this on Asterisk 1.2 systems. On Asterisk 1.4, the safe_asterisk script has been modified to do this out of the box.