To count the physical memory occupied by the Apache process
[[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# use pidof to view all httpd process numbers [[email protected] ~]# pidof httpd 13712 13711 13710 13709 13708 13707 13706 13705 13698[[email protected] ~]# cd /proc/13698 #apache的主进称, The others are Wahabbi called [[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 # This is the physical memory that the feed is occupying vmdata: 1812 kbvmstk: 88 kbvmexe: 336 Kbvmlib: 9964 kbvmpte: 376 kbvmswap: 0 kb
Then the sum of the physical memory occupied by all the httpd processes is counted, and all the memory occupied by the Apache service can be counted.
In [all]: from subprocess import Popen,pipein [+]: 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 ']
This article comes from "Plum blossom fragrance from bitter cold!" "Blog, be sure to keep this provenance http://daixuan.blog.51cto.com/5426657/1883130
To count the physical memory occupied by the Apache process