Chinaunix首页 | 论坛 | 博客
  • 博客访问: 533745
  • 博文数量: 116
  • 博客积分: 2063
  • 博客等级: 大尉
  • 技术积分: 1174
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-26 16:44
个人简介

none

文章分类

全部博文(116)

文章存档

2023年(2)

2020年(3)

2019年(4)

2018年(7)

2017年(6)

2016年(17)

2015年(13)

2014年(19)

2013年(6)

2012年(13)

2011年(5)

2010年(11)

2008年(10)

分类: LINUX

2014-01-17 17:19:41

#
# top

'vt100': unknown terminal type.
#
# export TERMINFO=/usr/share/terminfo
#
# env
USER=root
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib
OLDPWD=/root
TERMINFO=/usr/share/terminfo
HOME=/root
LOGNAME=root
TERM=vt100
PATH=/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
SHELL=/bin/sh
PWD=/usr/share
#
# ls /usr/share/terminfo/v/vt100
/usr/share/terminfo/v/vt100
#
# top -d 1 -n 1  ##############################################################OK


$ cat /proc/uptime
  350735.47 234388.90
The first number is the total number of seconds the system has been up. 
The second number is how much of that time the machine has spent idle, in seconds.
On multi core systems (and some linux versions) the second number is the sum of the idle time accumulated by each CPU.

> cat /proc/stat
cpu  2255 34 2290 22625563 6290 127 456
cpu0 1132 34 1441 11311718 3675 127 438
cpu1 1123 0 849 11313845 2614 0 18
intr 114930548 113199788 3 0 5 263 0 4 [... lots more numbers ...]
ctxt 1990473
btime 1062191376
processes 2915
procs_running 1
procs_blocked 0

The meanings of the columns are as follows, from left to right:

user: normal processes executing in user mode
nice: niced processes executing in user mode
system: processes executing in kernel mode
idle: twiddling thumbs
iowait: waiting for I/O to complete
irq: servicing interrupts
softirq: servicing softirqs

-------------------- Calculate CPU different occupancy --------------------
     USE NICE SYS    IDLE  IO IRQ SIRQ ? ? ?
cpu  14640 0 17906 1209731 179 0 21033 0 0 0

head -1 /proc/stat|awk '{print "USER="($2+$3)/($2+$3+$4+$5+$6+$7+$8)*100" IO="($6)/($2+$3+$4+$5+$6+$7+$8)*100" SYS="($4)/($2+$3+$4+$5+$6+$7+$8)*100" IDLE="($5)/($2+$3+$4+$5+$6+$7+$8)*100}'

-------------------- Calculate CPU idle occupancy from command vmstat --------------------
SLEEP_TIME=30;TOTAL=0;for i in $(seq 1 $SLEEP_TIME);do IDLE=`vmstat 1 2|tail -1|awk '{print $15}'`;echo $IDLE;TOTAL=`expr $TOTAL \+ $IDLE`;done;echo ilde_avg in $SLEEP_TIME Sec is : `expr $TOTAL \/ $SLEEP_TIME`

-------------------- Calculate System HZ from procps-3.2.8 top.c --------------------
CPU_NUMS=2;CPU_TIK=`head -1 /proc/stat|awk '{print $2+$3+$4+$5+$6+$7+$8}'`;LEN2=`cat /proc/uptime |awk -F'.' '{print $1}'`;LEN2=${#LEN2};read -n $LEN2 CPU_TIME < /proc/uptime;echo System_HZ=`expr $CPU_TIK \/ $CPU_TIME \/ $CPU_NUMS`
阅读(579) | 评论(0) | 转发(0) |
0

上一篇:[ZT] 中英混合三字经

下一篇:C语言语法

给主人留下些什么吧!~~