aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--debian/changelog3
-rw-r--r--debian/sitesummary-client.install1
-rw-r--r--nagios-nrpe-commands.cfg1
-rwxr-xr-xnagios-plugins/check_kernel_status120
-rw-r--r--nagios-templates.cfg5
-rwxr-xr-xsitesummary-nodes4
7 files changed, 140 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 6ec3100..ee9aa3c 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,7 @@ pkgdir = $(libdir)/sitesummary
collectordir = $(pkgdir)/collect.d
perldir = $(datadir)/perl5
pkgvardir = /var/lib/sitesummary
+nagiosplugdir= $(pkgdir)/nagios-plugins
INSTALL = install
INSTALL_DATA = $(INSTALL) -m 644
@@ -83,6 +84,11 @@ install-client:
$(INSTALL) $$collector $(DESTDIR)$(collectordir); \
done
+ $(INSTALL) -d $(DESTDIR)$(nagiosplugdir)
+ for plugin in nagios-plugins/* ; do \
+ $(INSTALL) $$plugin $(DESTDIR)$(nagiosplugdir); \
+ done
+
clean:
$(RM) *~ */*~
distclean: clean
diff --git a/debian/changelog b/debian/changelog
index f138c74..a39c8a7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,6 +19,9 @@ sitesummary (0.0.59) UNRELEASED; urgency=low
autoconfig if /etc/default/nagios3 exist.
* Change munin configuration to use /var/cache/munin/www/ if it
exist, to work out of the box with munin 1.4.0 (Closes: #567168).
+ * Add new nagios pluing check_kernel_status to report the need for a
+ reboot to activate a new kernel. Written by Toni Van Remortel and
+ found at <URL: http://www.monitoringexchange.org >.
-- Petter Reinholdtsen <pere@debian.org> Tue, 26 Jan 2010 08:56:53 +0100
diff --git a/debian/sitesummary-client.install b/debian/sitesummary-client.install
index eb1f317..aa51d89 100644
--- a/debian/sitesummary-client.install
+++ b/debian/sitesummary-client.install
@@ -1,5 +1,6 @@
debian/tmp/etc/nagios
debian/tmp/usr/lib/sitesummary/collect.d
+debian/tmp/usr/lib/sitesummary/nagios-plugins
debian/tmp/usr/sbin/sitesummary-client
debian/tmp/usr/sbin/sitesummary-upload
debian/tmp/usr/share/sitesummary/sitesummary-client.conf
diff --git a/nagios-nrpe-commands.cfg b/nagios-nrpe-commands.cfg
index c264f3e..7ce030e 100644
--- a/nagios-nrpe-commands.cfg
+++ b/nagios-nrpe-commands.cfg
@@ -5,6 +5,7 @@ command[check_apt]=/usr/lib/nagios/plugins/check_apt
command[check_dhcp]=/usr/lib/nagios/plugins/check_dhcp
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_ftp]=/usr/lib/nagios/plugins/check_ftp -H localhost
+command[check_kernel_status]=/usr/lib/sitesummary/nagios-plugins/check_kernel_status
command[check_linux_raid]=/usr/lib/nagios/plugins/check_linux_raid
command[check_nfs]=/usr/lib/nagios/plugins/check_rpc -H localhost -C nfs -c2,3
command[check_ntp]=/usr/lib/nagios/plugins/check_ntp -H localhost
diff --git a/nagios-plugins/check_kernel_status b/nagios-plugins/check_kernel_status
new file mode 100755
index 0000000..b7faff6
--- /dev/null
+++ b/nagios-plugins/check_kernel_status
@@ -0,0 +1,120 @@
+#!/usr/bin/perl
+# check_kernel_status : check if the running kernel is the latest installed
+# By Toni Van Remortel [toni.van.remortel@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
+
+$OK = 0;
+$WARN = 1;
+$CRIT = 2;
+$UNKN = 3;
+
+# 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);
+ }
+ else
+ {
+ print "UNKNOWN - Cannot find running Ubuntu kernel version\n";
+ exit $UNKN;
+ }
+}
+elsif ( -e '/proc/version' )
+{
+ # Likely Debian
+ $sig = `cat /proc/version`;
+ if ( $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, $6);
+ }
+ 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 kernels here.
+# But I assume that you don't need reboots anymore when this major version has passed.
+$dpkg_list = `dpkg -l | grep linux-image-2.6`;
+chomp($dpkg_list);
+@dpkg_lines = split("\n", $dpkg_list);
+$dpkg = pop(@dpkg_lines);
+
+# 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.\n";
+ exit $UNKN;
+}
+
+# Calculate sums for easy comparison
+$running_version_sum = sprintf("%02d%02d%02d%02d%02d%02d", @running_version);
+$installed_version_sum = sprintf("%02d%02d%02d%02d%02d%02d", @installed_version);
+# And some readable format
+$print_running_version = sprintf("%d.%d.%d-%d.%d.%d", @running_version);
+$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/nagios-templates.cfg b/nagios-templates.cfg
index b38edfa..d751345 100644
--- a/nagios-templates.cfg
+++ b/nagios-templates.cfg
@@ -209,6 +209,11 @@ define command{
}
define command{
+ command_name check_kernel_status
+ command_line /usr/lib/sitesummary/nagios-plugins/check_kernel_status
+}
+
+define command{
command_name check-host-alive
command_line /usr/lib/nagios/plugins/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1
}
diff --git a/sitesummary-nodes b/sitesummary-nodes
index b4bffdc..ef326b5 100755
--- a/sitesummary-nodes
+++ b/sitesummary-nodes
@@ -356,6 +356,10 @@ sub generate_nagios_config {
print_nagios_service_check($remote, $hostname, "apt-updates",
"check_apt");
+ # Check if a kernel reboot is needed
+ print_nagios_service_check($remote, $hostname, "kernel status",
+ "check_kernel_status");
+
# print_nagios_service_check($remote, $hostname, "dhcp",
# "check_dhcp")
# if is_pkg_installed($hostid, "dhcp3-server");