Chinaunix首页 | 论坛 | 博客
  • 博客访问: 115887
  • 博文数量: 38
  • 博客积分: 2111
  • 博客等级: 大尉
  • 技术积分: 395
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-06 13:04
文章分类

全部博文(38)

文章存档

2012年(4)

2010年(34)

我的朋友

分类: LINUX

2010-05-22 23:31:16

shell脚本02--记录系统资源消耗
记录运行时的CPU、内存等的消耗情况。
 
#!/bin/bash
########################################################################
#rsru.sh
#record_system_resources_usage.sh
#The script used to record the use of system resources.
#by shark巨菜
########################################################################
#define
IOSTAT_FILE=./iostatus.txt
DATE=`date +%Y%m%d---%r`
CPU_USAGE=`top -b -n 1|head -n 5`
MEM_USAGE=`free -m`
HCT=`ps aux| awk '{print $5 "\t" $6 "\t" $11}' |sort -nr|head -n 10`
#setup the time of the check
echo "#######################################################" >> $IOSTAT_FILE
echo "$DATE" >> $IOSTAT_FILE
echo "-------------------------------------------------------------------------" >>$IOSTAT_FILE
#check the cpu status
echo "$CPU_USAGE" >> $IOSTAT_FILE
echo "-------------------------------------------------------------------------" >>$IOSTAT_FILE
#check the memory status
echo "$MEM_USAGE" >> $IOSTAT_FILE
echo "-------------------------------------------------------------------------" >>$IOSTAT_FILE
#check the tasks status
echo "$HCT" >> $IOSTAT_FILE
 
会生成一个iostatus.txt的文件,水平有限还不能根据这些数据给出简明扼要的提示,只能自己看使用率了。
o(╯□╰)o

阅读(1093) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~