• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Too many open files..

tkalfaoglu

Silver Pleskian
Server operating system version
Alma Linux 8.8
Plesk version and microupdate number
Obsidian
I wrote a little chron thing that warns me when there are too many open files (which can be fatal on the server)..
I got a warning at 4 AM..

The open files number comes from /proc/sys/fs/file-nr, the 42 thousand..

Apparently my script that lists the open files doesn't work as well as I hoped -- it's missing lots of things as it only found ~15K files.

Anyway, what could be the cause of too many open files?

Many thanks,
-t


It says:

3 Jun 2023 04:05:02 current open files at 42016

108 (sd-pam)
130 /usr/libexec/postfix/master
142 smtpd
202 dovecot/imap-login
240 /opt/plesk/php/8.0/bin/php-cgi
244 /usr/sbin/dovecot
252 Passenger
267 dovecot/imap
267 dovecot/imap
386 php-fpm:
408 /opt/plesk/php/7.4/bin/php-cgi
423 /usr/lib/systemd/systemd
1983 /usr/libexec/mysqld
3217 /usr/sbin/httpd
4856 nginx:
TOTAL: 14968
 
I'd need to see your script to get a better idea of why the output is different. Open files can change very quickly, so the script may be a millisecond too late and get fewer files than the alert got.

For example, this will tell you how many open files each process is using, but it will take a while to run, so the actual number will be different by the time it finishes:
Code:
lsof | awk '{ print $1 " " $2; }' | sort -rn | uniq -c | sort -rn | head -15
/proc/sys/fs/file-nr shows allocated file handles, not open files. These indicate whether a process has active connections to a file. A single process can assign multiple handles to the same file, so there can be multiple handles for a single file. This could be the reason for the 15K to 42K difference.
 
Back
Top