統計apache進程佔用的實體記憶體

來源:互聯網
上載者:User

標籤:統計apache進程佔用的實體記憶體

統計apache進程佔用的實體記憶體

[[email protected] ~]# ps aux | grep httpdroot     13698  0.0  0.0 185628  4356 ?        Ss   17:12   0:00 /usr/sbin/httpdapache   13705  0.3  0.1 293504 27340 ?        S    17:12   0:00 /usr/sbin/httpdapache   13706  0.3  0.1 293504 27324 ?        S    17:12   0:00 /usr/sbin/httpdapache   13707  0.3  0.1 293504 27324 ?        S    17:12   0:00 /usr/sbin/httpdapache   13708  0.3  0.1 293504 27324 ?        S    17:12   0:00 /usr/sbin/httpdapache   13709  0.3  0.1 293504 27324 ?        S    17:12   0:00 /usr/sbin/httpdapache   13710  0.3  0.1 293504 27328 ?        S    17:12   0:00 /usr/sbin/httpdapache   13711  0.3  0.1 293504 27324 ?        S    17:12   0:00 /usr/sbin/httpdapache   13712  0.3  0.1 293504 27324 ?        S    17:12   0:00 /usr/sbin/httpdroot     13831  0.0  0.0 103320   908 pts/6    S+   17:15   0:00 grep httpd#使用pidof查看所有httpd的進程號[[email protected] ~]# pidof httpd 13712 13711 13710 13709 13708 13707 13706 13705 13698[[email protected] ~]# cd /proc/13698 #apache的主進稱,其它都是子進稱[[email protected] 13698]# cat statusName:httpdState:S (sleeping)Tgid:13698Pid:13698PPid:1TracerPid:0Uid:0000Gid:0000Utrace:0FDSize:64Groups:0VmPeak:  185628 kBVmSize:  185628 kBVmLck:       0 kBVmHWM:    4356 kBVmRSS:    4356 kB  #這是該進稱佔用的實體記憶體VmData:    1812 kBVmStk:      88 kBVmExe:     336 kBVmLib:    9964 kBVmPTE:     376 kBVmSwap:       0 kB

那麼將所有httpd的進程所佔用的實體記憶體之和統計出來,即可統計出apache服務佔用的所有記憶體


In [15]: from subprocess import Popen,PIPEIn [16]: p=Popen([‘pidof‘,‘httpd‘],stdout=PIPE,stderr=PIPE)In [22]: p.stdout.read().split()Out[22]: [‘13712‘, ‘13711‘, ‘13710‘, ‘13709‘, ‘13708‘, ‘13707‘, ‘13706‘, ‘13705‘, ‘13698‘]



本文出自 “梅花香自苦寒來!” 部落格,請務必保留此出處http://daixuan.blog.51cto.com/5426657/1883130

統計apache進程佔用的實體記憶體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.