#
# 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`
阅读(612) | 评论(0) | 转发(0) |