Added Memory monitor
This commit is contained in:
parent
2ec58e6d51
commit
aaad5f5837
|
@ -23,6 +23,7 @@
|
||||||
from socket import *
|
from socket import *
|
||||||
|
|
||||||
from sensors.cpu import *
|
from sensors.cpu import *
|
||||||
|
from sensors.memory import *
|
||||||
|
|
||||||
HOST = ''
|
HOST = ''
|
||||||
PORT = 6000
|
PORT = 6000
|
||||||
|
@ -35,6 +36,7 @@ class Stats:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.sensors = []
|
self.sensors = []
|
||||||
self.sensors.append(cpu_monitor())
|
self.sensors.append(cpu_monitor())
|
||||||
|
self.sensors.append(mem_monitor())
|
||||||
|
|
||||||
def getStats(self):
|
def getStats(self):
|
||||||
message = ''
|
message = ''
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
class cpu_monitor:
|
||||||
|
def __init__(self):
|
||||||
|
self.num_cpus = len(psutil.cpu_percent(0,percpu=True))
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
self.cpu_usage = psutil.cpu_percent(0.1, percpu=True)
|
||||||
|
self.cpu_times = psutil.cpu_times()
|
||||||
|
|
||||||
|
def getFormatedData(self):
|
||||||
|
message = ''
|
||||||
|
message += 'Cpu usage: '
|
||||||
|
message += ', '.join('%.1f'%x for x in self.cpu_usage)
|
||||||
|
message += ' CPU times: '
|
||||||
|
message += ', '.join('%.3f'%x for x in self.cpu_times)
|
||||||
|
return message
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
class mem_monitor:
|
||||||
|
def __init__(self):
|
||||||
|
self.mem_usage = ''
|
||||||
|
self.virt_mem_usage = ''
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
self.mem_usage = psutil.phymem_usage()
|
||||||
|
self.virt_mem_usage = psutil.virtmem_usage()
|
||||||
|
|
||||||
|
def getFormatedData(self):
|
||||||
|
message = 'Memory- Phys: %.1f Virt: %.1f' % (self.mem_usage.percent, self.virt_mem_usage.percent)
|
||||||
|
return message
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue