aix monitor script

发表于:2007-05-26来源:作者:点击数: 标签:
在别人的BLOG中看到这段监视操作系统CPU、内存和硬件错误的脚本,摘录在此。 #! /bin/sh Month=`date +%m` Day=`date +%d` Year=`date +%y` YEAR=`date +%Y` Num=5 LogDir=/tmp/sysmonitor CPULog=$LogDir/CPU_MEM_$YEAR$Month$Day.txt CRITICAL=$LogDir/CRI

在别人的BLOG中看到这段监视操作系统CPU、内存和硬件错误的脚本,摘录在此。

 #! /bin/sh
Month=`date "+%m"`
Day=`date "+%d"`
Year=`date "+%y"`
YEAR=`date "+%Y"`
Num=5

LogDir=/tmp/sysmonitor

CPULog=$LogDir/CPU_MEM_$YEAR$Month$Day.txt
CRITICAL=$LogDir/CRITICAL_CPU_MEM_$YEAR$Month$Day.txt
WARNING=$LogDir/WARNING_CPU_MEM_$YEAR$Month$Day.txt

##### Monitor CPU & Page in #####

echo "@@@@@@@@@@@ Date @@@@@@@@@@" >> $CPULog
date>> $CPULog
vmstat -t 2 $Num >> $CPULog

CNT=`tail -$Num $CPULog|awk ' ~ /^[0-9]/ {if(+>95 || <5){print }}' | wc -l`

if [ $CNT -gt 0 ] ; then
  echo "***********CRITICAL***********" >> $CRITICAL
  date >> $CRITICAL
  head -3 $CPULog >> $CRITICAL
  tail -$Num $CPULog|awk ' ~ /^[0-9]/ {if(+>95 || <5){print }}' >> $CRITICAL
fi

CNT=`tail -$Num $CPULog |awk ' ~ /^[0-9]/ {if(+>0){print }}' | wc -l`

if [ $CNT -gt 0 ] ; then
  echo "***********WARNING***********" >> $WARNING
  date >> $WARNING
  head -3 $CPULog >> $WARNING
  tail -$Num $CPULog |awk ' ~ /^[0-9]/ {if(+>0){print }}' >> $WARNING
fi


#####Monitor Memory#####

echo "@@@@@@@@@@@ Date @@@@@@@@@@" >> $CPULog
date>> $CPULog
svmon -G >> $CPULog

CNT=`tail -7 $CPULog |grep memory |awk '{if(/*100>80){print }}'| wc -l`

if [ $CNT -gt 0 ] ; then
  echo "***********CRITICAL***********" >> $CRITICAL
  date >> $CRITICAL
  tail -7 $CPULog >> $CRITICAL
fi

#####Monitor HW ERROR#####

CNT=`errpt -d H -s $Month$Day"0000"$Year |wc -l`

if [ $CNT -gt 0 ] ; then
  HWERR=$LogDir/HW_ERROR_$YEAR$Month$Day.txt
  echo "***********HW_ERROR***********" >> $HWERR
  date >> $HWERR
  errpt -d H -s $Month$Day"0000"$Year >> $HWERR
fi

原文转自:http://www.ltesting.net