@@ -0,0 +1,1260 @@
+#!/usr/bin/env python%0A# coding:utf-8%0Aimport subprocess%0A%0Adef split_Num(pid_num):%0A    cmd = %22cat /proc/%25s/status%7Cgrep VmRSS%22 %25 pid_num%0A    p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)%0A    data = p.communicate()%5B0%5D%0A    mem_proc = data.split()%5B1%5D%0A    return mem_proc%0A%0Adef get_App_Mem(app_server):%0A    app_mem = 0%0A    cmd = %22ps aux%7Cgrep %25s%7Cgrep -v grep%22 %25 app_server%0A    p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)%0A    data = p.communicate()%5B0%5D.split('%5Cn')%5B:-1%5D%0A    for i in data:%0A        num = int(i.split()%5B1%5D)%0A        app_mem += int(split_Num(num))%0A    return app_mem%0A%0Adef mem_Total():%0A    cmd = %22grep MemTotal /proc/meminfo%22%0A    p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)%0A    data = p.communicate()%5B0%5D%0A    mem_total = data.split()%5B1%5D%0A    return mem_total%0A%0Adef get_Proportion(app_server):%0A    if get_App_Mem(app_server) == 0:%0A        print '%25s Total VmRSS: 0' %25 app_server%0A    else:%0A        app_mem = float(get_App_Mem(app_server))%0A        mem_total = int(mem_Total())%0A        return app_mem/mem_total%0A%0Aif __name__ == %22__main__%22:%0A    print get_App_Mem('httpd')%0A    print mem_Total()%0A    print get_Proportion('httpd')%0A%0A

add check_httpd_mem.py