This commit is contained in:
Joshua Boniface 2018-06-01 00:53:53 -04:00
parent 54d40f117b
commit 2570d3c450
1 changed files with 20 additions and 18 deletions

View File

@ -53,7 +53,25 @@ class NodeInstance(threading.Thread):
def run(self):
if self.name == socket.gethostname():
self.setup_local_node()
conn = self.setup_local_node()
while True:
if self.name == socket.gethostname():
self.memfree = conn.getFreeMemory()
self.cpuload = os.getloadavg()[0]
try:
self.zk.set(self.zkey + '/memfree', str(self.memfree).encode('ascii'))
self.zk.set(self.zkey + '/cpuload', str(self.cpuload).encode('ascii'))
except:
if self.stop_thread.is_set():
return
print("Free memory: %s | Load: %s" % ( self.memfree, self.cpuload ))
print("Active domains: %s" % self.domainlist)
for x in range(0,100):
time.sleep(0.1)
if self.stop_thread.is_set():
return
@zk.DataWatch(self.zkey + '/state')
def watch_state(data, stat):
@ -93,20 +111,4 @@ class NodeInstance(threading.Thread):
print("Node hostname: %s" % self.name)
print("CPUs: %s" % self.cpucount)
while True:
self.memfree = conn.getFreeMemory()
self.cpuload = os.getloadavg()[0]
try:
self.zk.set(self.zkey + '/memfree', str(self.memfree).encode('ascii'))
self.zk.set(self.zkey + '/cpuload', str(self.cpuload).encode('ascii'))
except:
if self.stop_thread.is_set():
return
print("Free memory: %s | Load: %s" % ( self.memfree, self.cpuload ))
print("Active domains: %s" % self.domainlist)
for x in range(0,100):
time.sleep(0.1)
if self.stop_thread.is_set():
return
return conn