34751: /usr/local/python/bin/python /opt/demo/bin/demo-server --config-file=/etc/demo.conf --log-config=/etc/demo-log.conf
0000000000400000 4K r-x-- /usr/local/python/bin/python2.7
0000000000600000 4K rw--- /usr/local/python/bin/python2.7
0000000000601000 10096K rw--- [ anon ]
0000000041826000 4K ----- [ anon ]
...
00007fff4bab8000 84K rw--- [ stack ]
00007fff4bb42000 4K r-x-- [ anon ]
ffffffffff600000 4K r-x-- [ anon ]
total 192320K
-x extended Show the extended format.
-d device Show the device format.
EXTENDED AND DEVICE FORMAT FIELDS
Address: start address of map
Kbytes: size of map in kilobytes
RSS: resident set size in kilobytes
Dirty: dirty pages (both shared and private) in kilobytes
Mode: permissions on map: read, write, execute, shared, private (copy on write)
Mapping: file backing the map, or ’[ anon ]’ for allocated memory, or ’[ stack ]’ for the program stack
Offset: offset into the file
Device: device name (major:minor)
34751: /usr/local/python/bin/python /opt/demo/bin/demo-server --config-file=/etc/demo.conf --log-config=/etc/demo-log.conf
Address Kbytes RSS Dirty Mode Mapping
0000000000400000 4 4 0 r-x-- python2.7
0000000000600000 4 4 4 rw--- python2.7
0000000000601000 10096 9964 9964 rw--- [ anon ]
...
00007fff4bb42000 4 4 0 r-x-- [ anon ]
ffffffffff600000 4 0 0 r-x-- [ anon ]
---------------- ------ ------ ------
total kB 192320 16360 12512
--sort spec specify sorting order. Sorting syntax is [+|-]key[,[+|-]key[,...]]
Choose a multi-letter key from the STANDARD FORMAT SPECIFIERS section.
The "+" is optional since default direction is increasing numerical or
lexicographic order. Identical to k. For example:
ps jax --sort=uid,-ppid,+pid
检查系统进程中超过cpu阀值和memory阀值的方法
MAX_CPU=5
MAX_MEM=10
ps aux | sort -rn -k 3 | awk '$3>$MAX_CPU {ot="";i=11;while(i<=NF) {ot=ot" "$i;i++};print $3,ot}'
ps aux | sort -rn -k 4 | awk '$3>$MAX_MEM {ot="";i=11;while(i<=NF) {ot=ot" "$i;i++};print $4,ot}'
上述统计超过5%的CPU usage的进程,还存在一个缺陷,就是没有计算system
,待完善。