Added a new nagios-nrpe plugin: check_open_files
This commit is contained in:
parent
df891f6aee
commit
90a517af2d
25
nagios-nrpe/files/plugins/check_open_files
Normal file
25
nagios-nrpe/files/plugins/check_open_files
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
exitCode=0
|
||||
|
||||
for user in $(getent passwd | grep -ve root -e www-data | cut -d: -f1); do
|
||||
openFiles=$(lsof -n -u "$user" | wc -l)
|
||||
if [[ $openFiles -ge 3200 ]]; then
|
||||
echo "CRITICAL: $user has more than 3200 files opened!"
|
||||
exitCode=2
|
||||
elif [[ $openFiles -ge 2000 ]]; then
|
||||
echo "WARNING: $user has more than 2000 files opened!"
|
||||
if [[ $exitCode -ne 2 ]]; then
|
||||
exitCode=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $exitCode -eq 1 || $exitCode -eq 2 ]]; then
|
||||
exit $exitCode
|
||||
else
|
||||
echo "OK"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in a new issue