desktop-base-openmamba/openmamba-makereport/openmamba-makereport

219 lines
5.8 KiB
Plaintext
Raw Normal View History

2011-04-26 13:25:32 +02:00
#!/bin/bash
#
# openmamba system report generation tool
#
# Copyright (c) 2008-2022 by Silvan Calarco <silvan.calarco@mambasoft.it>
2011-04-26 13:25:32 +02:00
#
VERSION=20220618
TEMPFILE=`mktemp`
2011-04-26 13:25:32 +02:00
. ${ROOT}/etc/sysconfig/machine
[ ! "$SYSTEM_MANUFACTURER" -o "$SYSTEM_MANUFACTURER" = "System manufacturer" ] && {
SYSTEM_MANUFACTURER=unknown
2011-04-26 13:25:32 +02:00
}
[ ! "$SYSTEM_PRODUCT_NAME" -o "$SYSTEM_PRODUCT_NAME" = "System Product Name" ] && {
SYSTEM_PRODUCT_NAME=unknown
2011-04-26 13:25:32 +02:00
}
[ ! "$SYSTEM_SERIAL_NUMBER" -o "$SYSTEM_SERIAL_NUMBER" = "System Serial Number" ] && {
SYSTEM_SERIAL_NUMBER=unknown
2011-04-26 13:25:32 +02:00
}
SYSTEM_MANUFACTURER=`echo $SYSTEM_MANUFACTURER | tr ' ' _ | tr '-' _ | tr '/' _`
SYSTEM_PRODUCT_NAME=`echo $SYSTEM_PRODUCT_NAME | tr ' ' _ | tr '-' _ | tr '/' _`
SYSTEM_SERIAL_NUMBER=`echo $SYSTEM_SERIAL_NUMBER | tr ' ' _ | tr '-' _ | tr '/' _`
2011-04-26 13:25:32 +02:00
REPORTNAME="openmamba-report-$SYSTEM_MANUFACTURER-$SYSTEM_PRODUCT_NAME-$SYSTEM_SERIAL_NUMBER.txt"
if [ "$1" ]; then
NOTE="$1"
2011-04-26 13:25:32 +02:00
fi
if [ "$2" ]; then
REPORTNAME="$2"
2011-04-26 13:25:32 +02:00
fi
function catfile() {
FILENAME=$1
FILEDESC=$2
2011-04-26 13:25:32 +02:00
for c in $FILENAME; do
cat >> $TEMPFILE << _EOF
****************************************************************
* File '$c': $FILEDESC
****************************************************************
_EOF
cat ${ROOT}/$c >> $TEMPFILE
done
}
function tailfile() {
FILENAME=$1
FILEDESC=$2
for c in $1; do
2011-04-26 13:25:32 +02:00
cat >> $TEMPFILE << _EOF
2011-04-26 13:25:32 +02:00
****************************************************************
* File '$c' (last 200 lines): $FILEDESC
2011-04-26 13:25:32 +02:00
****************************************************************
_EOF
tail -n 200 ${ROOT}/$c >> $TEMPFILE
2011-04-26 13:25:32 +02:00
done
}
function catinitramfs() {
FILENAME=$1
FILEDESC=$2
2011-04-26 13:25:32 +02:00
for c in $1; do
TMPDIR=`mktemp -d`
cat >> $TEMPFILE << _EOF
****************************************************************
* Initramfs image '$c': $FILEDESC
****************************************************************
_EOF
pushd $TMPDIR >/dev/null
gunzip -c ${ROOT}/$c | cpio -i &>/dev/null
ls -lR . >> $TEMPFILE
echo "\
************************\
init script in initramfs\
************************" >> $TEMPFILE
cat init >> $TEMPFILE
popd >/dev/null
[ "$TMPDIR" -a "$TMPDIR" != "/" ] && rm -rf $TMPDIR
done
}
function catcommand() {
CMDNAME="$1"
FILEDESC="$2"
cat >> $TEMPFILE << _EOF
****************************************************************
* Command '$CMDNAME': $FILEDESC
****************************************************************
_EOF
eval $CMDNAME 2>>$TEMPFILE >> $TEMPFILE
}
echo "openmamba report generation tool $VERSION"
echo "Copyright (c) 2008-2022 by Silvan Calarco <info@openmamba.org>"
2011-04-26 13:25:32 +02:00
echo
[ $UID = 0 ] || {
echo "Error: this program must be run as root; exiting."
exit 1
}
echo "Gathering information..."
cat > $TEMPFILE << _EOF
****************************************************************************
* openmamba diagnostic information $VERSION for host $HOSTNAME (`date`)
****************************************************************************
_EOF
if [ "$NOTE" ]; then
echo "
REPORTED PROBLEM:
=================" >> $TEMPFILE
cat "$NOTE" >> $TEMPFILE
2011-04-26 13:25:32 +02:00
echo >> $TEMPFILE
fi
# system information
catfile /etc/openmamba-release "release information"
catfile /etc/sysconfig/machine "machine information from BIOS"
catfile /proc/cpuinfo "processor(s) information"
catfile /proc/meminfo "System memory information"
catcommand "/usr/sbin/lspci -nn" "PCI hardware information (short)"
2014-11-17 22:54:43 +01:00
catcommand /usr/bin/lsusb "USB hardware information"
2011-04-26 13:25:32 +02:00
catcommand /sbin/lsmod "Loadel kernel modules"
catcommand "rpm -qa|grep kernel-mamba" "Installed kernel packages"
catcommand "ls -l /etc/alternatives" "System alternatives"
# kernel and system logs
catcommand "journalctl --system -b | head -n 1000" "system journal from boot"
catcommand "journalctl --system -n 500" "system journal last lines"
catcommand /bin/dmesg "last kernel messages"
# user log
catcommand "sudo -u ${SUDO_USER} journalctl -b --user | head -n 500" "user journal from startup"
catcommand "sudo -u ${SUDO_USER} journalctl --user -n 500" "user journal last entries"
2011-04-26 13:25:32 +02:00
# process/memory information
catcommand "top -b -n1" "Top running processes"
catcommand "ps aux" "All running processes"
# system boot troubleshooting
2011-04-26 13:25:32 +02:00
catfile /proc/cmdline "kernel startup command line"
catcommand "ls -l /boot" "boot files"
catfile /boot/grub/grub.cfg "GRUB configuration"
catfile "/etc/modprobe.d/*" "modules configuration"
catcommand "lsinitrd /boot/initramfs-`uname -r`.img" "running kernel initial ramdisk"
2011-04-26 13:25:32 +02:00
# system services status
catcommand "systemctl status" "systemctl status"
catcommand "systemctl" "systemctl services status"
catcommand "systemd-analyze blame" "systemd services startup timings"
# Graphical subsystem
2011-04-26 13:25:32 +02:00
catfile /var/log/Xorg.0.log "Xorg startup log"
catfile /etc/X11/xorg.conf "Xorg configuration"
catfile /etc/X11/xorg.conf.d/* "Xorg configuration modules"
catcommand "DISPLAY=:0 /usr/bin/glxinfo" "GLX information"
2011-04-26 13:25:32 +02:00
# Audio
catfile "/proc/asound/card*/codec*" "Audio driver codecs"
catfile "/etc/asound.conf" "Alsa configuration"
catfile "/var/lib/alsa/asound.state" "Alsa mixer settings"
2011-04-26 13:25:32 +02:00
# Network
catcommand "/sbin/ifconfig -a" "Network interfaces list"
catcommand "/usr/sbin/iwconfig" "Wireless interfaces list"
catcommand "/sbin/route -n" "Routing table"
catcommand "systemd-resolve --status" "DNS configuration"
2011-04-26 13:25:32 +02:00
# Disks
for d in /dev/sd[a-z]; do
catcommand "smartctl -ia $d" "S.M.A.R.T. status for device $d"
done
2011-04-26 13:25:32 +02:00
# Installation
catcommand "rpm -qa --last | head -n 100" "Last installed packages"
2011-04-26 13:25:32 +02:00
catfile /var/log/Xorg.5.log "Xorg installation test log"
# Other details
catcommand "/usr/sbin/lspci -vv" "PCI hardware information (verbose)"
cp $TEMPFILE $REPORTNAME || exit 1
chmod +r $REPORTNAME
rm -f $TEMPFILE
echo "Report saved as $REPORTNAME"
echo "Please send this report to reports@openmamba.org."