-
Hahn Axel (hahn) authoredHahn Axel (hahn) authored
check_reboot_required 1.49 KiB
#!/bin/bash
# ======================================================================
#
# NAGIOS CLIENT CHECK :: is a restart required?
#
# ----------------------------------------------------------------------
# works for sure on
# - centos7
# - debian6,7
# - ubuntu10,12
# ----------------------------------------------------------------------
# 2016-08-12 added ouput of packages
# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# ======================================================================
. `dirname $0`/inc_pluginfunctions
distro=`ph.getOS`
# ----------------------------------------------------------------------
case $distro in
"centos")
currentkernel=`uname -r`
out=`rpm -q --last kernel | head -1 | fgrep $currentkernel`
if [ -z "$out" ]; then
ph.setStatus "warning"
ph.status "[$distro] need to reboot for kernel `rpm -q --last kernel | head -1` (current: $currentkernel)"
else
ph.status "[$distro] no reboot required (kernel is up to date: $currentkernel)"
fi
;;
"debian"|"ubuntu")
if [ ! -f /var/run/reboot-required ]; then
ph.status "[$distro] no reboot required"
else
ph.setStatus "warning"
ph.status "[$distro] `cat /var/run/reboot-required` by `tr '\n' ',' </var/run/reboot-required.pkgs`"
fi
;;
*)
ph.abort "UNKNOWN: distro [$distro] was detected but is not supported (yet)."
;;
esac
ph.exit
# ----------------------------------------------------------------------