Hi, I have encountered this problem recently as well. The check compares the running kernel version with the wrong installed version.
It seems to me the problem is created by not using version sort[0] with the result that in the original bug reporter's case 3.2.0-4-amd64 is seen as bigger than 3.16.0-4-amd64, or that 4.9.0-8-amd64 is seen as more recent than 4.18.6-1~bpo9+1 in my case. In my case the output of the check is as follows: # /usr/lib/nagios/plugins/check_running_kernel WARNING: Running kernel does not match on-disk kernel image: [Linux version 4.18.0-0.bpo.1-amd64 (debian-ker...@lists.debian.org) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #1 SMP Debian 4.18.6-1~bpo9+1 (2018-09-13) != Linux version 4.9.0-8-amd64 (debian-ker...@lists.debian.org) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1) ) #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30)] Simply using version sort (adding option -V to sort) solves the problem: # ./check_running_kernel.fixed_version_sorting OK: Running kernel matches on disk image: [Linux version 4.18.0-0.bpo.1-amd64 (debian-ker...@lists.debian.org) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #1 SMP Debian 4.18.6-1~bpo9+1 (2018-09-13)] Please see the attached patch. Please consider applying the attached patch or a similar fix to the Debian package. Thanks, Erik [0] https://www.gnu.org/software/coreutils/manual/html_node/Details-about-version-sort.html -- Dipl.-Inform. Erik Auerswald http://www.fg-networking.de/ auersw...@fg-networking.de T:+49-631-4149988-0 M:+49-176-64228513 Gesellschaft für Fundamental Generic Networking mbH Geschäftsführung: Volker Bauer, Jörg Mayer Gerichtsstand: Amtsgericht Kaiserslautern - HRB: 3630
--- /usr/lib/nagios/plugins/check_running_kernel 2017-02-22 14:32:22.000000000 +0100 +++ check_running_kernel.fixed_version_sorting 2018-10-02 11:28:55.258937352 +0200 @@ -92,7 +92,7 @@ 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 -u); do + 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 if dpkg --compare-versions "1.$vers" gt "1.$imagename"; then imagename=$vers fi @@ -185,8 +185,8 @@ 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) \ - $([ -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 + $([ -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 if [ -e "$on_disk" ]; then if [ -z "$STRINGS" ]; then