2011-04-26 13:25:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# openmamba system report generation tool
|
|
|
|
#
|
2019-03-04 17:37:52 +01:00
|
|
|
# Copyright (c) 2008-2019 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
2011-04-26 13:25:32 +02:00
|
|
|
#
|
|
|
|
|
2019-03-04 17:37:52 +01:00
|
|
|
VERSION=20190304
|
2011-04-26 13:25:32 +02:00
|
|
|
TEMPFILE=`tempfile`
|
|
|
|
|
|
|
|
. ${ROOT}/etc/sysconfig/machine
|
|
|
|
|
|
|
|
[ ! "$SYSTEM_MANUFACTURER" -o "$SYSTEM_MANUFACTURER" = "System manufacturer" ] && {
|
2013-02-27 11:11:36 +01:00
|
|
|
SYSTEM_MANUFACTURER=unknown
|
2011-04-26 13:25:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[ ! "$SYSTEM_PRODUCT_NAME" -o "$SYSTEM_PRODUCT_NAME" = "System Product Name" ] && {
|
2013-02-27 11:11:36 +01:00
|
|
|
SYSTEM_PRODUCT_NAME=unknown
|
2011-04-26 13:25:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[ ! "$SYSTEM_SERIAL_NUMBER" -o "$SYSTEM_SERIAL_NUMBER" = "System Serial Number" ] && {
|
2013-02-27 11:11:36 +01:00
|
|
|
SYSTEM_SERIAL_NUMBER=unknown
|
2011-04-26 13:25:32 +02:00
|
|
|
}
|
|
|
|
|
2013-08-16 10:41:15 +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
|
|
|
|
REPORTNAME="$1/$REPORTNAME"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $2 ]; then
|
|
|
|
HOME="$2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $3 ]; then
|
|
|
|
NOTE="$3"
|
|
|
|
fi
|
|
|
|
|
|
|
|
function catfile() {
|
|
|
|
|
|
|
|
FILENAME=$1
|
|
|
|
FILEDESC=$2
|
2011-10-05 13:30:16 +02:00
|
|
|
|
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
|
|
|
|
|
2011-10-17 00:08:53 +02:00
|
|
|
for c in $1; do
|
2011-04-26 13:25:32 +02:00
|
|
|
cat >> $TEMPFILE << _EOF
|
2011-10-17 00:08:53 +02:00
|
|
|
|
2011-04-26 13:25:32 +02:00
|
|
|
****************************************************************
|
2011-10-17 00:08:53 +02:00
|
|
|
* File '$c' (last 200 lines): $FILEDESC
|
2011-04-26 13:25:32 +02:00
|
|
|
****************************************************************
|
|
|
|
_EOF
|
|
|
|
|
2011-10-17 00:08:53 +02:00
|
|
|
tail -n 200 ${ROOT}/$c >> $TEMPFILE
|
2011-04-26 13:25:32 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function catinitramfs() {
|
|
|
|
|
|
|
|
FILENAME=$1
|
|
|
|
FILEDESC=$2
|
|
|
|
|
|
|
|
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"
|
2019-03-04 17:37:52 +01:00
|
|
|
echo "Copyright (c) 2008-2019 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
|
|
|
|
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"
|
2011-10-08 13:53:20 +02:00
|
|
|
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"
|
2011-06-07 20:25:03 +02:00
|
|
|
catcommand "ls -l /etc/alternatives" "System alternatives"
|
2019-03-04 17:37:52 +01:00
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
2019-03-04 17:37:52 +01:00
|
|
|
# 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"
|
2012-07-12 15:11:44 +02:00
|
|
|
catcommand "lsinitrd /boot/initramfs-`uname -r`.img" "running kernel initial ramdisk"
|
2011-04-26 13:25:32 +02:00
|
|
|
|
2019-03-04 17:37:52 +01:00
|
|
|
# system services status
|
|
|
|
catcommand "systemctl status" "systemctl status"
|
|
|
|
catcommand "systemctl" "systemctl services status"
|
|
|
|
catcommand "systemd-analyze blame" "systemd services startup timings"
|
2011-10-25 12:45:03 +02:00
|
|
|
|
2011-08-07 19:25:45 +02:00
|
|
|
# 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"
|
2019-03-04 17:37:52 +01:00
|
|
|
catfile /etc/X11/xorg.conf.d/* "Xorg configuration modules"
|
2011-08-07 19:25:45 +02:00
|
|
|
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"
|
2011-11-16 22:05:21 +01:00
|
|
|
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"
|
|
|
|
catfile "/etc/sysconfig/network" "General network configuration"
|
|
|
|
catfile "/etc/resolv.conf" "DNS configuration"
|
|
|
|
|
2011-10-17 16:26:20 +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
|
2011-10-05 13:30:16 +02:00
|
|
|
catcommand "rpm -qa --last | head -n 100" "Last installed packages"
|
2011-04-26 13:25:32 +02:00
|
|
|
catfile "/var/log/install-*" "Installation log"
|
|
|
|
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."
|