From 9707368e3d3ab67dded5dc6875c40fc6ca8bba50 Mon Sep 17 00:00:00 2001 From: rasmus Date: Tue, 22 Dec 2020 00:39:28 +0200 Subject: [PATCH] We have all data we need --- main.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index f984672..9ef2bf8 100644 --- a/main.py +++ b/main.py @@ -78,13 +78,14 @@ logging.info("There are " + str(baysInUseCount+1) + "servers presenet.") # Furth ## Get blade data ## -for b in range(1, baysInUseCount+1): - logging.info("Accessing server " + str(b)) - logging.debug( ssh_runcmd('connect server ' + str(b)) ) # Use the enc as a jump host. +for n in range(baysInUseCount): + bay = servers[n][0] # We want the bay, not how many times we have looped over. + logging.info("Accessing server " + str(bay)) + logging.debug( ssh_runcmd('connect server ' + str(bay)) ) # Use the enc as a jump host. powerInfoTmp = ssh_runcmd('show system1/oemhp_power1') # Get the data presentPower = [i for i in powerInfoTmp if i.startswith(' oemhp_PresentPower=')][0][23:-7] # Get the line with PresentPower, then remove first 23, and last 7 chars to end up with the Watts DC the blade is directly using. - servers[b-1].append(int(presentPower)) # And push it to our miniDB of the servers list. + servers[n].append(int(presentPower)) # And push it to our miniDB of the servers list. logging.info("UsageRawDC: " + presentPower) logging.debug(ssh_runcmd('exit')) # Exit the blade's iLO, return to the enc's iLO SSH interface. @@ -96,9 +97,18 @@ for b in range(1, baysInUseCount+1): ## Get enc's _AC_ usage. ## -encPowerUsageAC = int( [i for i in ssh_runcmd('show power') if i.startswith('Present Power:')][0] )# [23:-7] +encPowerUsageAC = int(str.strip( [i for i in ssh_runcmd('show power') if i.startswith('Present Power:')][0][14:-9] )) logging.info("Server total usage AC: " + str(encPowerUsageAC)) -# End sesion with enc. +## End sesion with enc. ## channel.send('exit' + '\n') # Using lower level cmd since we're not going to get a prompt back here. ssh.close() + + + + +## Calculating blade usage by percentage. ## +# Keep in mind the querying of the data took a while, a minute or so. + +breakpoint() +print()