Am 2015-03-09 15:40, schrieb Jonas Meurer:
Hi DSA and Debian Nagios maintainers,
please find attached patches that fix three issues with your nagios
plugin
script 'dsa-check-running-kernel', respectively 'check_running_kernel'
in
Debian package nagios-plugins-contrib:
apparently I sent you old and broken versions of my patches. Here we go
again. Patch 02 is exactly the same, patches 01 and 03 have changed.
Sorry
for the confusion. I tested the patches on Debian Jessie, Debian
Wheezy,
Ubuntu 14.10 and CentOS 6.
1/ detect missing filter (e.g. xzcat) and warn about it. (fixes
#780098)
2/ enhance sed regex on on_disk_version for vendor != Debian. Fixes
kernel
detection on Ubuntu installations.
3/ iterate over all installed kernels that are either equal to or have
a
newer timestamp than running kernel. Fixes detection of newer
kernels
for new kernel releases, e.g. in Debian unstable, Debian testing.
Additionally fixes kernel update detection on distros that have a
different policy regarding kernel security updates and install a new
kernel file at every update, like Red Hat based distros.
All patches are against head (a3a621a387886e12a23fcf3d1c0837b7a5a5db14)
of
git repository https://db.debian.org/git/dsa-nagios.git.
Cheers,
jonas
From 3ce240b4e6a38e9c244bbd9ec9015ee2c4a31a89 Mon Sep 17 00:00:00 2001
From: Jonas Meurer <[email protected]>
Date: Mon, 9 Mar 2015 15:49:59 +0100
Subject: [PATCH 1/3] detect missing filter (e.g. xzcat) and warn about it.
---
dsa-nagios-checks/checks/dsa-check-running-kernel | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/dsa-nagios-checks/checks/dsa-check-running-kernel b/dsa-nagios-checks/checks/dsa-check-running-kernel
index 6a6994b..32b5a9e 100755
--- a/dsa-nagios-checks/checks/dsa-check-running-kernel
+++ b/dsa-nagios-checks/checks/dsa-check-running-kernel
@@ -129,6 +129,11 @@ cat_vmlinux() {
filter="$3"
hdroff="$4"
+ if ! which $filter >/dev/null; then
+ echo "UNKNOWN: filter command '$filter' missing, perhaps install xz-utils?" >&2
+ exit $UNKNOWN
+ fi
+
get_offset "$image" $header | head -n 5 | while read off; do
(if [ "$off" != 0 ]; then
dd ibs="$((off+hdroff))" skip=1 count=0
--
1.7.10.4
From 446b42c56eb60bfdcb30189a0f6c45dc3064d45b Mon Sep 17 00:00:00 2001
From: Jonas Meurer <[email protected]>
Date: Mon, 9 Mar 2015 15:50:51 +0100
Subject: [PATCH 2/3] enhance sed regex on on_disk_version for vendor !=
Debian. Fixes kernel detection on Ubuntu installations.
---
dsa-nagios-checks/checks/dsa-check-running-kernel | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dsa-nagios-checks/checks/dsa-check-running-kernel b/dsa-nagios-checks/checks/dsa-check-running-kernel
index 32b5a9e..cd85286 100755
--- a/dsa-nagios-checks/checks/dsa-check-running-kernel
+++ b/dsa-nagios-checks/checks/dsa-check-running-kernel
@@ -199,7 +199,7 @@ for on_disk in \
if [ -x /usr/bin/lsb_release ] ; then
vendor=$(lsb_release -i -s)
if [ -n "$vendor" ] && [ "xDebian" != "x$vendor" ] ; then
- on_disk_version=$( echo $on_disk_version|sed -e "s/ ($vendor [[:alnum:]\.-]\+ [[:alnum:]\.]\+)//")
+ on_disk_version=$( echo $on_disk_version|sed -e "s/ ($vendor [[:alnum:]\.-]\+ [[:alnum:]\.-]\+)//")
fi
fi
[ -z "$on_disk_version" ] || break
--
1.7.10.4
From 9c6e51d8b229592b79e925d860edda179c5855ad Mon Sep 17 00:00:00 2001
From: Jonas Meurer <[email protected]>
Date: Mon, 9 Mar 2015 15:52:23 +0100
Subject: [PATCH 3/3] iterate over all installed kernels that are either equal
to or have a newer timestamp than running kernel. Fixes
detection of newer kernels for new kernel releases,
e.g. in Debian unstable, Debian testing. Additionally
fixes kernel update detection on distros that have a
different policy regarding kernel security updates and
install a new kernel file at every update, like Red Hat
based distros.
---
dsa-nagios-checks/checks/dsa-check-running-kernel | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/dsa-nagios-checks/checks/dsa-check-running-kernel b/dsa-nagios-checks/checks/dsa-check-running-kernel
index cd85286..c508eb0 100755
--- a/dsa-nagios-checks/checks/dsa-check-running-kernel
+++ b/dsa-nagios-checks/checks/dsa-check-running-kernel
@@ -185,9 +185,8 @@ fi
searched=""
for on_disk in \
- "/boot/vmlinuz-`uname -r`"\
- "/boot/vmlinux-`uname -r`"\
- "/boot/kfreebsd-`uname -r`.gz"; do
+ $([ -f "/boot/vmlinuz-$(uname -r)" ] && find /boot/ -name 'vmlinuz*' -and -name "vmlinuz-$(uname -r)" -or -name 'vmlinuz*' -and -newer "/boot/vmlinuz-$(uname -r)" | sort) \
+ $([ -f "/boot/kfreebsd-$(uname -r).gz" ] && find /boot/ -name 'kfreebsd*' -and -name "kfreebsd-$(uname -r).gz" -or -name 'kfreebsd*' -and -newer "/boot/kfreebsd-$(uname -r).gz" | sort); do
if [ -e "$on_disk" ]; then
if [ -z "$STRINGS" ]; then
@@ -202,9 +201,9 @@ for on_disk in \
on_disk_version=$( echo $on_disk_version|sed -e "s/ ($vendor [[:alnum:]\.-]\+ [[:alnum:]\.-]\+)//")
fi
fi
- [ -z "$on_disk_version" ] || break
+ [ -z "$on_disk_version" ] || continue
on_disk_version="`cat "$on_disk" | $STRINGS | grep 'Linux version' | head -n1`"
- [ -z "$on_disk_version" ] || break
+ [ -z "$on_disk_version" ] || continue
echo "UNKNOWN: Failed to get a version string from image $on_disk"
exit $UNKNOWN
--
1.7.10.4