FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 04-12-2012, 05:05 PM
Bob Proulx
 
Default Checking for kernel freshness

Bernhard Schmidt wrote:
> Bob Proulx wrote:
> > Try this:
> >
> > $ cat /proc/version
> > Linux version 2.6.32-5-686 (Debian 2.6.32-41squeeze2) (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Mon Mar 26 05:20:33 UTC 2012
>
> God damnit. I was looking in /proc/sys/kernel and /sys/kernel, but not
> in /proc/version. Thanks! :-(

:-)

Oh, and try this:

$ perl -lne '$_ =~ m/Linux version S+ (Debian (S+))/ && print $1;' /proc/version
2.6.32-41squeeze2

Bob
 
Old 04-12-2012, 06:20 PM
keith
 
Default Checking for kernel freshness

Bernhard Schmidt wrote:

Hi,

the company I work for has a script on SLES/SuSE, that checks the
following three kernel versions

- latest version available in the repository
- version installed in /boot and thus likely to be loaded on next boot
- version running

and warns (and/or fixes) if there is a mismatch. I've been trying to
think of a way to do the same, but failed so far.

Latest version available in the repository is easy enough, just check
for the version the metapackage depends on (or, even easier, check for
updates of the kernel package).

Checking for the version in /boot is semi-easy (check the package
version installed and hope the user did not fiddle with grub), too.

The hard part seems to be matching the running kernel against the
version installed. I cannot figure out a good way so far. Nothing in the
running kernel seems to show the Debian version (i.e.
2.6.32-41squeeze2), thus I cannot compare it. It is printed in the
bootup messages

[ 0.000000] Linux version 2.6.32-5-amd64 (Debian 2.6.32-39squeeze1)
(dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Mon Jan
9 20:49:59 UTC 2012

but that might be long gone when I check. I could not find this version
string in /proc or /sys yet.

Any idea how to solve that?

Bernhard



Doesn't 'uname -a' give you that...



--
Sent from Free Open Source Software
Debian GNU/Linux


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4F871D06.30400@gmail.com">http://lists.debian.org/4F871D06.30400@gmail.com
 
Old 04-12-2012, 06:24 PM
Bernhard Schmidt
 
Default Checking for kernel freshness

keith <km3952@gmail.com> wrote:
> Bernhard Schmidt wrote:
>> The hard part seems to be matching the running kernel against the
>> version installed. I cannot figure out a good way so far. Nothing in the
>> running kernel seems to show the Debian version (i.e.
>> 2.6.32-41squeeze2), thus I cannot compare it. It is printed in the
>> bootup messages
>>
>> [ 0.000000] Linux version 2.6.32-5-amd64 (Debian 2.6.32-39squeeze1)
>> (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Mon Jan
>> 9 20:49:59 UTC 2012
>>
>> but that might be long gone when I check. I could not find this version
>> string in /proc or /sys yet.
>>
>> Any idea how to solve that?
>>
> Doesn't 'uname -a' give you that...

No.

$ uname -a
Linux ping 2.6.32-5-amd64 #1 SMP Mon Jan 9 20:49:59 UTC 2012 x86_64
GNU/Linux

The Squeeze kernel has been 2.6.32-5 since release, that doesn't tell
you anything about the actual kernel build you are running. Well, except
you start looking at the build date, but that's so ugly ...

Fortunately there is /proc/version ...

Thanks for everyone involved, I'm off writing checkscripts.

Bernhard


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: jm76kf$46r$1@dough.gmane.org">http://lists.debian.org/jm76kf$46r$1@dough.gmane.org
 
Old 04-13-2012, 09:16 AM
Florian Ernst
 
Default Checking for kernel freshness

Hello all,

On Thu, Apr 12, 2012 at 06:24:15PM +0000, Bernhard Schmidt wrote:
> [...]
> Fortunately there is /proc/version ...
>
> Thanks for everyone involved, I'm off writing checkscripts.

FWIW, please check the attached script.

HTH,
Flo
#!/usr/bin/perl -w

# fe: ripped out from
#
# apt-dater - terminal-based remote package update manager
#
# $Id: apt-dater-host 352 2009-05-19 15:55:49Z liske $
#
# Authors:
# Andre Ellguth <ellguth@ibh.de>
# Thomas Liske <liske@ibh.de>
#
# Copyright Holder:
# 2008-2009 (C) IBH IT-Service GmbH [http://www.ibh.de/apt-dater/]
#
# License:
# 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 package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

use strict;

my $CMD = shift;

$ENV{'LC_ALL'} = 'C';

my $exitcode = &do_kernel;
exit $exitcode;

sub do_kernel() {
my $UNKNOWN = 3;
my $infostr = 'KERNELINFO: Installed';
my $verfile = '/proc/version';
my $version = `uname -r`;
chomp($version);

unless(-r $verfile) {
print "$infostr $version, but could not read $verfile
";
return $UNKNOWN;
}

$verfile = `cat $verfile`;
chomp($verfile);
unless($verfile =~ /^S+ S+ S+ (Debian ([^)]+))/) {
print "$infostr $version, but no comparison possible against apparent non-Debian kernel $verfile
";
return $UNKNOWN;
}
my $vers = $1;

print "$infostr $vers";

my $reboot = 0;
open(HDPKG, "dpkg-query -W -f='${Version} ${Status;20} ${Maintainer} ${Provides}
' 'linux-image*'|grep 'install ok installed Debian Kernel Team'|grep linux-image|") or die "Could not fork: $!
";
while(<HDPKG>) {
next unless (/^(S+)s/);

unless (system("dpkg", "--compare-versions", $vers, "lt", $1) >> 8) {
$reboot = 1;
print ", available: $1";
}

}
close(HDPKG);

print "
";

return $reboot;
}
 

Thread Tools




All times are GMT. The time now is 04:26 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org