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: Don Aug 10 00:17:56 CEST 2006 [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 ################################################################################
18 if [[ -z "$INFOFILE" ]]; then
19 INFOFILE='info.tar.bz2'
22 # echo a list of all disks and their size
23 # taken from http://cvs.debian.org/fai/lib/disk-info
24 function diskandsize() {
25 local isdisk major minor blocks device suffix
26 while read major minor blocks device suffix; do
29 [ -f /proc/ide/$device/media ] && grep -q cdrom /proc/ide/$device/media && isdisk=0
30 [ $isdisk -eq 1 ] && echo "$device $blocks"
34 function list_disks() {
35 # print only every second entry; used by disk_info
47 function disk_info() {
48 # the variable holds a space separated list of devices and their block size
49 device_size=`grep -E ' cciss/c.d.$| ida/c.d.$| rd/c.d.$| hd.$| sd.$|/disc$' /proc/partitions | diskandsize`
50 # grep -E ' cciss/c.d.\b| ida/c.d.\b| rd/c.d.\b| hd.\b| sd.\b|/disc\b' /proc/partitions | diskandsize
52 # a list of all local disks, without size
53 disklist=`list_disks $device_size`
56 echo "Running grml-hwinfo ${VERSION} - collecting hardware information."
57 echo "Please send feedback, bugreports, feature requests to Michael Prokop <mika@grml.org>."
64 echo "Generating hardware information report using file $INFOFILE."
65 echo "This might take a few seconds/minutes. Please be patient..."
69 if [ -r /etc/grml_version ] ; then
70 cat /etc/grml_version > grml_version
72 echo "This does not seem to be a grml system. Continuing anyway..."
74 cat /etc/debian_version > debian_version
78 [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi > scsi
79 (lspci; lspci -n) | sort > lspci
80 [ -r /proc/bus/pnp ] && lspnp > lspnp
81 [ -r /proc/bus/usb ] && lsusb > lsusb
82 cat /proc/partitions > partitions
83 [ -r /proc/ide/ide?/hd?/geometry ] && grep . /proc/ide/ide?/hd?/geometry /dev/null | sed -e 's#/proc/ide/ide./##' > proc_ide
84 df -h > df 2>/dev/null
85 for i in free lsmod mount lsdev ; do
90 for i in cpuinfo interrupts cmdline devices dma fb iomem ioports \
91 mdstat meminfo modules mtrr pci version ; do
92 [ -r /proc/$i ] && cat /proc/$i > proc_$i
94 [[ -x `which sysdump` ]] && sysdump > sysdump 2>sysdump.error
95 # for sysnet in `find /proc/sys/net/*/ -type f | grep -v flush`; do cat $sysnet >> sysnet ; done
101 [[ -x `which discover` ]] && discover -v --type-summary --enable-bus all > discover 2> discover.2
102 [[ -x `which hwinfo` ]] && hwinfo log=hwinfo
105 [[ -x `which ifconfig` ]] && ifconfig -v -a > ifconfig
106 [[ -x `which ip` ]] && ip route show > ip_route
107 [[ -x `which ip` ]] && ip link show > ip_link
108 [[ -x `which route` ]] && route -n > route
111 dpkg --get-selections > dpkg_get_selections
112 COLUMNS=300 dpkg --list > dpkg_list
113 COLUMNS=1000 dpkg -l linux-image-$UNAME | grep linux-image-$UNAME | tr -s ' ' > running_kernel
116 [[ -x `which laptop-detect` ]] && laptop-detect 1>/dev/null 2>/dev/null && echo "0" > laptop_detected
117 [[ -x `which acpi_available` ]] && acpi_available && cat /proc/acpi/info > acpi_info
118 [[ -x `which acpi` ]] && acpi > acpi 2> acpi.error && acpi -v > acpi.version
119 [ -r /proc/apm/ ] && apm > acpi
122 if [ -r /proc/config.gz ] ; then
123 zcat /proc/config.gz > kernelconfig
125 [ -r /boot/config-$UNAME ] && cat /boot/config-$UNAME > kernelconfig
129 if [ -n "${DISPLAY}" ] ; then
130 [[ -x `which xviddetect` ]] && xviddetect > xviddetect
131 [[ -x `which xvidtune` ]] && xvidtune -show > xdivtune
132 [[ -x `which xrandr` ]] && xrandr > xrandr
133 [[ -x `which xdpyinfo` ]] && xdpyinfo > xdpyinfo
134 X -version 1> x_version 2>&1
137 for i in Xorg.0.log Xorg.7.log Xorg.8.log XFree86.0.log XFree86.7.log XFree86.8.log dmesg ; do
138 cp /var/log/$i log_$i 2>/dev/null
141 cp /etc/X11/xorg.conf xorg.conf 2>/dev/null
142 cp /etc/modules modules 2>/dev/null
143 cp /etc/X11/XF86Config-4 XF86Config-4 2>/dev/null
146 # sysinfo -class device -level all
149 if [ $UID != 0 ] ; then
150 echo "not running as root" > root
153 echo "running as root" > root
155 [[ -x `which sfdisk` ]] && sfdisk -d > sfdisk 2>sfdisk.error
156 [[ -x `which ddcprobe` ]] && ddcprobe > ddcprobe
157 [[ -x `which dmidecode` ]] && dmidecode > dmidecode
158 for disk in $disklist; do
159 [[ -x `which smartctl` ]] && smartctl -i /dev/$disk >> smartctl
160 [[ -x `which hdparm` ]] && hdparm -iv /dev/$disk >> hdparm
161 [[ -x `which fdisk` ]] && fdisk -lu /dev/$disk >> fdisk 2>>fdisk.error
162 [[ -x `which parted` ]] && parted -s /dev/$disk print >> parted
163 LC_ALL=C file -s /dev/$disk?* | grep -v ": empty" >> file_disk
168 tar jcf $INFOFILE info/ && rm -Rf info/
171 [ -n "$NOTROOT" ] && echo "Notice: you are running $PN without root permissions! Not all information could be collected!"
173 [ -r "$INFOFILE" ] && echo "$INFOFILE ($(ls -ahl $INFOFILE | awk '{print $5}')) has been generated."
177 #echo 'Thanks for collecting this information!'
179 #echo "Please fill out this form and send it together with $INFOFILE ($(ls -ahl $INFOFILE | awk '{print $5}')) to"
180 #echo " Michael Prokop <mika@grml.org>"
184 #Class: <Laptop/Desktop/Server/built-to-order/self-assembled>
187 #Distributor: <Where did you buy it>
188 #Bought in: <Country and Date>
190 #Components/Options: <If the PC was built-to-order or self assembled, please
191 # list the options or components you used>
197 ## END OF FILE##################################################################