Merge branch 'master' of https://github.com/rhausch/System-Monitoring-Daemon
This commit is contained in:
commit
367941070a
|
@ -24,6 +24,7 @@ import threading
|
||||||
from socket import *
|
from socket import *
|
||||||
|
|
||||||
from sensors.cpu import *
|
from sensors.cpu import *
|
||||||
|
from sensors.memory import *
|
||||||
|
|
||||||
HOST = ''
|
HOST = ''
|
||||||
PORT = 6000
|
PORT = 6000
|
||||||
|
@ -39,6 +40,7 @@ class Stats:
|
||||||
|
|
||||||
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