source: udev/show_event_log@ d15a80a

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since d15a80a was 9aa77af, checked in by Jim Gifford <clfs@…>, 18 years ago

Fix show_event_log

  • Property mode set to 100755
File size: 2.3 KB
RevLine 
[9aa77af]1#!/bin/sh
[7e161ea]2########################################################################
3#
4# Description : show_event_log
5#
6# Authors : Based on Open Suse Udev Rules
7# kay.sievers@suse.de
8#
9# Adapted to : Jim Gifford
10# LFS
11#
12# Version : 00.00
13#
14# Notes :
15#
16########################################################################
17#
[26b1cc1]18# extract udev log messages from a syslog file
19# show_event_log <first> [<last> [<list of event types>] ]
20#
[7e161ea]21# known events are:
[26b1cc1]22# ac97 acpi block cpu drivers edd firmware graphics i2c-adapter i8259
23# ieee1394_protocol input ioapic irqrouter lapic mem misc module namespace
24# pci_bus pci_express pcmcia pcmcia_socket platform pnp printer scsi scsi_host
25# serio sound timer timer_pit tty usb usb_device usb_host vc
26#
27# GPL, version 2
28# Christian Zoz <zoz@suse.de>
[7e161ea]29#
[26b1cc1]30
[7e161ea]31EXCLUDE_SUBS="acpi cpu edd mem namespace pci_bus tty vc"
[1400499]32MESSAGES=${MESSAGES:-/var/log/messages.log}
[7e161ea]33
34show_event() {
35 local SN PID SUBS
36 declare -i SN=$1 PID
37 read PID ACT SUBS < <(sed -n "s/^.*seq $SN forked, pid \[\([0-9]*\)\], '\([^']*\)' '\([^']*\)'.*$/\1 \2 \3/p;T;q" $MESSAGES)
38 if [ $PID == 0 ] ; then
39 echo event $SN not found 1>&2
40 return 1
41 fi
42 if [ -n "$WANTED_SUBS" ] ; then
43 WANTED=no
44 for S in $WANTED_SUBS; do
45 test "$SUBS" == "$S" && WANTED=yes
46 done
47 else
48 WANTED=yes
49 for S in $EXCLUDE_SUBS; do
50 test "$SUBS" == "$S" && WANTED=no
51 done
52 fi
53 echo event $SN $PID $ACT $SUBS $WANTED 1>&2
54 test $WANTED == no && return 1
55 echo " _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ $SN _ $ACT _ $SUBS _ _ _ _"
56 grep "seq $SN \|\[$PID\]" $MESSAGES |
57 grep -v "pass_env\|geventrec\|hal.hot"
58 echo
59}
60
61declare -i START=$1 STOP=$2
62if [ "$2" == last ] ; then
[26b1cc1]63 read STOP_STRING < <(grep -o "udev_done.*exit" $MESSAGES | cut -d" " -f3 | sort -n | tail -1)
64 STOP=`echo $STOP_STRING | sed 's/^[^0-9]*\([0-9]\+\).*$/\1/'`
[7e161ea]65fi
66test $START -lt 0 -a $STOP -gt 0 && START=$((STOP+START+1))
67test $START -gt $STOP && STOP=$START
68shift; shift; WANTED_SUBS="$*"
69for n in `seq $START $STOP`; do
70 show_event $n
71done
[26b1cc1]72
[7e161ea]73exit
74
75# list all events
[103e3eb]76(read x; while read x s x x x c x; read x s2 x a d; do echo $s $s2 $a $c $d; done) < <( sed -n "s/^.*udev.*\(seq [0-9]* [qf].*$\)/\1/p" /var/log/messages | sort -n -k 2 | tr -d ',' )
[7e161ea]77
78./show_event_log 1 last > boot.events.log.`date +%A_%H:%M` 2> boot.events.list.`date +%A_%H:%M`
Note: See TracBrowser for help on using the repository browser.