监控CPU和内存的使用:
#!/bin/bash#script to capture system statisticsoutfile=/home/rainbow/test/file.csvdate=`date +%Y/%m/%d`time=`date +%k:%M:%S`timeout=`uptime`vmout=`vmstat 1 2`users=`echo $timeout|awk '{print $4}'`load=`echo $timeout|awk '{print $9}' |sed 's/,//'`free=`echo "$vmout"|sed -n '/[0-9]/p' |sed -n '2p'|awk '{print $4}'`idle=`echo "$vmout"|sed -n '/[0-9]/p' |sed -n '2p' |awk '{print $15}'`echo "$date,$time,$users,$load,$free,$idle">>$outfile
生成html文档的格式查看:
#!/bin/bash#parse capstats data info daily reportFILE=/root/cimp/testTEMP=/root/cimp/test.htmlDATE=`date +"%A,%B %d, %Y"`echo "Report for $DATE
" > $TEMPecho "
Date | Time | Users | " >> $TEMPcat $FILE |awk -F, '{printf "|||
%s | %s | %s | ",$1,$2,$3;print "%s | %s | %s | \n