#觀察系統一般參數
RH20 /home/cts>cat report1.sh
#!/bin/bash
LOG=~/report1.log
date > $LOG
echo "" >> $LOG
echo "=========================df==============================" >> $LOG
df >> $LOG
echo "" >> $LOG
echo "======================blockdev===========================" >> $LOG
blockdev --report /dev/sda >> $LOG
echo "" >> $LOG
echo "======================grub.conf==========================" >> $LOG
cat /etc/grub.conf >> $LOG
echo "" >> $LOG
echo "======================lsb_release========================" >> $LOG
lsb_release -a >> $LOG
echo "" >> $LOG
echo "=======================uname=============================" >> $LOG
uname -a >> $LOG
echo "" >> $LOG
echo "======================meminfo============================" >> $LOG
cat /proc/meminfo >> $LOG
echo "" >> $LOG
echo "======================cpuinfo============================" >> $LOG
cat /proc/cpuinfo >> $LOG
echo "" >> $LOG
echo "======================iostat=============================" >> $LOG
iostat -x >> $LOG
echo "" >> $LOG
echo "======================vmstat=============================" >> $LOG
vmstat -m >> $LOG
echo "" >> $LOG
vmstat -a >> $LOG
echo "" >> $LOG
vmstat -n >> $LOG
echo "" >> $LOG
vmstat -s >> $LOG
echo "" >> $LOG
vmstat -d >> $LOG
echo "" >> $LOG
echo "======================sysctl=============================" >> $LOG
sysctl -a | grep -e lowmem -e pressure -e page-cluster -e zone >> $LOG
#觀察系統io參數
RH20 /home/cts>cat report2.sh
#!/bin/bash
LOG=~/report2.log
date > $LOG
echo "" >> $LOG
echo "======================scheduler==========================" >> $LOG
cat /sys/block/sda/queue/scheduler >> $LOG
echo "" >> $LOG
echo "====================read_ahead_kb========================" >> $LOG
cat /sys/block/sda/queue/read_ahead_kb >> $LOG
echo "" >> $LOG
echo "====================nr_requests==========================" >> $LOG
cat /sys/block/sda/queue/nr_requests >> $LOG
echo "" >> $LOG
echo "===================antic_expire==========================" >> $LOG
cat /sys/block/sda/queue/iosched/antic_expire >> $LOG
echo "" >> $LOG
echo "===================read_expire===========================" >> $LOG
cat /sys/block/sda/queue/iosched/read_expire >> $LOG
echo "" >> $LOG
echo "===================write_expire==========================" >> $LOG
cat /sys/block/sda/queue/iosched/write_expire >> $LOG
echo "" >> $LOG
echo "=====================quantum=============================" >> $LOG
cat /sys/block/sda/queue/iosched/quantum >> $LOG
echo "" >> $LOG
echo "=====================queue===============================" >> $LOG
cat /sys/block/sda/queue/iosched/queue >> $LOG
echo "" >> $LOG
echo "=================front_merges============================" >> $LOG
cat /sys/block/sda/queue/iosched/front_merges >> $LOG
for pidd in $(pidof XGateway)
do
echo "" >> $LOG
top -n 1 -S -b -p $pidd >> $LOG
echo "" >> $LOG
ps -p $pidd -o comm,cmd,user,group >> $LOG
done
echo "" >> $LOG
top -S -b -n1 >> $LOG
#觀察2天的file fragmentation
RH20 /home/cts>cat report3.sh
#!/bin/bash
LOG=~/report3.log
date1="20110317"
date2="20110324"
date > $LOG
echo "" >> $LOG
echo "=========================KGIStkLog==============================" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KGIStkLog/10.0.250.24.Ord >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KGIStkLog/10.0.250.24.Ord >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KGIStkLog/10.0.250.24.Rpt >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KGIStkLog/10.0.250.24.Rpt >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KGIStkLog/10.0.250.24.RptOth >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KGIStkLog/10.0.250.24.RptOth >> $LOG
echo "" >> $LOG
echo "" >> $LOG
echo "=========================KStkSesLog=============================" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KStkSesLog/192.168.248.92.Ord >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KStkSesLog/192.168.248.92.Ord >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KStkSesLog/192.168.248.93.Ord >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KStkSesLog/192.168.248.93.Ord >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KStkSesLog/192.168.248.93.PreRpt >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KStkSesLog/192.168.248.93.PreRpt >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KStkSesLog/192.168.248.93.Rpt >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KStkSesLog/192.168.248.93.Rpt >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KStkSesLog/All.inn >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KStkSesLog/All.inn >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/KStkSesLog/All.preinn >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/KStkSesLog/All.preinn >> $LOG
echo "" >> $LOG
echo "" >> $LOG
echo "=========================orderlog===============================" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/orderlog/IvacMatch.rec >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/orderlog/IvacMatch.rec >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/orderlog/IvacOrder.rec >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/orderlog/IvacOrder.rec >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/orderlog/LocalIvacMatch.rec >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/orderlog/LocalIvacMatch.rec >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/orderlog/IvacStkLocalMat/0000 >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/orderlog/IvacStkLocalMat/0000 >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/orderlog/IvacStkLocalOrd/0000 >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/orderlog/IvacStkLocalOrd/0000 >> $LOG
echo "" >> $LOG
echo "" >> $LOG
echo "=========================OrderLog===============================" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/OrderLog/Stk/Deals.bin >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/OrderLog/Stk/Deals.bin >> $LOG
echo "" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/OrderLog/Stk/SysOrds.inn >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/OrderLog/Stk/SysOrds.inn >> $LOG
echo "" >> $LOG
echo "" >> $LOG
echo "=========================SyncLog================================" >> $LOG
echo "$date1" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date1/SyncLog/Stk.Sync >> $LOG
echo "$date2" >> $LOG
/usr/sbin/filefrag -v /xgw/XGW.Stk.K1/Logs/$date2/SyncLog/Stk.Sync >> $LOG
echo "" >> $LOG
2011年4月1日 星期五
2011年3月31日 星期四
AP@Linux Disk IO 效能調校
針對本次的測試說明如下: 1.使用Bryan提供的測試程式(XGW.STK.K1,以下簡稱XGW)(內含56000多筆的資料)來進行測試, 壓力測試程式在Windows 7(小黑nb,172.16.43.144)上執行 同時也執行了模擬後端主機(dbs)接收的的程式 2.本次的XGW在3台機器上分別進行驗證,不過主要以驗證PC -1為主,硬體與作業系統規格如下
| PC - 1 | kernel | 2.6.18-164.el5PAE | |||
| distribution | RHEL5.4(172.16.43.99) | ||||
| memory | MemTotal: 3916364 kB | ||||
| cpu | Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz | ||||
| disk | 500G 7200rpm(single) | ||||
| PC - 2 | kernel | 2.6.18-92.el5 | |||
| distribution | RHEL5.2(172.16.43.171) | ||||
| memory | MemTotal: 3107452 kB | ||||
| cpu | Intel(R) Pentium(R) Dual CPU E2140 @ 1.60GHz | ||||
| disk | 160G 7200rpm(single) | ||||
| PC - 3 | kernel | 2.6.18-194.el5 | |||
| distribution | CentOS5.5(172.16.43.170) | ||||
| memory | MemTotal: 16411680 kB | ||||
| cpu | Intel(R) Xeon(R) CPU E5506 @ 2.13GHz(quard core * 2) | ||||
| disk | 7200 rpm(raid-5, 146G*3) | ||||
| HDD | nr_requests | episode | time(sec) | min CPU idle% | avg CPU idle% | XGW useage% | wa%(inc. in idle) | PC2 time | PC3 time |
| cfq | 64 | 0c0101092 | 173 | ||||||
| 128 | 0c0202092 | 157 | 44 | 68.09 | 45.66 | 19.2 | 168 | 82 | |
| 512 | 0c01020c1 | 121 | |||||||
| 1024 | 0c01030c1 | 85 | |||||||
| 2048 | 0c0103092 | 86 | 115 | 66 | |||||
| 4096 | 0c01010c1 | 93 | 35 | 63.26 | 56.06 | 18.65 | 116 | 65 | |
| anticipatory | 64 | 0b0101012 | 159 | ||||||
| 128 | 0b0202012 | 153 | |||||||
| 2048 | 0b0103012 | 85 | 114 | 71 | |||||
| 4096 | 0b01010c1 | 77 | 55 | 72.88 | 62.8 | 11.04 | 115 | 69 | |
| deadline | 64 | 0a0101012 | 171 | ||||||
| 128 | 0a0202012 | 159 | |||||||
| 2048 | 0a0103012 | 101 | 121 | 121 | |||||
| noop | 64 | 0d01010b1 | 163 | ||||||
| 128 | 0d02020b1 | 171 | |||||||
| 2048 | 0d01030b1 | 140 | 181 | 231 |
| ramdisk | nr_requests | episode | time diff |
| cfq | 128 | - | 79 |
| 1024 | - | 79 | |
| 2048 | - | 76 | |
| anticipatory | 128 | - | 79 |
監控目前HDD有在IO作業的PROCESS是哪一支
while true; do date; ps auxf | awk '{if($8=="D") print $0;}'; sleep 1; done
sleep 1若改usleep 300000, 則0.3秒監控一次,可以更快反應
其中,可以取得PID , 進一步透過/proc/PID/io 來找出相對應的read/write統計資料
rchar => This is the total reads caused by the process in bytes. This includes bytes read from the disk or from console
wchar => The same as rchar but it accounts for bytes written instead of read
read_bytes => Actual number of bytes read from the storage
write_bytes => Actual bytes written to the storage
Here's the script that shows you the top 5 processes which are reading data from disk:
grep read_bytes /proc/[0-9]*/io | sort -nrk2 | head -5
writing data, execute the following:
grep write_bytes /proc/[0-9]*/io | sort -nrk2 | head -5
There's also an utility called "iotop" which does the same thing in real time and gives you better top-like output
yum install iotop
/proc/PID/status, 則是方面的統計內容 參考資料: http://yoshinorimatsunobu.blogspot.com/2009/04/linux-io-scheduler-queue-size-and.html http://www.softpanorama.org/Commercial_linuxes/performance_tuning.shtml
2011年3月23日 星期三
process用top監控的方便
一般用top監控,如果想要留記錄來比較,可能會覺得不太方便,以下是可以留一個時間跟資料內容來當成追蹤記錄
top -S -b -p $(pidof XGateway) grep -e XGateway -e average
[結果]
top - 16:13:11 up 42 days, 21:00, 4 users, load average: 1.11, 1.19, 1.17
31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:12.54 XGateway
top - 16:13:14 up 42 days, 21:00, 4 users, load average: 1.10, 1.18, 1.17
31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:12.54 XGateway
top - 16:13:17 up 42 days, 21:00, 4 users, load average: 1.41, 1.25, 1.19
31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:12.54 XGateway
top - 16:13:20 up 42 days, 21:00, 4 users, load average: 1.41, 1.25, 1.19
31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:12.54 XGateway
top - 16:13:23 up 42 days, 21:00, 4 users, load average: 1.46, 1.26, 1.20
[root@RH20 cts]# cat top.sh#!/bin/bash
pidd=$(pidof XGateway)
while [ 1 ]
do
#Solaris不適用
echo "$(date +%H:%M:%S) $(top -n1 -S -b -p $pidd | grep -e XGateway )"
usleep 500000
done
[結果]17:01:19 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:20 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:21 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:22 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:23 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:24 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:25 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:26 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:27 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:28 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:29 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
17:01:30 31555 cts 15 0 227m 60m 8416 S 0.0 1.6 0:15.84 XGateway
[root@RH20 cts]# cat vmstat.sh#!/bin/bash
#pidd=$(pidof XGateway)
while [ 1 ]
do
str="$(vmstat 1 2| tail -n 1)"
#在solaris這行要改成 "$(vmstat 1 2 | tail -1l)"
echo "$(date +%H:%M:%S) $str"
done
[結果][root@RH20 cts]# ./vmstat.sh
20:21:02 0 0 896 1011492 325056 2152676 0 0 0 0 1006 4532 2 3 96 0 0
20:21:03 0 0 896 1011616 325056 2152676 0 0 0 260 1059 4558 1 2 97 0 0
20:21:04 0 0 896 1011616 325056 2152684 0 0 0 0 1004 4759 1 2 97 0 0
20:21:05 2 0 896 1011616 325056 2152684 0 0 0 0 1010 2977 1 1 98 0 0
[root@RH20 cts]# cat iostat.sh
#==================================================
# you must install sysstat-* rpm for iostat
#==================================================
#iostat有不同版本,取得字串的行數就會不一樣
iostatver=$(iostat -V &> /dev/stdout | grep sysstat)
if [ "$iostatver" != "" ]; then
ntail=2
nhead=1
else
ntail=1
nhead=1
fi
if [ "$1" != "" ]; then
device="$1"
else
device="sda"
fi
while [ 1 ]
do
strdate=$(date +%H:%M:%S)
#strstr=$(iostat -x $1 $2 $3 $4 $5 1 2 | tail -n $ntail | head -n $nhead | awk 'NR==1{ printf " %s %s\n","########",$0} NR>=2{printf " %s %s\n"," ",$0}' | sed 's/########/'${strdate}'/')
strstr=$(iostat -x $device 3 2 | tail -n $ntail | head -n $nhead | awk 'NR==1{ printf " %s %s\n","########",$0} NR>=2{printf " %s %s\n"," ",$0}' | sed 's/########/'${strdate}'/')
echo "$strstr"
done
[結果]RH20 /home/cts>./iostat.sh sda
13:58:58 sda 0 1 0.0 3.0 0.0 16.0 5.3 0.0 0.0 0.0 0
13:58:59 sda 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0
13:59:00 sda 0 33 0.0 12.0 0.0 192.0 16.0 0.2 18.9 2.0 2
2010年12月13日 星期一
process監控的問題與替代方法
在監控某一process時,常用
watch -n1 ps -p $(pidof 'process name' ) -o comm,pid,vss,rsz,pcpu,pri,cstime,cutime,utime
或者
while :; do date; ps -p $(pidof 'process name') -o comm,pid,vss.rsz,pcpu,pri,cstime,cutime,utime ;sleep 1; done
while :; do date; ps -oe comm,pid,vss,rsz,pcpu,pri,cstime,cutime,utime | grep 'process name' ;sleep 1; done
或者
for pidd in $(pidof 'process name')
do
top -n 1 -S -b -p $pidd >> $LOG
ps -p $pidd -o comm,cmd,user,group >> $LOG
done
但會發現pcpu(欄位%CPU)不會變,跟top指令比較,TOP確會變
於是修改指令如下,即可:
while :; do date; top -n 1 -S -b | grep vmware-vmx;sleep 1; done
[AIX]
ps -p 442584 -o args,pid,vsz,pcpu
ps -ef -o args,pid,vsz,pcpu
#!/usr/bin/ksh
if [ "$1" = "" ] ; then
echo "you need to entery the [pid] what you want to lookup."
echo "shell>./mon.sh [pid]"
exit 0;
else
# while :; do date >> ~/mon.log;ps -ef -o comm,pid,pcpu,vsz | grep $1 >> ~/mon.log ; sleep 5; done
while :; do date >> ~/mon.log;ps -efl | grep $1 >> ~/mon.log ; sleep 5; done
fi
[結果]
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
200003 A root 1 0 0 60 20 d8039000 756 Nov 24 - 0:21 /etc/init
240001 A root 98420 1 0 60 20 d0138400 496 * Nov 24 - 11:37 /usr/sbin/syncd 60
40401 A root 102602 1 0 60 20 e803f400 828 10a09d8 Nov 24 - 0:00 /usr/lib/errdemon
TIME
(all flags) The total execution time for the process.
TTY
(all flags) The controlling workstation for the process:
-
The process is not associated with a workstation.
?
Unknown.
Number
The TTY number. For example, the entry 2 indicates TTY2.
UID
(-f, -l, and l flags) The user ID of the process owner. The login name is printed under the -f flag.
WCHAN
(-l flag) The event for which the process or kernel thread is waiting or sleeping. For a kernel thread, this field is
blank if the kernel thread is running. For a process, the wait channel is defined as the wait channel of the sleeping
kernel thread if only one kernel thread is sleeping; otherwise STIME
(-f and u flags) The starting time of the process. The LANG environment variables control the appearance of this
field.
SZ
(-l and l flags) The size in 1KB units of the core image of the
NI
(-l and l flags) The nice value; used in calculating priority for the sched other policy.
PID
(all flags) The process ID of the process.
PGIN
(v flag) The number of disk I/Os resulting from references by the process to pages not loaded in core.
PPID
(-f, l, and -l flags) The process ID of the parent process.
PRI
(-l and l flags) The priority of the process or kernel thread; higher numbers mean lower priority.
S
(-l and l flags) The state of the process or kernel thread :(見man ps)
F
(-l and l flags) Some of the more important F field flags (hexadecimal and additive) associated with processes and
threads are shown in the following table:(見man ps)
CMD
(-f, -l, and l flags) Contains the command name. Under the -f flag, ps tries to determine the current command name and
arguments both of which may be changed asynchronously by the process. These are then displayed. Failing this, the
command name as it would appear without the option -f, is written in square brackets.
ADDR
(-l and l flags) Contains the segment number of the process stack, if normal; if a kernel process, the address of the
preprocess data area.
C
(-f, l, and -l flags) CPU utilization of process or thread, incremented each time the system clock ticks and the
process or thread is found to be running. The value is decayed by the scheduler by dividing it by 2 once per second.
For the sched_other policy, CPU utilization is used in determining process scheduling priority. Large values indicate
a CPU intensive process and result in lower process priority whereas small values indicate an I/O intensive process
and result in a more favorable priority.
watch -n1 ps -p $(pidof 'process name' ) -o comm,pid,vss,rsz,pcpu,pri,cstime,cutime,utime
或者
while :; do date; ps -p $(pidof 'process name') -o comm,pid,vss.rsz,pcpu,pri,cstime,cutime,utime ;sleep 1; done
while :; do date; ps -oe comm,pid,vss,rsz,pcpu,pri,cstime,cutime,utime | grep 'process name' ;sleep 1; done
或者
for pidd in $(pidof 'process name')
do
top -n 1 -S -b -p $pidd >> $LOG
ps -p $pidd -o comm,cmd,user,group >> $LOG
done
但會發現pcpu(欄位%CPU)不會變,跟top指令比較,TOP確會變
於是修改指令如下,即可:
while :; do date; top -n 1 -S -b | grep vmware-vmx;sleep 1; done
[AIX]
ps -p 442584 -o args,pid,vsz,pcpu
ps -ef -o args,pid,vsz,pcpu
#!/usr/bin/ksh
if [ "$1" = "" ] ; then
echo "you need to entery the [pid] what you want to lookup."
echo "shell>./mon.sh [pid]"
exit 0;
else
# while :; do date >> ~/mon.log;ps -ef -o comm,pid,pcpu,vsz | grep $1 >> ~/mon.log ; sleep 5; done
while :; do date >> ~/mon.log;ps -efl | grep $1 >> ~/mon.log ; sleep 5; done
fi
[結果]
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
200003 A root 1 0 0 60 20 d8039000 756 Nov 24 - 0:21 /etc/init
240001 A root 98420 1 0 60 20 d0138400 496 * Nov 24 - 11:37 /usr/sbin/syncd 60
40401 A root 102602 1 0 60 20 e803f400 828 10a09d8 Nov 24 - 0:00 /usr/lib/errdemon
TIME
(all flags) The total execution time for the process.
TTY
(all flags) The controlling workstation for the process:
-
The process is not associated with a workstation.
?
Unknown.
Number
The TTY number. For example, the entry 2 indicates TTY2.
UID
(-f, -l, and l flags) The user ID of the process owner. The login name is printed under the -f flag.
WCHAN
(-l flag) The event for which the process or kernel thread is waiting or sleeping. For a kernel thread, this field is
blank if the kernel thread is running. For a process, the wait channel is defined as the wait channel of the sleeping
kernel thread if only one kernel thread is sleeping; otherwise STIME
(-f and u flags) The starting time of the process. The LANG environment variables control the appearance of this
field.
SZ
(-l and l flags) The size in 1KB units of the core image of the
NI
(-l and l flags) The nice value; used in calculating priority for the sched other policy.
PID
(all flags) The process ID of the process.
PGIN
(v flag) The number of disk I/Os resulting from references by the process to pages not loaded in core.
PPID
(-f, l, and -l flags) The process ID of the parent process.
PRI
(-l and l flags) The priority of the process or kernel thread; higher numbers mean lower priority.
S
(-l and l flags) The state of the process or kernel thread :(見man ps)
F
(-l and l flags) Some of the more important F field flags (hexadecimal and additive) associated with processes and
threads are shown in the following table:(見man ps)
CMD
(-f, -l, and l flags) Contains the command name. Under the -f flag, ps tries to determine the current command name and
arguments both of which may be changed asynchronously by the process. These are then displayed. Failing this, the
command name as it would appear without the option -f, is written in square brackets.
ADDR
(-l and l flags) Contains the segment number of the process stack, if normal; if a kernel process, the address of the
preprocess data area.
C
(-f, l, and -l flags) CPU utilization of process or thread, incremented each time the system clock ticks and the
process or thread is found to be running. The value is decayed by the scheduler by dividing it by 2 once per second.
For the sched_other policy, CPU utilization is used in determining process scheduling priority. Large values indicate
a CPU intensive process and result in lower process priority whereas small values indicate an I/O intensive process
and result in a more favorable priority.
訂閱:
文章 (Atom)
文章分類
- 爬山 (3)
- 參考文章 (3)
- 鳥事 (5)
- 報稅 (1)
- AIX (2)
- ajax (1)
- BCB (3)
- C/C++ (2)
- cloudera (3)
- DISK (1)
- ftp (1)
- Fuse (2)
- gdb (2)
- hadoop (13)
- hdfs (8)
- HPC (2)
- hypertable (12)
- iOS (1)
- iscsi (1)
- JAVA (2)
- KFS (5)
- kickstart (1)
- KVM (2)
- LAMP (2)
- linux (2)
- Lion (1)
- LVM (2)
- mapreduce (3)
- mpi (3)
- mpich2 (4)
- msgpack (2)
- mysql (2)
- nfs (1)
- openmp (2)
- OS (1)
- OSX (2)
- others (5)
- PBS (1)
- performance_tuning (3)
- php (3)
- phplist (3)
- programming (27)
- REST (2)
- RHCA (6)
- rhel (13)
- rhel6 (4)
- scp (1)
- shell_scripts (2)
- snowleopard (2)
- Solaris (6)
- ssh (1)
- syslog (1)
- t-442-1 (4)
- torque (1)
- ubuntu (2)
- VNC (1)
- watercolor (5)
- windows (1)
- yum (1)
