直接贴脚本:
1、cpu
#!/bin/bash
CurrentDate=`date -d today '+%Y%m%d'`
CurrentTime=`date -d today '+%Y%m%d%H%M'`
mytext="$CurrentTime\t`top -b -n 1 | grep Cpu\(s\)`"
echo -e $mytext >> /home/www/monitor/log/cpu$CurrentDate.log
2、memo
#!/bin/bash
CurrentDate=`date -d today '+%Y%m%d'`
CurrentTime=`date -d today '+%Y%m%d%H%M'`
mytext="$CurrentTime\t`top -b -n 1 | grep Mem:`"
echo -e $mytext >> /home/www/monitor/log/memo$CurrentDate.log
3、io
#!/bin/bash
CurrentDate=`date -d today '+%Y%m%d'`
CurrentTime=`date -d today '+%Y%m%d%H%M'`
mytext="$CurrentTime\t`iostat -p sda | grep -w sda`"
echo -e $mytext >> /home/www/monitor/log/io$CurrentDate.log
4、swap
#!/bin/bash
CurrentDate=`date -d today '+%Y%m%d'`
CurrentTime=`date -d today '+%Y%m%d%H%M'`
mytext="$CurrentTime\t`top -b -n 1 | grep Swap:`"
echo -e $mytext >> /home/www/monitor/log/swap$CurrentDate.log