* Re: How to wait for kernel messages?
@ 2003-10-14 21:07 Jim Keniston
2003-10-14 22:57 ` Sebastian Piecha
0 siblings, 1 reply; 4+ messages in thread
From: Jim Keniston @ 2003-10-14 21:07 UTC (permalink / raw)
To: spi; +Cc: LKML, root
On Mon, 13 Oct 2003, Sebastian Piecha wrote:
> I have some problems with one NIC. Due to lack of time as an
> workaround I'd like to wait for the kernel message "NETDEV WATCHDOG:
> eth0: transmit timed out" and ifconfig down/up the NIC.
>
> How can I trigger any action by such a kernel message? Do I have to
> grep the kernel log?
>
> Mit freundlichen Gruessen/Best regards,
> Sebastian Piecha
If you had LTC's Event Logging installed, and you had your kernel
configured to forward printk messages to the event log, you could
do something like this:
evlnotify -f 'data~"NETDEV WATCHDOG: eth0: transmit timed out"' \
-a 'ifconfig eth0 down; ifconfig eth0 up'
That would cause the ifconfig down/up to run each time the indicated
printk happened.
Jim Keniston
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to wait for kernel messages?
2003-10-14 21:07 How to wait for kernel messages? Jim Keniston
@ 2003-10-14 22:57 ` Sebastian Piecha
0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Piecha @ 2003-10-14 22:57 UTC (permalink / raw)
To: Jim Keniston, LKML
[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 641 bytes --]
> On Mon, 13 Oct 2003, Sebastian Piecha wrote:
>
> > I have some problems with one NIC. Due to lack of time as an
> > workaround I'd like to wait for the kernel message "NETDEV WATCHDOG:
> > eth0: transmit timed out" and ifconfig down/up the NIC.
> >
> > How can I trigger any action by such a kernel message? Do I have to
> > grep the kernel log?
> >
Thanks a lot for all the hints. I'm using now a fifo to which syslogd
is logging kernel messages. A shell script greps the right message.
I attach the shell script inline for whom it may be interesting.
Mit freundlichen Gruessen/Best regards,
Sebastian Piecha
EMail: spi@gmxpro.de
[-- Attachment #2: Attachment information. --]
[-- Type: text/plain, Size: 466 bytes --]
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any other MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: check_nic.txt
Date: 15 Oct 2003, 0:56
Size: 771 bytes.
Type: Text
[-- Attachment #3: check_nic.txt --]
[-- Type: Application/Octet-stream, Size: 735 bytes --]
#!/bin/bash
# Signalling
trap 'exit 0' SIGTERM
trap '' SIGHUP
# grep
arg1="NETDEV WATCHDOG: eth0: transmit timed out"
#arg2="dhcpd: receive_packet failed on eth0: Network is down"
# Syslog
tag=$0
prio="kern.err"
fifo=/var/log/check_nic
IFCONFIG=$(which ifconfig)
SLEEP=$(which sleep)
EGREP=$(which egrep)
DATE=$(which date)
HOSTNAME=$(which hostname)
LOGGER=$(which logger)
while true
do
read line < $fifo
echo $line | \
$EGREP -e "$arg1" \
> /dev/null 2>&1
if [ $? -eq 0 ] ; then
$IFCONFIG eth0 down
$SLEEP 1
$IFCONFIG eth0 up
$LOGGER -t $tag -p $prio "eth0 down, restarting..."
$SLEEP 5
fi
done
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to wait for kernel messages?
2003-10-13 13:59 Sebastian Piecha
@ 2003-10-14 12:12 ` Richard B. Johnson
0 siblings, 0 replies; 4+ messages in thread
From: Richard B. Johnson @ 2003-10-14 12:12 UTC (permalink / raw)
To: Sebastian Piecha; +Cc: linux-kernel
On Mon, 13 Oct 2003, Sebastian Piecha wrote:
> I have some problems with one NIC. Due to lack of time as an
> workaround I'd like to wait for the kernel message "NETDEV WATCHDOG:
> eth0: transmit timed out" and ifconfig down/up the NIC.
>
> How can I trigger any action by such a kernel message? Do I have to
> grep the kernel log?
>
> Mit freundlichen Gruessen/Best regards,
> Sebastian Piecha
`cat /proc/kmsg`
...or to wait forever for each message, just open /proc/kmsg and
post a read. Note that kernel logger is also waiting for such
messages so you might not get them all.
Of course the 'Unix-way' is to just do `tail -f /var/log/messages`,
or whatever your log-file name is.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.
^ permalink raw reply [flat|nested] 4+ messages in thread
* How to wait for kernel messages?
@ 2003-10-13 13:59 Sebastian Piecha
2003-10-14 12:12 ` Richard B. Johnson
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Piecha @ 2003-10-13 13:59 UTC (permalink / raw)
To: linux-kernel
I have some problems with one NIC. Due to lack of time as an
workaround I'd like to wait for the kernel message "NETDEV WATCHDOG:
eth0: transmit timed out" and ifconfig down/up the NIC.
How can I trigger any action by such a kernel message? Do I have to
grep the kernel log?
Mit freundlichen Gruessen/Best regards,
Sebastian Piecha
EMail: spi@gmxpro.de
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-10-14 22:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14 21:07 How to wait for kernel messages? Jim Keniston
2003-10-14 22:57 ` Sebastian Piecha
-- strict thread matches above, loose matches on Subject: below --
2003-10-13 13:59 Sebastian Piecha
2003-10-14 12:12 ` Richard B. Johnson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.