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 Aug 20 11:23:37 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
117 exectest x86info && x86info > x86info 2>x86info.2
120 exectest ifconfig && ifconfig -v -a > ifconfig
121 exectest ip && ip route show > ip_route
122 exectest ip && ip link show > ip_link
123 exectest route && route -n > route
126 if exectest dpkg ; then
127 dpkg --get-selections > dpkg_get_selections
128 COLUMNS=300 dpkg --list > dpkg_list
129 COLUMNS=1000 dpkg -l linux-image-$UNAME | grep linux-image-$UNAME | tr -s ' ' > running_kernel
133 exectest laptop-detect && laptop-detect 1>/dev/null 2>/dev/null && echo "0" > laptop_detected
134 exectest acpi_available && acpi_available && cat /proc/acpi/info > acpi_info
135 exectest acpi && acpi > acpi 2> acpi.error && acpi -v > acpi.version
136 [ -r /proc/apm/ ] && apm > apm
139 if [ -r /proc/config.gz ] ; then
140 zcat /proc/config.gz > kernelconfig
142 [ -r /boot/config-$UNAME ] && cat /boot/config-$UNAME > kernelconfig
146 if [ -n "${DISPLAY}" ] ; then
147 exectest xviddetect && xviddetect > xviddetect
148 exectest xvidtune && xvidtune -show > xdivtune
149 exectest xrandr && xrandr > xrandr
150 exectest xdpyinfo && xdpyinfo > xdpyinfo
151 X -version 1> x_version 2>&1
154 for i in Xorg.0.log Xorg.7.log Xorg.8.log XFree86.0.log XFree86.7.log XFree86.8.log dmesg ; do
155 cp /var/log/$i log_$i 2>/dev/null
158 cp /etc/X11/xorg.conf xorg.conf 2>/dev/null
159 cp /etc/modules modules 2>/dev/null
160 cp /etc/X11/XF86Config-4 XF86Config-4 2>/dev/null
163 # sysinfo -class device -level all
166 if [ -n "$NOTROOT" ] ; then
167 echo "not running as root" > root
169 echo "running as root" > root
171 exectest sfdisk && sfdisk -d > sfdisk 2>sfdisk.error
172 exectest ddcprobe && ddcprobe > ddcprobe
173 exectest dmidecode && dmidecode > dmidecode
175 if [ -x /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl ] ; then
176 /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl > decode-dimms 2>decode-dimms.error
179 for disk in $disklist; do
180 exectest smartctl && smartctl -i /dev/$disk >> smartctl
181 exectest hdparm && hdparm -iv /dev/$disk >> hdparm
182 exectest fdisk && fdisk -lu /dev/$disk >> fdisk 2>>fdisk.error
183 exectest parted && parted -s /dev/$disk print >> parted
184 LC_ALL=C file -s /dev/$disk?* | grep -v ": empty" >> file_disk
189 # finally create the tarball
190 if [ -f "$INFOFILE" ] ; then
191 DATE="$(date +%Y%m%d_%H%M%S)"
192 NEW_INFOFILE="info_$DATE.tar.bz2"
194 echo "Warning: $INFOFILE exists already, using $NEW_INFOFILE instead.">&2
195 tar jcf $NEW_INFOFILE info/ && rm -Rf info/
196 INFOFILE="$NEW_INFOFILE" # adjust variable for final info message
198 tar jcf $INFOFILE info/ && rm -Rf info/
202 [ -r "$INFOFILE" ] && echo "$INFOFILE ($(ls -ahl $INFOFILE | awk '{print $5}')) has been generated."
205 ## END OF FILE##################################################################