Add more details to check_reboot_required, adding packages to the output string
This commit is contained in:
parent
dee3bce537
commit
4d63d9f3e9
@ -7,17 +7,25 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
rr="/var/run/reboot-required"
|
rr="/var/run/reboot-required"
|
||||||
|
rrpkgs="/var/run/reboot-required.pkgs"
|
||||||
# 604800 - 1 week in seconds
|
# 604800 - 1 week in seconds
|
||||||
threshold="${1:-604800}"
|
threshold="${1:-604800}"
|
||||||
if [ -f "$rr" ]; then
|
if [ -f "$rr" ]; then
|
||||||
# We have a pending reboot; alert in different states depending on its age
|
# We have a pending reboot; alert in different states depending on its age
|
||||||
lastmod=$(date +%s -r "$rr")
|
lastmod=$(date +%s -r "$rr")
|
||||||
now=$(date +%s)
|
now=$(date +%s)
|
||||||
|
pkgs="$(cat "$rr")"
|
||||||
|
if [ -f "$rrpkgs" ]; then
|
||||||
|
pkgs="$(cat "$rrpkgs")"
|
||||||
|
fi
|
||||||
|
if [ -z "$pkgs" ]; then
|
||||||
|
pkgs="(No output)"
|
||||||
|
fi
|
||||||
if (( now - lastmod > threshold )); then
|
if (( now - lastmod > threshold )); then
|
||||||
echo "CRITICAL - Pending reboot older than $threshold seconds: $(cat "$rr")"
|
echo "CRITICAL - Pending reboot older than $threshold seconds: $pkgs"
|
||||||
exit 2
|
exit 2
|
||||||
else
|
else
|
||||||
echo "WARNING - Pending reboot: $(cat "$rr")"
|
echo "WARNING - Pending reboot: $pkgs"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user