-#!/bin/sh
+#!/bin/bash
# Filename: grml-hwinfo
# Purpose: get hardware information
# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
UNAME="$(uname -r)"
PN="$(basename $0)"
[ -n "$WORKING_DIR" -a -d "$WORKING_DIR" ] || WORKING_DIR=$(pwd)
-VERSION='0.4.1'
+VERSION='***UNRELEASED***'
+
+# data collection should not be affected by user locale
+export LANG=C
+export LC_ALL=C
TIMESTAMP='+%F--%H-%M-%S-%Z'
DATE="$(date $TIMESTAMP)"
+echo "$PN ${VERSION} - collect hardware information"
+
GENERATE_FILE='1'
GENERATE_DIRECTORY=''
while getopts "hdf" args; do
case "$args" in
- h) echo "$PN - collect hardware information
-
+ h) echo "
This tool collects information of the hardware this tool is being executed
on. It can be executed as normal user to collect some basic information or
with root permissions to collect as much information as possible. By
Options:
--h : Display this help
--f : Create grml-hwinfo-TIMESTAMP.tar.bz2
--d : Create grml-hwinfo-TIMESTAMP/
-
--df : Create both, the directory and the file
+ -h Display this help message
+ -f Create grml-hwinfo-TIMESTAMP.tar.bz2
+ -d Create grml-hwinfo-TIMESTAMP as a directory
+ -df Create both, the directory and the file
"
exit 0;;
if [ "$(id -u)" != "0" ] ; then
NOTROOT=1
- echo "Notice: you are running $PN without root permissions. Not all information will be collected."
- echo
+ echo "W: Running without root permissions. Not all data will be collected."
fi
# check whether a binary is available and executable
echo 'Usage: exectest <binary>'>&2
return 1
else
- test -e "$(which $1)" && return 0 || return 1
+ if test -e "$(which $1)" ; then
+ return 0
+ else
+ grep -q "^$1"'$' missing_tools 2>/dev/null || echo "$1" >> missing_tools
+ return 1
+ fi
fi
}
disklist=`list_disks $device_size`
}
-echo "Running grml-hwinfo ${VERSION} - collecting hardware information."
cd "${OUTDIR}" || exit 1
(
-
[ -n "$GENERATE_FILE" ] && echo "Output file: $OUTFILE"
[ -n "$GENERATE_DIRECTORY" ] && echo "Output directory: $OUTDIR"
+ echo
echo "This might take a few seconds/minutes. Please be patient..."
# some sysinfo
for i in free lsmod mount lsdev ; do
exectest $i && $i > $i
done
+ swapon -s > swapon 2>swapon.error
# proc stuff
for i in cpuinfo interrupts cmdline devices dma fb iomem ioports \
# hwinfo
exectest discover && discover -v --type-summary --enable-bus all > discover 2> discover.2
exectest hwinfo && hwinfo log=hwinfo
+ exectest numactl && numactl --hardware > numactl
exectest x86info && x86info > x86info 2>x86info.2
# net stuff
echo "running as root" > root
disk_info
exectest sfdisk && sfdisk -d > sfdisk 2>sfdisk.error
- exectest ddcprobe && ddcprobe > ddcprobe
exectest dmidecode && dmidecode > dmidecode
exectest dconf && dconf -o dconf
/usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl > decode-dimms 2>decode-dimms.error
fi
+ exectest mdadm && mdadm --detail /dev/md[0-9]* >> mdadm 2>mdadm.error
+
+ # LVM
+ exectest pvs && pvs > pvs 2>pvs.error
+ exectest vgs && vgs > vgs 2>vgs.error
+ exectest lvs && lvs > lvs 2>lvs.error
+ exectest lvdisplay && lvdisplay > lvdisplay 2>lvdisplay.error
+
+ exectest dmsetup && dmsetup ls > dmsetup_ls 2>dmsetup_ls.error
+
for disk in $disklist; do
exectest smartctl && echo "smartctl -a /dev/$disk :\n" >> smartctl && smartctl -a /dev/$disk >> smartctl && echo "\n\n" >> smartctl
exectest hdparm && echo "hdparm -iv /dev/$disk :\n" >> hdparm && hdparm -iv /dev/$disk >> hdparm && echo "\n\n" >> hdparm
exectest fdisk && echo "fdisk -lu /dev/$disk :\n" >> fdisk && fdisk -lu /dev/$disk >> fdisk 2>>fdisk.error && echo "\n\n" >> fdisk
exectest parted && echo "parted -s /dev/$disk :\n" >> parted && parted -s /dev/$disk print >> parted && echo "\n\n" >> parted
- LC_ALL=C file -s /dev/$disk?* | grep -v ": empty" >> file_disk
+ file -s /dev/$disk?* | grep -v ": empty" >> file_disk
done
fi
)