code-dumps/sh/pre-maint-state-capture.sh

34 lines
804 B
Bash
Raw Normal View History

2024-10-24 23:09:21 +08:00
#!/bin/bash
CAPTURE="/tmp/maintenance/$(date +%Y%m%d)"
mkdir -p $CAPTURE
# System config files
cp -p /etc/fstab /etc/resolv.conf /var/log/messages /var/log/syslog /etc/os-release /var/log/yum.log /var/log/apt/history.log $CAPTURE/
# Running stats
( dmesg -T || dmesg ) > $CAPTURE/dmesg
mount > $CAPTURE/mount
lsblk > $CAPTURE/lsblk
df -hP > $CAPTURE/df
ps auxww > $CAPTURE/psauxww
netstat -atunp > $CAPTURE/netstat
pvs > $CAPTURE/pvs
vgs > $CAPTURE/vgs
lvs > $CAPTURE/lvs
uname -a > $CAPTURE/uname
free -m > $CAPTURE/free
systemctl list-unit-files > $CAPTURE/systemcl-list
# packages
rpm -qa > $CAPTURE/rpm.list
dpkg -l > $CAPTURE/dpkg.list
snap list > $CAPTURE/snap.list
# san storage
multipath -ll > $CAPTURE/multipath
powermt display dev=all > $CAPTURE/powermt
# Wrappng up
chmod 444 $CAPTURE/*