From 90a517af2dabb8e962cd9e2ec948d613e60edeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20S=C3=89RIE?= Date: Mon, 19 Feb 2018 14:17:53 +0100 Subject: [PATCH] Added a new nagios-nrpe plugin: check_open_files --- nagios-nrpe/files/plugins/check_open_files | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 nagios-nrpe/files/plugins/check_open_files diff --git a/nagios-nrpe/files/plugins/check_open_files b/nagios-nrpe/files/plugins/check_open_files new file mode 100644 index 00000000..33e52744 --- /dev/null +++ b/nagios-nrpe/files/plugins/check_open_files @@ -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 + +