2 # Filename: grml-hwinfo
3 # Purpose: get hardware information
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Mon Jun 11 12:15:04 CEST 2007 [mika]
8 ################################################################################
9 # Notice: Some ideas have been taken from
10 # http://club.black.co.at/david/hwdb/infodump
11 # by David Schmitt <david@schmitt.edv-bus.at>
12 ################################################################################
19 [ -n "$INFOFILE" ] || INFOFILE='info.tar.bz2'
22 if [ "$(id -u)" != 0 ] ; then
24 echo "Notice: you are running $PN without root permissions. Not all information will be collected."
28 # check whether a binary is available and executable
31 echo 'Usage: exectest <binary>'>&2
34 test -e "$(which $1)" && return 0 || return 1
38 # echo a list of all disks and their size
39 # taken from http://cvs.debian.org/fai/lib/disk-info
41 local isdisk major minor blocks device suffix
42 while read major minor blocks device suffix; do
45 [ -f /proc/ide/$device/media ] && grep -q cdrom /proc/ide/$device/media && isdisk=0
46 [ "$isdisk" -eq 1 ] && echo "$device $blocks"
51 # print only every second entry; used by disk_info
54 if [ "$i" -eq 0 ]; then
64 # the variable holds a space separated list of devices and their block size
65 device_size=`grep -E ' cciss/c.d.$| ida/c.d.$| rd/c.d.$| hd.$| sd.$|/disc$' /proc/partitions | diskandsize`
66 # a list of all local disks, without size
67 disklist=`list_disks $device_size`
70 echo "Running grml-hwinfo ${VERSION} - collecting hardware information."
71 echo "Please send feedback, bugreports, feature requests to Michael Prokop <mika@grml.org>."
78 echo "Generating hardware information report using file $INFOFILE."
79 echo "This might take a few seconds/minutes. Please be patient..."
83 if [ -r /etc/grml_version ] ; then
84 cat /etc/grml_version > grml_version
86 if [ -r /etc/debian_version ] ; then
87 cat /etc/debian_version > debian_version
92 [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi > scsi
93 (lspci; lspci -n) | sort > lspci
94 [ -r /proc/bus/pnp ] && lspnp > lspnp
95 [ -r /proc/bus/usb ] && lsusb > lsusb
96 cat /proc/partitions > partitions
97 find /proc/ide/ -name geometry -exec grep . {} \; > proc_ide 2>/dev/null
98 df -h > df 2>/dev/null
99 for i in free lsmod mount lsdev ; do
100 exectest $i && $i > $i
104 for i in cpuinfo interrupts cmdline devices dma fb iomem ioports \
105 mdstat meminfo modules mtrr pci version ; do
106 [ -r /proc/$i ] && cat /proc/$i > proc_$i
108 exectest sysdump && sysdump > sysdump 2>sysdump.error
109 # for sysnet in `find /proc/sys/net/*/ -type f | grep -v flush`; do cat $sysnet >> sysnet ; done
115 exectest discover && discover -v --type-summary --enable-bus all > discover 2> discover.2
116 exectest hwinfo && hwinfo log=hwinfo
119 exectest ifconfig && ifconfig -v -a > ifconfig
120 exectest ip && ip route show > ip_route
121 exectest ip && ip link show > ip_link
122 exectest route && route -n > route
125 if exectest dpkg ; then
126 dpkg --get-selections > dpkg_get_selections
127 COLUMNS=300 dpkg --list > dpkg_list
128 COLUMNS=1000 dpkg -l linux-image-$UNAME | grep linux-image-$UNAME | tr -s ' ' > running_kernel
132 exectest laptop-detect && laptop-detect 1>/dev/null 2>/dev/null && echo "0" > laptop_detected
133 exectest acpi_available && acpi_available && cat /proc/acpi/info > acpi_info
134 exectest acpi && acpi > acpi 2> acpi.error && acpi -v > acpi.version
135 [ -r /proc/apm/ ] && apm > apm
138 if [ -r /proc/config.gz ] ; then
139 zcat /proc/config.gz > kernelconfig
141 [ -r /boot/config-$UNAME ] && cat /boot/config-$UNAME > kernelconfig
145 if [ -n "${DISPLAY}" ] ; then
146 exectest xviddetect && xviddetect > xviddetect
147 exectest xvidtune && xvidtune -show > xdivtune
148 exectest xrandr && xrandr > xrandr
149 exectest xdpyinfo && xdpyinfo > xdpyinfo
150 X -version 1> x_version 2>&1
153 for i in Xorg.0.log Xorg.7.log Xorg.8.log XFree86.0.log XFree86.7.log XFree86.8.log dmesg ; do
154 cp /var/log/$i log_$i 2>/dev/null
157 cp /etc/X11/xorg.conf xorg.conf 2>/dev/null
158 cp /etc/modules modules 2>/dev/null
159 cp /etc/X11/XF86Config-4 XF86Config-4 2>/dev/null
162 # sysinfo -class device -level all
165 if [ -n "$NOTROOT" ] ; then
166 echo "not running as root" > root
168 echo "running as root" > root
170 exectest sfdisk && sfdisk -d > sfdisk 2>sfdisk.error
171 exectest ddcprobe && ddcprobe > ddcprobe
172 exectest dmidecode && dmidecode > dmidecode
173 for disk in $disklist; do
174 exectest smartctl && smartctl -i /dev/$disk >> smartctl
175 exectest hdparm && hdparm -iv /dev/$disk >> hdparm
176 exectest fdisk && fdisk -lu /dev/$disk >> fdisk 2>>fdisk.error
177 exectest parted && parted -s /dev/$disk print >> parted
178 LC_ALL=C file -s /dev/$disk?* | grep -v ": empty" >> file_disk
183 # finally create the tarball
184 if [ -f "$INFOFILE" ] ; then
185 DATE="$(date +%Y%m%d_%H%M%S)"
186 NEW_INFOFILE="info_$DATE.tar.bz2"
188 echo "Warning: $INFOFILE exists already, using $NEW_INFOFILE instead.">&2
189 tar jcf $NEW_INFOFILE info/ && rm -Rf info/
190 INFOFILE="$NEW_INFOFILE" # adjust variable for final info message
192 tar jcf $INFOFILE info/ && rm -Rf info/
196 [ -r "$INFOFILE" ] && echo "$INFOFILE ($(ls -ahl $INFOFILE | awk '{print $5}')) has been generated."
199 ## END OF FILE##################################################################