Bash
public
File Descriptor Usage
Share this script safely, inspect its metadata, and copy the exact command you need.
Ready to run
One-liner
curl -fsSL https://runny.sh/r/K104S9K0DD79 | bash
Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.450
At a glance
Script metadata
Readable before runnable
Preview
#!/usr/bin/env bash
# File descriptor usage
# Read-only: /proc/sys/fs/file-nr allocated vs max. Warns at >=80%, critical at >=95%.
# Exit 0 if healthy, 1 if warning, 2 if critical or the proc file is missing.
# Hosted on Runny.sh. Review the script page before you run it.
set -u
status=0
note() { printf '%s\n' "$*"; }
bump() {
case $1 in
crit) status=2 ;;
warn) [ "$status" -lt 1 ] && status=1 ;;
esac
}
note "=== File descriptor usage ==="
note "Host: $(hostname 2>/dev/null || printf unknown)"
if [ ! -r /proc/sys/fs/file-nr ]; then
note "/proc/sys/fs/file-nr is not readable"
note "Result: CRITICAL"
exit 2
fi
read -r allocated unused maximum _ < /proc/sys/fs/file-nr
note "Allocated:${allocated}"
note "Unused: ${unused}"
note "Maximum: ${maximum}"
if [ -z "${allocated}" ] || [ -z "${maximum}" ] || [ "$maximum" -le 0 ]; then
note " WARNING: could not parse file-nr"
bump warn
else
pct=$((allocated * 100 / maximum))
note "Used: ${pct}%"
if [ "$pct" -ge 95 ]; then
note " CRITICAL: process table file handles are nearly exhausted"
bump crit
elif [ "$pct" -ge 80 ]; then
note " WARNING: file-handle use is high"
bump warn
else
note " OK"
fi
fi
note ""
case $status in
0) note "Result: HEALTHY" ;;
1) note "Result: WARNING" ;;
*) note "Result: CRITICAL" ;;
esac
exit "$status"
Raw endpointhttps://runny.sh/r/K104S9K0DD79
See something unsafe?
Report this script
Tell us why it should come down. Anyone can also report a URL at /abuse.