alibaba / tsar

Taobao System Activity Reporter
Apache License 2.0
2.48k stars 733 forks source link

取进程内存使用量的模块 #41

Closed mingzym closed 10 years ago

mingzym commented 10 years ago

对一个进程,监控其内存的使用量,数据从/proc//status里取:

[root@localhost 704082]# cat status
Name:   java
State:  S (sleeping)
Tgid:   704082
Pid:    704082
PPid:   619125
TracerPid:  0
Uid:    0   0   0   0
Gid:    0   0   0   0
Utrace: 0
FDSize: 256
Groups: 0
envID:  1
VPid:   14118
StopState:  0
VmPeak:  1735256 kB
VmSize:  1735256 kB
VmLck:         0 kB
VmHWM:    147928 kB
VmRSS:    142048 kB
VmData:  1577640 kB
VmStk:        96 kB
VmExe:         4 kB
VmLib:     15440 kB
VmPTE:       592 kB
VmPTD:        32 kB
VmSwap:        0 kB
Threads:    33
SigQ:   1/191583
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 2000000181005ccf
SigSvd: 0000000000000000
CapInh: 00000000fdccefff
CapPrm: 00000000fdccefff
CapEff: 00000000fdccefff
CapBnd: 00000000fdccefff
Cpus_allowed:   ffff
Cpus_allowed_list:  0-15
Mems_allowed:   00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000003
Mems_allowed_list:  0-1
voluntary_ctxt_switches:    16
nonvoluntary_ctxt_switches: 4
TaskUB: 1
MMUB:   1
kongjian commented 10 years ago

这种模块已经有了 https://github.com/alibaba/tsar/blob/master/modules/mod_proc.c 配置: mod_proc on init 根据pidof init得到的进程id获取具体数据 -bash-3.2$ tsar --proc -l -i 1 Time -----------------------proc--------------------- Time user sys mem RSS read write 26/08/14-18:01:20 0.00 0.00 0.01 608.0K 0.00 0.00 26/08/14-18:01:21 0.00 0.00 0.01 608.0K 0.00 0.00 26/08/14-18:01:22 0.00 0.00 0.01 608.0K 0.00 0.00