Drop check_kernel in favor of check_running_kernel, add plugin command.

Refs #6369
This commit is contained in:
Michael Friedrich 2014-06-02 13:34:35 +02:00
parent bc446bb8b5
commit 9225f7ed00
5 changed files with 15 additions and 73 deletions

View File

@ -2,6 +2,5 @@ object Service "kernel" {
import "generic-service"
host_name = "localhost"
check_command = "kernel"
check_command = "running_kernel"
}

View File

@ -2077,3 +2077,11 @@ nrpe_timeout | **Optional.** The timeout in seconds.
Check command for the `check_apt` plugin.
The `apt` check command does not support any vars.
#### <a id="plugin-check-command-running-kernel"></a> ups
Check command object for the `check_running_kernel` plugin
provided by the `nagios-plugins-contrib` package on Debian.
The `running_kernel` check command does not support any vars.

View File

@ -1,11 +1,5 @@
/* Command objects */
object CheckCommand "kernel" {
import "plugin-check-command"
command = [ SysconfDir + "/icinga2/scripts/check_kernel" ]
}
object NotificationCommand "mail-host-notification" {
import "plugin-notification-command"

View File

@ -1,65 +0,0 @@
#!/bin/bash
# Icinga 2
# Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
if [ -e /etc/debian_version ]; then
if [ "$(lsb_release -s -i)" = "Debian" ]; then
latest_kernel=$(dpkg-query -W -f='${Version}' linux-image-$(uname -r))
current_kernel=$(uname -v | awk '{print $4}')
if [ "x$latest_kernel" != "x$current_kernel" ]; then
echo "A kernel upgrade is available: $(uname -r) ($latest_kernel) - currently running: $(uname -r) ($current_kernel)"
exit 2
fi
else
IFS=$'\n'
for pkginfo in $(dpkg-query -W -f '${Source}\t${Depends}\n' 'linux-image-*'); do
source=$(echo $pkginfo | cut -f1 -d$'\t')
if [ "$source" != "linux-meta" -a "$source" != "linux-latest" ]; then
continue
fi
depends=$(echo $pkginfo | cut -f2 -d$'\t')
IFS=','
for depend in $depends; do
name=$(echo $depend | awk '{print $1}')
if ! echo $name | grep -E linux-image-[0-9] >/dev/null; then
continue
fi
version=$(echo $depend | cut -f3- -d-)
if [ "$name" != "linux-image-$(uname -r)" ]; then
echo "A kernel upgrade is available: $version - currently running: $(uname -r)"
exit 2
fi
done
IFS=$'\n'
done
fi
elif [ -e /etc/redhat-release ]; then
latest_kernel=`rpm -q --last kernel | head -n 1 | awk '{print $1}' | cut -f2- -d-`
current_kernel=`uname -r`
if [ "x$latest_kernel" != "x$current_kernel" ]; then
echo "A kernel upgrade is available: $latest_kernel - currently running: $current_kernel"
exit 2
fi
else
echo "Unsupported OS/distribution."
exit 3
fi
echo "Kernel version: `uname -a`"
exit 0

View File

@ -453,3 +453,9 @@ object CheckCommand "nrpe" {
vars.nrpe_timeout_unknown = false
}
/* Contrib plugins */
object CheckCommand "running_kernel" {
import "plugin-check-command"
command = PluginDir + "/check_running_kernel"
}