Subject: Re: low-level error conditions
To: Jukka Marin <jmarin@pyy.jmp.fi>
From: Andrew Gillham <gillhaa@ghost.whirlpool.com>
List: current-users
Date: 01/29/1997 14:43:14
Jukka Marin wrote:
> Why do some error messages go to the dmesg buffer (is that a 'kernel message
> buffer'?)?  Some examples of these are "arp - address XXXX overwritten by.."
> and some SCSI messages.  Yeah, and the serial port silo overflow messages.
> I find this annoying because the system configuration information gets lost
> sooner or later and I know no other way of getting it back but a reboot.

I've added a section to my rc.local to maintain a log of the dmesg output, and
to notify root of any changes.  I started out just using it on my "production"
machines that didn't reboot that often, so I would know if anything silently
disappeared. (or not so silently in the case of a disk or ethernet)  Lately
I've been using it on my -current machines that reboot quite frequently, 
mostly so I can see the difference in autoconfig output.
Here is what I use:

# check for changes in the hardware configuration
if [ -f /var/log/dmesglog ]; then
	echo -n 'checking hardware config:'
	mv /var/log/dmesglog /var/log/dmesglog.0
	dmesg | sed -n '/^NetBSD/h; /^NetBSD/!H; ${ x; p; q; }' \
		> /var/log/dmesglog
	diff -bc /var/log/dmesglog.0 /var/log/dmesglog > /tmp/diff.$$ 
	if [ -s /tmp/diff.$$ ]; then
		cat /tmp/diff.$$ | Mail -s "hardware change" root
		echo ' changed.'
	else
		echo ' no change.'
	fi
	rm -f /tmp/diff.$$
fi

At a minimum this saves your dmesg off for you. (the sed script tries to
save just the last kernel output)  If the email to root is annoying, it
can be commented out.

-Andrew