[Pkg-nagios-changes] [pkg-nagios-plugins-contrib] 06/18: Add check_kernel_status module from the sitesummary-client package.
Bernd Zeimetz
bernd at bzed.de
Wed Oct 1 11:13:16 UTC 2014
This is an automated email from the git hooks/post-receive script.
bzed pushed a commit to branch master
in repository pkg-nagios-plugins-contrib.
commit b63d12999ffa00f6b1108c21fceeeae12e260c77
Author: Petter Reinholdtsen <pere at hungry.com>
Date: Thu Sep 11 10:45:24 2014 +0200
Add check_kernel_status module from the sitesummary-client package.
---
check_kernel_status/Makefile | 5 ++
check_kernel_status/check_kernel_status | 136 ++++++++++++++++++++++++++++++++
check_kernel_status/control | 6 ++
check_kernel_status/copyright | 14 ++++
4 files changed, 161 insertions(+)
diff --git a/check_kernel_status/Makefile b/check_kernel_status/Makefile
new file mode 100644
index 0000000..66f0c07
--- /dev/null
+++ b/check_kernel_status/Makefile
@@ -0,0 +1,5 @@
+#/usr/bin/make -f
+
+PLUGIN = check_kernel_status
+
+include ../common.mk
diff --git a/check_kernel_status/check_kernel_status b/check_kernel_status/check_kernel_status
new file mode 100755
index 0000000..102b428
--- /dev/null
+++ b/check_kernel_status/check_kernel_status
@@ -0,0 +1,136 @@
+#!/usr/bin/perl
+# check_kernel_status : check if the running kernel is the latest installed
+# By Toni Van Remortel [toni.van.remortel at p-ops.be]
+# 2008-07-28
+# GPLv2
+# Downloaded from
+# http://www.monitoringexchange.org/attachment/download/Check-Plugins/Operating-Systems/Linux/Running-kernel-compared-to-installed-kernel-version/check_kernel_status
+
+use strict;
+use warnings;
+
+my $OK = 0;
+my $WARN = 1;
+my $CRIT = 2;
+my $UNKN = 3;
+
+my $sig;
+my @running_version;
+my @installed_version;
+
+# First, find the current running kernel version
+if ( -e '/proc/version_signature' )
+{
+ # Likely Ubuntu
+ $sig = `cat /proc/version_signature`;
+ if ( $sig =~ /.* (\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)-[generic|server]/ )
+ {
+ @running_version = ($1, $2, $3, $4, $5, 0);
+ }
+ else
+ {
+ print "UNKNOWN - Cannot find running Ubuntu kernel version\n";
+ exit $UNKN;
+ }
+}
+elsif ( -e '/proc/version' )
+{
+ # Likely Debian
+ $sig = `cat /proc/version`;
+ if (
+ # New format in kernel package version 3.2.32-1, match first to also work with
+ # kernel 3.13 and later in Debian.
+ $sig =~ / Debian (\d+)\.(\d+)\.(\d+)-(\d+)/
+
+ || $sig =~ /\(Debian (\d+)\.(\d+)\.(\d+)\.dfsg\.(\d+)-(\d+)\)/
+ || $sig =~ /\(Debian (\d+)\.(\d+)\.(\d+)\.dfsg\.(\d+)-(\d+)\w+(\d+)\)/
+ || $sig =~ /\(Debian (\d+)\.(\d+)\.(\d+)-(\d+).+?(\d+).+?(\d+)\)/
+ || $sig =~ /\(Debian (\d+)\.(\d+)\.(\d+)-(\d+)lenny(\d+)\)/
+
+ )
+ {
+ @running_version = ($1, $2, $3, $4, $5 || 0, $6 || 0);
+ }
+ else
+ {
+ print "UNKNOWN - Cannot find running Debian kernel version\n";
+ exit $UNKN;
+ }
+}
+else
+{
+ print "UNKNOWN - Cannot extract running kernel info\n";
+ exit $UNKN;
+}
+
+# Next, find the installed kernel version
+# Yes, as you can see, it is limited to 2.6 and 3.X kernels here.
+# But I assume that you don't need reboots anymore when this major
+# version has passed.
+my $dpkg_list = `COLUMNS=1024 dpkg -l`;
+my $dpkg;
+for my $line (split("\n", $dpkg_list)) {
+ chomp $line;
+ $dpkg = $line if ($line =~ m/^ii.+linux-image-(2.6|3.\d)/);
+}
+
+# Now, which OS is it, and which footprint do they use?
+if ( $dpkg =~ /(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)/ )
+{
+ # Ubuntu
+ @installed_version = ($1, $2, $3, $4, $5, 0);
+}
+elsif ( $dpkg =~ /(\d+)\.(\d+)\.(\d+)\.dfsg\.(\d+)-(\d+)\w+(\d+)/ )
+{
+ # Debian Etch and older
+ @installed_version = ($1, $2, $3, $4, $5, $6);
+}
+elsif ( $dpkg =~ /(\d+)\.(\d+)\.(\d+)\.dfsg\.(\d+)-(\d+) / )
+{
+ # Debian Etch and older
+ @installed_version = ($1, $2, $3, $4, $5, 0);
+}
+elsif ( $dpkg =~ /(\d+)\.(\d+)\.(\d+)-(\d+)\~.+?(\d+).+?(\d+)/ )
+{
+ # Debian Etch and older
+ @installed_version = ($1, $2, $3, $4, $5, $6);
+}
+elsif ( $dpkg =~ /Debian (\d+)\.(\d+)\.(\d+)\+(\d+)\+lenny(\d+)/ )
+{
+ # Debian Lenny
+ @installed_version = ($1, $2, $3, $4, $5, 0);
+}
+elsif ( $dpkg =~ /(\d+)\.(\d+)\.(\d+)-(\d+)lenny(\d+)/ )
+{
+ # Debian Lenny
+ @installed_version = ($1, $2, $3, $4, $5, 0);
+}
+elsif ( $dpkg =~ / (\d+)\.(\d+)\.(\d+)-(\d+)/ )
+{
+ # Debian Lenny
+ @installed_version = ($1, $2, $3, $4, 0, 0);
+}
+else
+{
+ print "UNKNOWN - Could not determine installed version ($dpkg).\n";
+ exit $UNKN;
+}
+
+# Calculate sums for easy comparison
+my $running_version_sum = sprintf("%02d%02d%02d%02d%02d%02d", @running_version);
+my $installed_version_sum = sprintf("%02d%02d%02d%02d%02d%02d", @installed_version);
+# And some readable format
+my $print_running_version = sprintf("%d.%d.%d-%d.%d.%d", @running_version);
+my $print_installed_version = sprintf("%d.%d.%d-%d.%d.%d", @installed_version);
+
+# Do we need a reboot?
+if ( $running_version_sum < $installed_version_sum )
+{
+ print "WARNING - Reboot required : running kernel = $print_running_version, installed kernel = $print_installed_version\n";
+ exit $WARN;
+}
+else
+{
+ print "OK - running kernel = $print_running_version, installed kernel = $print_installed_version\n";
+ exit $OK;
+}
diff --git a/check_kernel_status/control b/check_kernel_status/control
new file mode 100644
index 0000000..a66f387
--- /dev/null
+++ b/check_kernel_status/control
@@ -0,0 +1,6 @@
+Homepage: http://www.monitoringexchange.org/attachment/download/Check-Plugins/Operating-Systems/Linux/Running-kernel-compared-to-installed-kernel-version/check_kernel_status
+Uploaders: Toni Van Remortel <toni.van.remortel at p-ops.be>
+Description: plugin to check if the running Linux kernel is the latest installed
+ Compare the running kernel with the set of kernels installed in /boot/
+Recommends: dpkg
+Version: ?
diff --git a/check_kernel_status/copyright b/check_kernel_status/copyright
new file mode 100644
index 0000000..4299c9d
--- /dev/null
+++ b/check_kernel_status/copyright
@@ -0,0 +1,14 @@
+Copyright (C) 2008 Toni Van Remortel <toni.van.remortel at p-ops.be>
+
+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, see <http://www.gnu.org/licenses/>.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-nagios-plugins-contrib.git
More information about the Pkg-nagios-changes
mailing list