From 05d6be51b89349ce82c4e913e563f0e3ae982032 Mon Sep 17 00:00:00 2001 From: Salt Date: Sat, 2 Oct 2021 14:39:19 -0500 Subject: [PATCH] Modify the reboot-required check to be more forgiving of the first few days after a package update --- check_reboot_required | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/check_reboot_required b/check_reboot_required index 8a82d2f..591dc2e 100755 --- a/check_reboot_required +++ b/check_reboot_required @@ -9,7 +9,9 @@ rr="/var/run/reboot-required" rrpkgs="/var/run/reboot-required.pkgs" # 604800 - 1 week in seconds -threshold="${1:-604800}" +threshold_crit="${1:-604800}" +# 259200 - 3 days in seconds +threshold_warn="${2:-259200}" if [ -f "$rr" ]; then # We have a pending reboot; alert in different states depending on its age lastmod=$(date +%s -r "$rr") @@ -21,12 +23,15 @@ if [ -f "$rr" ]; then if [ -z "$pkgs" ]; then pkgs="(No output)" fi - if (( now - lastmod > threshold )); then - echo "CRITICAL - Pending reboot older than $threshold seconds: $pkgs" - exit 2 - else - echo "WARNING - Pending reboot: $pkgs" + if (( now - lastmod < threshold_warn )); then + echo "OK - Pending reboot: $pkgs" + exit 0 + elif (( now - lastmod < threshold_crit )); then + echo "WARNING - Pending reboot older than $threshold_warn seconds: $pkgs" exit 1 + else + echo "CRITICAL - Pending reboot older than $threshold_crit seconds: $pkgs" + exit 2 fi else # We have no pending reboots