#coding=utf-8__author__ = 'kenkao'
import os
def getNginxProcess(): p = os.popen('ps -C nginx -no-header | wc -l') return p.read()
def getNginxMemory(): p = os.popen('top -b -n1 | grep nginx |gawk \'{if($6~/m$/) {sum+=$6*1024} else {sum+=$6} }; END {print int(sum/1024)}\'') return p.read()
def getNginxConnect(): p = os.popen('netstat -nat|grep -i "80"|wc -l') return p.read()
def getPhpfpmProcess(): p = os.popen('ps -C php-fpm -no-header | wc -l') return p.read()
def getPhpfpmMemory(): p = os.popen('top -b -n1 | grep php-fpm |gawk \'{if($6~/m$/) {sum+=$6*1024} else {sum+=$6} }; END {print int(sum/1024)}\'') return p.read()
if __name__ == '__main__': print "NginxProcess:" + getNginxProcess() print "NginxMemory:" + getNginxMemory() print "NginxConnect:" + getNginxConnect() print "PhpfpmProcess:" + getPhpfpmProcess() print "PhpfpmMemory:" + getPhpfpmMemory()