| 1 | #!/bin/sh | 
|---|
| 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 | # | 
|---|
| 18 | # extract udev log messages from a syslog file | 
|---|
| 19 | # show_event_log <first> [<last> [<list of event types>] ] | 
|---|
| 20 | # | 
|---|
| 21 | # known events are: | 
|---|
| 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> | 
|---|
| 29 | # | 
|---|
| 30 |  | 
|---|
| 31 | EXCLUDE_SUBS="acpi cpu edd mem namespace pci_bus tty vc" | 
|---|
| 32 | MESSAGES=${MESSAGES:-/var/log/messages.log} | 
|---|
| 33 |  | 
|---|
| 34 | show_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 |  | 
|---|
| 61 | declare -i START=$1 STOP=$2 | 
|---|
| 62 | if [ "$2" == last ] ; then | 
|---|
| 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/'` | 
|---|
| 65 | fi | 
|---|
| 66 | test $START -lt 0 -a $STOP -gt 0 && START=$((STOP+START+1)) | 
|---|
| 67 | test $START -gt $STOP && STOP=$START | 
|---|
| 68 | shift; shift; WANTED_SUBS="$*" | 
|---|
| 69 | for n in `seq $START $STOP`; do | 
|---|
| 70 | show_event $n | 
|---|
| 71 | done | 
|---|
| 72 |  | 
|---|
| 73 | exit | 
|---|
| 74 |  | 
|---|
| 75 | # list all events | 
|---|
| 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 ',' ) | 
|---|
| 77 |  | 
|---|
| 78 | ./show_event_log 1 last > boot.events.log.`date +%A_%H:%M` 2> boot.events.list.`date +%A_%H:%M` | 
|---|