[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dmesg command



On Mon, 2011-10-31 at 19:42 +0100, Svante Signell wrote:
> On Mon, 2011-10-31 at 13:35 +0100, Samuel Thibault wrote:
> > Samuel Thibault, le Mon 31 Oct 2011 12:50:57 +0100, a écrit :
> > > Svante Signell, le Mon 31 Oct 2011 12:45:11 +0100, a écrit :
> > > > On Mon, 2011-10-31 at 12:20 +0100, Samuel Thibault wrote:
> > > > > Thomas Schwinge, le Mon 31 Oct 2011 10:20:39 +0100, a écrit :
> > > > > >             # Save kernel messages in /var/log/dmesg
> > > > > >             if which dmesg >/dev/null 2>&1
> > > > > >             then
> > > > > >                     [ -f /var/log/dmesg ] && savelog -q -p -c 5 /var/log/dmesg
> > > > > >                     dmesg -s 524288 > /var/log/dmesg
> > > > > >                     chgrp adm /var/log/dmesg || :
> > > > > 
... 
> > (the idea of just catting /var/log/dmesg was interesting, but the
> > example above shows that it'd be considered convoluted, we should
> > probably just implement a proper dmesg which eats /dev/klog without
> > blocking)
> 
> What about creating a script dmesg doing similar to the following (save
> for syntax errors) :

Below is an updated script working for me (tm), with bashisms removed.
(As a temporary workaround until a proper dmesg has been written.)

apt-0.8.16~exp7 builds even if the following tests fails:
GlobalError_libapt_test and HashSums_libapt_test

dmesg is also used in apt-pkg/deb/dpkgpm.cc at: void
pkgDPkgPM::WriteApportReport to add to the report if pkg fails:
// attach dmesg log (to learn about segfaults)
For Hurd these segfaults will not be shown since the logfile is
truncated, but it would not do any harm either.

Additionally /var/log/dmesg has to be world readable (or the user has to
be in the adm group), is that a problem?

#!/bin/sh
 
if [ "$1" = "" ]; then
  exec cat /var/log/dmesg
else
  if [ -c /dev/klog ]; then
    dd if=/dev/klog of=/var/log/dmesg &
    sleep 1
    kill $!
  fi
fi




Reply to: