Conflicts:
	monitor.py
This commit is contained in:
Dan Ballard 2012-04-07 16:50:16 -07:00
commit 649b56390b
2 changed files with 18 additions and 2 deletions

5
README
View File

@ -0,0 +1,5 @@
Authors: Dan Ballard & Robert Hausch
Dependecies:
psutils 0.4.1 (PyPI)

View File

@ -23,6 +23,8 @@
import threading import threading
from socket import * from socket import *
from sensors.cpu import *
HOST = '' HOST = ''
PORT = 6000 PORT = 6000
ADDR = (HOST, PORT) ADDR = (HOST, PORT)
@ -35,7 +37,16 @@ class Stats:
self.read_lock = threading.Lock() self.read_lock = threading.Lock()
self.write_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): def acquire_read(self):
self.read_lock.acquire() self.read_lock.acquire()
@ -58,7 +69,7 @@ class ClientHandler:
self.stats = stats self.stats = stats
def handle(self, sock): def handle(self, sock):
conn_sock.send('{ cpu_load: %d}' % (self.stats.cpu_load)) conn_sock.send( self.stats.getStats() )
conn_sock.close() conn_sock.close()
stats = Stats() stats = Stats()