Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7345914
  • 博文数量: 1763
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16217
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1763)

文章存档

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类: LINUX

2010-06-17 10:49:45

#!/bin/bash
cputotal=`head -1 /proc/stat |awk '{print $2+$3+$4+$5}'`
cpunow=`head -1 /proc/stat |awk '{print $2+$3+$4}'`
memtotal=`free  -m |sed -n '/Mem/p'|awk '{print $2}'`
memnow=`free  -m |sed -n '/Mem/p'|awk '{print $3}'`
cpuused=`gawk -v x=$cpunow -v y=$cputotal 'BEGIN{printf "%.5f",x * 100/y}'`
memused=`gawk -v x=$memnow -v y=$memtotal 'BEGIN{printf "%.5f",x * 100/y}'`
case "$1" in
  cpu)
        echo $cpuused
        ;;
  mem)
        echo $memused
        ;;
  clu)
        size=`(stat $2 | grep Size |awk '{print $2}')`
        num=`(stat $2 | grep Size |awk '{print $4}')`
        block=`expr $size / $num`
        echo $block
        ;;
  *)
        echo "it used cpu;mem;clu"
        ;;
esac
阅读(1271) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

chinaunix网友2010-06-20 10:37:24

你好!博客狠棒If you are looking for nike air max 2010 and kobe shoes. I will tell you that MBT Shoes is well-known for its positive effect to human body. MBT is one technology originally, MBT Shoes clearance sale, it began in Masai which is a tribe of Eastern Africa. 回复 | 举报