재부팅 할 때 상태가 이상한 서버는 아래와 같이 정보 저장하고 재부팅 하는 편이다.
더보기
#!/bin/bash
DATE=$(date -I)
mkdir -p /root/reboot/$DATE
/bin/netstat -nlp > /root/reboot/$DATE/netstat.txt
/sbin/iptables -nvL > /root/reboot/$DATE/iptables.txt
/sbin/iptables-save > /root/reboot/$DATE/iptables.rule
/bin/ps aux > /root/reboot/$DATE/ps.txt
/sbin/lsmod > /root/reboot/$DATE/lsmod.txt
/bin/df -Th > /root/reboot/$DATE/df.txt
/sbin/fdisk -lu > /root/reboot/$DATE/fdisk.txt
/sbin/ifconfig -a > /root/reboot/$DATE/ifconfig.txt
/bin/cp -a /etc/rc.d/rc.local /root/reboot/$DATE/rclocal.txt
/bin/cp -a /etc/fstab /root/reboot/$DATE/fstab.txt
/bin/cp -a /boot/grub/grub.conf /root/reboot/$DATE/grubconf.txt
mkdir -p /root/reboot/$DATE/lsof_pid
cd /root/reboot/$DATE/lsof_pid
PID=`netstat -nlp | awk '{print $7}' | awk -F / '{print $1}' | sed '/^$/d' | sed '/^[A-Za-z]/d'`
for i in $PID
do
lsof -p $i > "$i"_lsof
done
DATE=$(date -I)
mkdir -p /root/reboot/$DATE
/bin/netstat -nlp > /root/reboot/$DATE/netstat.txt
/sbin/iptables -nvL > /root/reboot/$DATE/iptables.txt
/sbin/iptables-save > /root/reboot/$DATE/iptables.rule
/bin/ps aux > /root/reboot/$DATE/ps.txt
/sbin/lsmod > /root/reboot/$DATE/lsmod.txt
/bin/df -Th > /root/reboot/$DATE/df.txt
/sbin/fdisk -lu > /root/reboot/$DATE/fdisk.txt
/sbin/ifconfig -a > /root/reboot/$DATE/ifconfig.txt
/bin/cp -a /etc/rc.d/rc.local /root/reboot/$DATE/rclocal.txt
/bin/cp -a /etc/fstab /root/reboot/$DATE/fstab.txt
/bin/cp -a /boot/grub/grub.conf /root/reboot/$DATE/grubconf.txt
mkdir -p /root/reboot/$DATE/lsof_pid
cd /root/reboot/$DATE/lsof_pid
PID=`netstat -nlp | awk '{print $7}' | awk -F / '{print $1}' | sed '/^$/d' | sed '/^[A-Za-z]/d'`
for i in $PID
do
lsof -p $i > "$i"_lsof
done
'Language > Shell scripting' 카테고리의 다른 글
[Shell Scripting] CPU/Disk/Memory check & monitoring (0) | 2023.03.14 |
---|---|
[Shell Scripting] 불필요 로그 제거 (0) | 2023.01.29 |
댓글