From 4a87f6c1d66e39b6520bccae3d22a7bab974b456 Mon Sep 17 00:00:00 2001 From: Michael Howe Date: Wed, 2 Jun 2021 22:21:45 +0100 Subject: [PATCH] Merge in check_running_kernel changes monitoring-plugins-contri 35.20210511 looks to work; unfortunately that's not available until bullseye --- debian/changelog | 5 +++-- plugins/check_running_kernel | 16 ++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 39ce03d..152808d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,10 @@ -nagios-plugins-local (0.22~test.1) UNRELEASED; urgency=medium +nagios-plugins-local (0.22) unstable; urgency=medium * New version of check_mqtt, from https://github.com/jpmens/check-mqtt/ This adds python3 support and works with buster. + * Merge in check_running_kernel changes from 35.20210511 - -- Michael Howe Sat, 09 Jan 2021 14:35:02 +0000 + -- Michael Howe Wed, 02 Jun 2021 22:21:26 +0100 nagios-plugins-local (0.21) unstable; urgency=medium diff --git a/plugins/check_running_kernel b/plugins/check_running_kernel index cb0c109..b74e261 100755 --- a/plugins/check_running_kernel +++ b/plugins/check_running_kernel @@ -94,7 +94,7 @@ get_avail() { local imagename=0 # --no-all-versions show shows only the candidate - for vers in $(apt-cache --no-all-versions show ${prefix}-image-${metavers} | sed -n 's/^Depends: //p' | tr ',' '\n' | tr -d ' ' | grep ${prefix}-image | awk '{print $1}' | sort -Vu); do + for vers in $(apt-cache --no-all-versions show ${prefix}-image-${metavers} | sed -n 's/^Depends: //p' | sed -e 's/ (.*)$//' | tr ',' '\n' | tr -d ' ' | grep ${prefix}-image | awk '{print $1}' | sort -Vu); do if dpkg --compare-versions "1.$vers" gt "1.$imagename"; then imagename=$vers fi @@ -132,8 +132,8 @@ cat_vmlinux() { filter="$3" hdroff="$4" - if ! which $filter >/dev/null; then - echo "UNKNOWN: filter command '$filter' missing, perhaps install xz-utils?" >&2 + if ! which ${filter%% *} >/dev/null; then + echo "UNKNOWN: filter command '$filter' missing, perhaps install xz-utils, lz4 or lzop?" >&2 exit $UNKNOWN fi @@ -157,7 +157,11 @@ get_image_linux() { cat_vmlinux "$image" "\x00\x00\x00\x02\xff" "xzcat" -1 cat_vmlinux "$image" "\x00\x00\x00\x04\xff" "xzcat" -1 # xz compressed image - cat_vmlinux "$image" "\xfd\x37\x7a\x58\x5a " "xzcat" 0 + cat_vmlinux "$image" "\xfd\x37\x7a\x58\x5a" "xzcat" 0 + # lz4 compressed image + cat_vmlinux "$image" "\x02\x21\x4c\x18" "lz4 -dc" 0 + # lzo compressed image + cat_vmlinux "$image" "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a" "lzop -dc" 0 echo "ERROR: Unable to extract kernel image." 2>&1 exit 1 @@ -188,8 +192,8 @@ fi searched="" for on_disk in \ - $([ -f "/boot/vmlinuz-$(uname -r)" ] && find /boot/ -name 'vmlinuz*' -and -name "vmlinuz-$(uname -r)" -or -name 'vmlinuz*' -and -newer "/boot/vmlinuz-$(uname -r)" | sort -V) \ - $([ -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 -V); do + $([ -f "/boot/vmlinuz-$(uname -r)" ] && find /boot/ -maxdepth 1 -name 'vmlinuz*' -and -name "vmlinuz-$(uname -r)" -or -name 'vmlinuz*' -and -newer "/boot/vmlinuz-$(uname -r)" | sort -V) \ + $([ -f "/boot/kfreebsd-$(uname -r).gz" ] && find /boot/ -maxdepth 1 -name 'kfreebsd*' -and -name "kfreebsd-$(uname -r).gz" -or -name 'kfreebsd*' -and -newer "/boot/kfreebsd-$(uname -r).gz" | sort -V); do if [ -e "$on_disk" ]; then if [ -z "$STRINGS" ]; then -- 2.39.5