Archive

Posts Tagged ‘kernel’

Various Nagios plugins

October 15th, 2009 No comments

I’ve now written several Nagios plugins and submitted them all to MonitoringExchange.

Here’s a quick summary:

  • check_temper for monitoring the temperature with a TEMPer USB thermometer
  • check_kernel for checking that the currently running kernel on an RPM-based system is the most recent installed kernel (not necessarily the latest available kernel in the repository)
  • check_aql_balance for monitoring the number of SMS text message credits on your AQL account[1]
  • check_k8temp for monitoring the temperature of an AMD K8 (e.g. Athlon or Sempron) CPU

[1] See my blog post if you are interested in setting up SMS alerts with Nagios

Checking for the latest kernel with Nagios

August 17th, 2009 No comments

I’ve just written a module for Nagios that will determine if the currently running kernel is the latest kernel available on the system. It will not tell you if there is a newer kernel in a yum repository or similar.

The main gotcha is that you need an RPM-based system for my script to work, e.g. RHEL, CentOS, Fedora and many others. It is most certainly not bulletproof, but it works on my systems.

All feedback welcome.

N.B. I’ve now published this module on Monitoring Exchange. Please download the plugin from there, as I will keep that copy up to date if there are changes in the future (and the copy on this page is likely to go out of date).

check_kernel

#!/usr/bin/perl -w

# Usage:   check_kernel

use strict;
use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS);

my $running_kernel=`uname -r`;
my $installed_kernel=`rpm -q kernel | tail -n 1`;
my $rpm = `which rpm`;

chomp $running_kernel;
chomp $installed_kernel;

if ($rpm =~ m/no rpm in/i) {
   print "UNKNOWN - You must be running an RPM-based system\n";
   exit $ERRORS{'UNKNOWN'};
}

if (!defined $running_kernel || !defined $installed_kernel) {
   print "UNKNOWN - Test failed\n";
   exit $ERRORS{'UNKNOWN'};
}

# Strip off the "kernel-" prefix so the strings will match
$installed_kernel =~ s/kernel-//gi;

# Do the test
if ($running_kernel eq $installed_kernel) {
   print "OK - running latest installed kernel ($running_kernel)\n";
   exit $ERRORS{'OK'};
} else {
   print "WARNING - reboot to run latest installed kernel ($installed_kernel)\n";
   exit $ERRORS{'WARNING'};
}
Categories: Guides, Linux, Nagios Tags: , , ,