Last active
May 8, 2025 16:23
-
-
Save hvmonteiro/007cb36f44727b4df8bbfa4ec3ef6cb2 to your computer and use it in GitHub Desktop.
Check System and GitLab running processes Max Open Files (ulimit -n)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# description: Check System and GitLab running processes Max Open Files (ulimit -n) | |
# author: Hugo Monteiro (08-05-2025) | |
# | |
# System | |
echo "# System processes limit ---" | |
echo "" | |
echo "# System runtime configured Max Open File:" | |
echo "# allocated: the number of allocated file handles" | |
echo "# unused: the number of allocated but unused file handles" | |
echo "# maximum: the maximum number of file handles that the Linux kernel will allocate" | |
echo "" | |
echo "allocated unused maximum" | |
cat /proc/sys/fs/file-nr | |
echo "" | |
echo "" | |
# GitLab Processes | |
echo "# GitLab processes limit ---" | |
echo "" | |
echo "Process User Limit Soft Limit Hard Limit Units" | |
old_max_open_files="" | |
for user in $(grep '^gitlab' /etc/passwd | cut -d: -f1); do | |
for pid in $(ps -u $user -o pid=); do | |
max_open_files="$(cat /proc/$pid/limits | grep 'Max open files')" | |
if [ "$old_max_open_files" != "max_open_files" ]; then | |
old_max_open_files=$max_open_files | |
echo -e "$pid $user $max_open_files" | |
fi | |
done | |
done | |
echo "Hint: Check if shown open files values are different from what is supposed to be configured under '/etc/sysctl.d' and '/etc/security/limits.d' directories." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment