Too many files open

Hello
We are using asterisk
LibPRI 1.4.11.5
Installed DAHDI 2.4.1.
Installed Asterisk 1.6.2.17.2.
Ubuntu 10.04

We have a SIP trunk setup that goes to a NEC PBX. Every several weeks the system crashes and needs to be restarted, They can not make or recieve calls.
When we look into the logs we see the following.

Got SIP response 503 “Service Unavailable” back from 172.31.80.9
– SIP/trunk-000001cb is circuit-busy
== Everyone is busy/congested at this time (1:0/1/0)
– Auto fallthrough, channel ‘SIP/trunk-000001ca’ status is ‘CONGESTION’

Then we see

[Jun 14 14:23:35] WARNING[926]: rtp.c:2491 rtp_socket: Unable to allocate RTCP socket: Too many open files
== Using SIP RTP CoS mark 5
[Jun 14 14:23:35] ERROR[926]: res_timing_timerfd.c:105 timerfd_timer_open: Failed to create timerfd timer: Too many open files
[Jun 14 14:23:35] WARNING[926]: channel.c:829 __ast_channel_alloc_ap: Channel allocation failed: Can’t create alert pipe! Try increasing max file descriptors with ulimit -n
[Jun 14 14:23:35] WARNING[926]: chan_sip.c:6630 sip_new: Unable to allocate AST channel structure for SIP channel
[Jun 14 14:23:35] NOTICE[926]: chan_sip.c:20354 handle_request_invite: Unable to create/find SIP channel for this INVITE

Finally we see the following

[Jun 14 14:36:42] WARNING[798]: asterisk.c:1280 listener: Accept returned -1: Too many open files
[Jun 14 14:36:42] WARNING[798]: asterisk.c:1280 listener: Accept returned -1: Too many open files
[Jun 14 14:36:42] WARNING[798]: asterisk.c:1280 listener: Accept returned -1: Too many open files
[Jun 14 14:36:42] WARNING[798]: asterisk.c:1280 listener: Accept returned -1: Too many open files
This message repeats itself thousands of times.
Any ideas what could be causing the problem?
Rebooting the server fixes the problem however it comes back around every 3 weeks.

A file descriptor leak (which would be an Asterisk bug), or too low a ulimit for the number of open files (an operating system configuration error).

Knowing whether there was a channel or SIP channel leak would probably help (run core show channels and sip show channels, and see whether the number settles down or continuously increases).

Thank you David 55 for your input. I am going to keep an eye on these to see if I can see them increasing.

Really appreciate your help.

Dean