监控系统负载的脚本
#! /bin/bash
N=20
while :;
do
load=`uptime |awk '{print $10}' |cut -d'.' -f 1`
if [ $load -gt $N ] ; then
uptime |awk '{print $1,$8,$9,$10,$11,$12}' >>/root/anaload/`date +%m%d`_anaload.txt
vmstat 1 600 >>/root/anaload/`date +%m%d`_anaload.txt
echo " " >>/root/anaload/`date +%m%d`_anaload.txt
fi
sleep 10
done
N=20
while :;
do
load=`uptime |awk '{print $10}' |cut -d'.' -f 1`
if [ $load -gt $N ] ; then
uptime |awk '{print $1,$8,$9,$10,$11,$12}' >>/root/anaload/`date +%m%d`_anaload.txt
vmstat 1 600 >>/root/anaload/`date +%m%d`_anaload.txt
echo " " >>/root/anaload/`date +%m%d`_anaload.txt
fi
sleep 10
done
none