aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/oscar/rxqueue.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-08-21 23:42:01 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-08-21 23:42:01 +0100
commit4022b686cce05eb9a42b744335abd09d5ae7d0f0 (patch)
treefe827cdf6aef1fe7c3e9d0458848be3edda60ea1 /protocols/oscar/rxqueue.c
parent327af51a28fe292cfc4a68caa086a13175a69719 (diff)
parentc00dd7117be2a5fda92d6f7d72b0e4e54fa5d615 (diff)
Merge mainline.
Diffstat (limited to 'protocols/oscar/rxqueue.c')
0 files changed, 0 insertions, 0 deletions
ef='#n116'>116 117 118 119 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;
}