#!/bin/bash while : do vmr=`vmstat | tail -1 | awk ‘{print $1}‘` if [ ${vmr} -gt 4 ] then date >> /root/monitor.txt vmstat >> /root/monitor.txt netstat -anp >> /root/monitor.txt ps -aux>> /root/monitor.txt last >> /root/monitor.txt tail -10 /var/log/messages >> /root/monitor.txt fi sleep 60 done
此脚本可放至后台运行 sh /root/monitor.sh & ,如遇CPU繁忙的情况,它会自动记载系统日志等以供分析。
时间: 2024-11-14 15:42:49