Merge branch 'master' of https://github.com/rhausch/System-Monitoring-Daemon
Conflicts: monitor.py
This commit is contained in:
commit
649b56390b
5
README
5
README
|
@ -0,0 +1,5 @@
|
|||
Authors: Dan Ballard & Robert Hausch
|
||||
|
||||
Dependecies:
|
||||
psutils 0.4.1 (PyPI)
|
||||
|
15
monitor.py
15
monitor.py
|
@ -23,6 +23,8 @@
|
|||
import threading
|
||||
from socket import *
|
||||
|
||||
from sensors.cpu import *
|
||||
|
||||
HOST = ''
|
||||
PORT = 6000
|
||||
ADDR = (HOST, PORT)
|
||||
|
@ -35,7 +37,16 @@ class Stats:
|
|||
self.read_lock = threading.Lock()
|
||||
self.write_lock = threading.Lock()
|
||||
|
||||
self.cpu_load = 50
|
||||
self.sensors = []
|
||||
self.sensors.append(cpu_monitor())
|
||||
|
||||
def getStats(self):
|
||||
message = ''
|
||||
for s in self.sensors:
|
||||
s.update()
|
||||
message += '{'+s.getFormatedData()+'}'
|
||||
return message
|
||||
|
||||
|
||||
def acquire_read(self):
|
||||
self.read_lock.acquire()
|
||||
|
@ -58,7 +69,7 @@ class ClientHandler:
|
|||
self.stats = stats
|
||||
|
||||
def handle(self, sock):
|
||||
conn_sock.send('{ cpu_load: %d}' % (self.stats.cpu_load))
|
||||
conn_sock.send( self.stats.getStats() )
|
||||
conn_sock.close()
|
||||
|
||||
stats = Stats()
|
||||
|
|
Loading…
Reference in New Issue