Debian Codegraph @

getsysinfo

raw
1 #! /bin/sh
2
3 if [ "$1" ] ; then
4 cat <<EOF
5 Usage: getsysinfo
6 Collect some system data that are useful for debugging
7 hardware detection bugs.
8 EOF
9 exit 0
10 fi
11
12 # collect some system data
13
14 dir=`mktemp -d /tmp/getsysinfo.XXXXXXXXXX`
15
16 [ -d "$dir" ] || exit 1
17
18 host=`hostname`
19 [ "$host" ] || host=xxx
20
21 mkdir -p "$dir/$host"
22
23 for i in \
24 /proc/asound \
25 /proc/bus/input \
26 /proc/cpuinfo \
27 /proc/device-tree \
28 /proc/devices \
29 /proc/dma \
30 /proc/driver/nvram \
31 /proc/fb \
32 /proc/filesystems \
33 /proc/iSeries \
34 /proc/ide \
35 /proc/interrupts \
36 /proc/iomem \
37 /proc/ioports \
38 /proc/meminfo \
39 /proc/modules \
40 /proc/net/dev \
41 /proc/partitions \
42 /proc/scsi \
43 /proc/sys/dev/cdrom/info \
44 /proc/sys/dev/parport \
45 /proc/tty \
46 /proc/version \
47 /sys \
48 /var/log/boot.msg \
49 /var/lib/hardware/udi
50 do
51 if [ -e "$i" ] ; then
52 echo "$i"
53 cp -x -a --parents "$i" "$dir/$host" 2>/dev/null
54 chmod -R u+w,a+r,a+X "$dir/$host"
55 for i in `( cd "$dir/$host" ; find proc -type f -size 0 )` ; do
56 cat "/$i" >"$dir/$host/$i"
57 done
58 fi
59 done
60
61 echo /proc/mounts
62 perl -nl -e 'print unless (split)[0] =~ /none|automount|:/' /proc/mounts >"$dir/$host/proc/mounts"
63
64 mkdir -p "$dir/$host/var/log"
65 echo "
66 ------ dmesg start ------
67 " >>"$dir/$host/var/log/boot.msg"
68 dmesg >>"$dir/$host/var/log/boot.msg"
69
70 if [ -x /usr/bin/lshal ] ; then
71 echo lshal
72 lshal >$dir/$host/lshal.txt 2>/dev/null
73 fi
74
75 file="$host.tar.gz"
76 tar -C "$dir" -zcf "$dir/$file" "$host"
77
78 rm -f "/tmp/$file"
79
80 if [ -e "/tmp/$file" ] ; then
81 echo "Warning: /tmp/$file exists, no info written"\!
82 rm -rf "$dir"
83 exit 1
84 fi
85
86 ln -nf "$dir/$file" "/tmp/$file"
87
88 rm -rf "$dir"
89
90 echo "
91 System data written to: /tmp/$file"