Added CPU usage

This commit is contained in:
Robert Hausch 2012-04-07 16:47:30 -07:00
parent e51a76116e
commit 2ec58e6d51
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

@ -22,6 +22,8 @@
from socket import *
from sensors.cpu import *
HOST = ''
PORT = 6000
ADDR = (HOST, PORT)
@ -31,14 +33,23 @@ MAX_QUEUE = 5
class Stats:
def __init__(self):
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
class ClientHandler:
def __init__(self, stats):
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()