From 40f36271cc4b7247cc6e1202d051749f824af3ab Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Mon, 24 Sep 2018 15:09:51 -0400 Subject: [PATCH] Send CPU load to ZK --- router-daemon/pvcrd/RouterInstance.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/router-daemon/pvcrd/RouterInstance.py b/router-daemon/pvcrd/RouterInstance.py index dbe054c2..037d2703 100644 --- a/router-daemon/pvcrd/RouterInstance.py +++ b/router-daemon/pvcrd/RouterInstance.py @@ -133,10 +133,12 @@ class RouterInstance(): self.daemon_state = 'run' # Set our information in zookeeper + cpuload = os.getloadavg()[0] keepalive_time = int(time.time()) try: zkhandler.writedata(self.zk_conn, { - '/routers/{}/keepalive'.format(self.name): str(keepalive_time) + '/routers/{}/keepalive'.format(self.name): str(keepalive_time), + '/routers/{}/cpuload'.format(self.name): str(cpuload), }) except: ansiiprint.echo('Failed to set keepalive data', '', 'e') @@ -144,7 +146,7 @@ class RouterInstance(): # Display router information to the terminal ansiiprint.echo('{}{} keepalive{}'.format(ansiiprint.purple(), self.name, ansiiprint.end()), '', 't') - ansiiprint.echo('{0}Network list:{1} {2}'.format(ansiiprint.bold(), ansiiprint.end(), self.network_list), '', 'c') + ansiiprint.echo('{0}Networks count:{1} {2} {0}Load average:{1} {3}'.format(ansiiprint.bold(), ansiiprint.end(), len(self.network_list), cpuload), '', 'c') # Update our local router lists for router_name in self.t_router: