Improve handling of keepalive and message printing
This commit is contained in:
parent
66fe258655
commit
0794cc854c
|
@ -143,14 +143,7 @@ class NodeInstance():
|
||||||
conn = libvirt.open(libvirt_name)
|
conn = libvirt.open(libvirt_name)
|
||||||
if conn == None:
|
if conn == None:
|
||||||
print('>>> Failed to open connection to %s' % libvirt_name)
|
print('>>> Failed to open connection to %s' % libvirt_name)
|
||||||
exit(1)
|
return
|
||||||
|
|
||||||
# Gather data about hypervisor
|
|
||||||
self.name = conn.getHostname()
|
|
||||||
self.cpucount = conn.getCPUMap()[0]
|
|
||||||
self.zk.set(self.zkey + '/cpucount', str(self.cpucount).encode('ascii'))
|
|
||||||
print("Node hostname: %s" % self.name)
|
|
||||||
print("CPUs: %s" % self.cpucount)
|
|
||||||
|
|
||||||
# Get past state and update if needed
|
# Get past state and update if needed
|
||||||
past_state = self.zk.get(self.zkey + '/state')[0].decode('ascii')
|
past_state = self.zk.get(self.zkey + '/state')[0].decode('ascii')
|
||||||
|
@ -182,17 +175,22 @@ class NodeInstance():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Set our information in zookeeper
|
# Set our information in zookeeper
|
||||||
|
self.name = conn.getHostname()
|
||||||
|
self.cpucount = conn.getCPUMap()[0]
|
||||||
self.memfree = conn.getFreeMemory()
|
self.memfree = conn.getFreeMemory()
|
||||||
self.cpuload = os.getloadavg()[0]
|
self.cpuload = os.getloadavg()[0]
|
||||||
try:
|
try:
|
||||||
|
self.zk.set(self.zkey + '/cpucount', str(self.cpucount).encode('ascii'))
|
||||||
self.zk.set(self.zkey + '/memfree', str(self.memfree).encode('ascii'))
|
self.zk.set(self.zkey + '/memfree', str(self.memfree).encode('ascii'))
|
||||||
self.zk.set(self.zkey + '/cpuload', str(self.cpuload).encode('ascii'))
|
self.zk.set(self.zkey + '/cpuload', str(self.cpuload).encode('ascii'))
|
||||||
self.zk.set(self.zkey + '/runningdomains', ' '.join(self.domain_list).encode('ascii'))
|
self.zk.set(self.zkey + '/runningdomains', ' '.join(self.domain_list).encode('ascii'))
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
print(">>> %s - Free memory: %s | Load: %s" % ( time.strftime("%d/%m/%Y %H:%M:%S"), self.memfree, self.cpuload ))
|
# Display node information to the terminal
|
||||||
print("Active domains: %s" % self.domain_list)
|
print('>>> {} - {} keepalive'.format(time.strftime('%d/%m/%Y %H:%M:%S'), self.name))
|
||||||
|
print(' CPUs: {} | Free memory: {} | Load: {}'.format(self.cpucount, self.memfree, self.cpuload))
|
||||||
|
print(' Active domains: {}'.format(' '.join(self.domain_list)))
|
||||||
|
|
||||||
# Update our local node lists
|
# Update our local node lists
|
||||||
for node_name in self.t_node:
|
for node_name in self.t_node:
|
||||||
|
@ -233,6 +231,8 @@ class NodeInstance():
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
print('Active nodes: %s' % self.active_node_list)
|
# Display cluster information to the terminal
|
||||||
print('Flushed nodes: %s' % self.flushed_node_list)
|
print('>>> {} - Cluster status'.format(time.strftime('%d/%m/%Y %H:%M:%S')))
|
||||||
print('Inactive nodes: %s' % self.inactive_node_list)
|
print(' Active nodes: {}'.format(' '.join(self.active_node_list)))
|
||||||
|
print(' Flushed nodes: {}'.format(' '.join(self.flushed_node_list)))
|
||||||
|
print(' Inactive nodes: {}'.format(' '.join(self.inactive_node_list)))
|
||||||
|
|
2
pvcd.py
2
pvcd.py
|
@ -119,7 +119,7 @@ update_zookeeper = this_node.update_zookeeper
|
||||||
|
|
||||||
# Create timer to update this node in Zookeeper
|
# Create timer to update this node in Zookeeper
|
||||||
update_timer = apscheduler.schedulers.background.BackgroundScheduler()
|
update_timer = apscheduler.schedulers.background.BackgroundScheduler()
|
||||||
update_timer.add_job(update_zookeeper, 'interval', seconds=2)
|
update_timer.add_job(update_zookeeper, 'interval', seconds=5)
|
||||||
update_timer.start()
|
update_timer.start()
|
||||||
|
|
||||||
# Tick loop
|
# Tick loop
|
||||||
|
|
Loading…
Reference in New Issue