diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2011-12-25 23:29:06 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2011-12-25 23:29:06 +0000 |
commit | 1d29ac00d5d4b693cbbdb697ac4d323df93ca0b9 (patch) | |
tree | 64a3e838aca9086cef9df7e528351288ee0d8236 | |
parent | 7125b7aa3c30fe19b0072faca71b18402af3abdb (diff) | |
download | sitesummary-1d29ac00d5d4b693cbbdb697ac4d323df93ca0b9.tar.gz sitesummary-1d29ac00d5d4b693cbbdb697ac4d323df93ca0b9.tar.bz2 sitesummary-1d29ac00d5d4b693cbbdb697ac4d323df93ca0b9.tar.xz |
Improve error reporting from Nagios plugin check_kernel_status.
Make it more robust by telling dpkg -l to not cut long lines when
looking for kernel versions.
-rw-r--r-- | debian/changelog | 8 | ||||
-rwxr-xr-x | nagios-plugins/check_kernel_status | 17 |
2 files changed, 18 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog index 2157e09..31ec404 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +sitesummary (0.0.75) UNRELEASED; urgency=low + + * Improve error reporting from Nagios plugin check_kernel_status. + Make it more robust by telling dpkg -l to not cut long lines when + looking for kernel versions. + + -- Petter Reinholdtsen <pere@debian.org> Mon, 26 Dec 2011 00:14:41 +0100 + sitesummary (0.0.74) unstable; urgency=low * Add munin include dir to default munin config to match recent diff --git a/nagios-plugins/check_kernel_status b/nagios-plugins/check_kernel_status index cd1c96d..59bbc49 100755 --- a/nagios-plugins/check_kernel_status +++ b/nagios-plugins/check_kernel_status @@ -58,12 +58,15 @@ else } # 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. -my $dpkg_list = `dpkg -l | grep linux-image-2.6`; -chomp($dpkg_list); -my @dpkg_lines = split("\n", $dpkg_list); -my $dpkg = pop(@dpkg_lines); +# Yes, as you can see, it is limited to 2.6 and 3.0 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.0)/); +} # Now, which OS is it, and which footprint do they use? if ( $dpkg =~ /(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)/ ) @@ -103,7 +106,7 @@ elsif ( $dpkg =~ / (\d+)\.(\d+)\.(\d+)-(\d+)/ ) } else { - print "UNKNOWN - Could not determine installed version.\n"; + print "UNKNOWN - Could not determine installed version ($dpkg).\n"; exit $UNKN; } |