You've already forked nrpe
uptime - add new version with override feature & switch warning / critical value
This commit is contained in:
+2
-2
@@ -57,5 +57,5 @@ nrpe_proc_age_critical: 600
|
|||||||
# nrpe_redis_replication_lag_warning: 10
|
# nrpe_redis_replication_lag_warning: 10
|
||||||
# nrpe_redis_replication_lag_critical: 60
|
# nrpe_redis_replication_lag_critical: 60
|
||||||
|
|
||||||
nrpe_uptime_warning: 30
|
nrpe_uptime_warning: 1440
|
||||||
nrpe_uptime_critical: 1440
|
nrpe_uptime_critical: 30
|
||||||
|
|||||||
+18
-5
@@ -6,16 +6,18 @@ STATE_WARNING=1
|
|||||||
STATE_CRITICAL=2
|
STATE_CRITICAL=2
|
||||||
STATE_UNKNOWN=3
|
STATE_UNKNOWN=3
|
||||||
|
|
||||||
# Default values (in minutes)
|
# Default values
|
||||||
warn=1440
|
warn=1440
|
||||||
crit=30
|
crit=30
|
||||||
|
OVERRIDE_FILE="/var/lib/nagios/uptime_override"
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
while getopts "w:c:" opt; do
|
while getopts "w:c:f:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
w) warn=$OPTARG ;;
|
w) warn=$OPTARG ;;
|
||||||
c) crit=$OPTARG ;;
|
c) crit=$OPTARG ;;
|
||||||
*) echo "Usage: $0 -w <minutes> -c <minutes>"; exit $STATE_UNKNOWN ;;
|
f) OVERRIDE_FILE=$OPTARG ;; # Permet de changer le chemin via Icinga
|
||||||
|
*) echo "Usage: $0 -w <minutes> -c <minutes> [-f <file_path>]"; exit $STATE_UNKNOWN ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -26,7 +28,18 @@ uptime_min=$((uptime_seconds / 60))
|
|||||||
# Performance Data
|
# Performance Data
|
||||||
PERFDATA="|uptime_min=${uptime_min}min;${warn};${crit};0;"
|
PERFDATA="|uptime_min=${uptime_min}min;${warn};${crit};0;"
|
||||||
|
|
||||||
# Decision logic
|
# 1. Vérification du fichier d'acquittement
|
||||||
|
if [ -f "$OVERRIDE_FILE" ]; then
|
||||||
|
# Si le système est redevenu "stable" naturellement, on supprime le flag
|
||||||
|
if [ "$uptime_min" -gt "$warn" ]; then
|
||||||
|
rm -f "$OVERRIDE_FILE"
|
||||||
|
else
|
||||||
|
echo "OK - Reboot acquitté manuellement (Uptime: ${uptime_min} min)$PERFDATA"
|
||||||
|
exit $STATE_OK
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Logique de décision standard
|
||||||
if [ "$uptime_min" -le "$crit" ]; then
|
if [ "$uptime_min" -le "$crit" ]; then
|
||||||
echo "CRITICAL - Recent reboot detected (${uptime_min} min < threshold ${crit} min)$PERFDATA"
|
echo "CRITICAL - Recent reboot detected (${uptime_min} min < threshold ${crit} min)$PERFDATA"
|
||||||
exit $STATE_CRITICAL
|
exit $STATE_CRITICAL
|
||||||
@@ -36,4 +49,4 @@ elif [ "$uptime_min" -le "$warn" ]; then
|
|||||||
else
|
else
|
||||||
echo "OK - System stable (Uptime: ${uptime_min} min)$PERFDATA"
|
echo "OK - System stable (Uptime: ${uptime_min} min)$PERFDATA"
|
||||||
exit $STATE_OK
|
exit $STATE_OK
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user