We have all data we need

This commit is contained in:
rasmus 2020-12-22 00:39:28 +02:00
parent 380d911596
commit 9707368e3d
1 changed files with 16 additions and 6 deletions

22
main.py
View File

@ -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()