|
|
@ -130,6 +130,11 @@ def get_traffic(request): |
|
|
data = pipe.read().strip().split(':',1)[-1] |
|
|
data = pipe.read().strip().split(':',1)[-1] |
|
|
pipe.close() |
|
|
pipe.close() |
|
|
|
|
|
|
|
|
|
|
|
if type(data[0]) is str: |
|
|
|
|
|
pipe = os.popen("cat /proc/net/dev |" + "grep " + request + "| awk '{print $2, $10}'") |
|
|
|
|
|
data = pipe.read().strip().split(':',1)[-1] |
|
|
|
|
|
pipe.close() |
|
|
|
|
|
|
|
|
data = data.split() |
|
|
data = data.split() |
|
|
|
|
|
|
|
|
traffic_in = int(data[0]) |
|
|
traffic_in = int(data[0]) |
|
|
@ -173,6 +178,9 @@ def get_disk(): |
|
|
return data |
|
|
return data |
|
|
|
|
|
|
|
|
def get_mem(): |
|
|
def get_mem(): |
|
|
|
|
|
""" |
|
|
|
|
|
Get memory usage |
|
|
|
|
|
""" |
|
|
try: |
|
|
try: |
|
|
pipe = os.popen("free -tmo | " + "grep 'Mem' | " + "awk '{print $2,$4}'") |
|
|
pipe = os.popen("free -tmo | " + "grep 'Mem' | " + "awk '{print $2,$4}'") |
|
|
data = pipe.read().strip().split() |
|
|
data = pipe.read().strip().split() |
|
|
@ -194,6 +202,9 @@ def get_mem(): |
|
|
return data |
|
|
return data |
|
|
|
|
|
|
|
|
def get_cpu_usage(): |
|
|
def get_cpu_usage(): |
|
|
|
|
|
""" |
|
|
|
|
|
Get the CPU usage and running processes |
|
|
|
|
|
""" |
|
|
try: |
|
|
try: |
|
|
pipe = os.popen("ps aux --sort -%cpu,-rss") |
|
|
pipe = os.popen("ps aux --sort -%cpu,-rss") |
|
|
data = pipe.read().strip().split('\n') |
|
|
data = pipe.read().strip().split('\n') |
|
|
@ -223,6 +234,9 @@ def get_cpu_usage(): |
|
|
return data |
|
|
return data |
|
|
|
|
|
|
|
|
def get_load(): |
|
|
def get_load(): |
|
|
|
|
|
""" |
|
|
|
|
|
Get load average |
|
|
|
|
|
""" |
|
|
try: |
|
|
try: |
|
|
data = os.getloadavg()[0] |
|
|
data = os.getloadavg()[0] |
|
|
except Exception, err: |
|
|
except Exception, err: |
|
|
|