updated get_ram_and_disk method
All checks were successful
buildbot/multibuild_parent Build done.
buildbot/travis_bionic Build done.

This commit is contained in:
Shailaja Kumari 2024-06-28 18:12:11 +05:30
parent bd6ecc3519
commit ea4675a56c
Signed by: shailaja
GPG Key ID: 2B9455CAFBC4D75A

View File

@ -145,13 +145,14 @@ class ServerData:
for device in os.listdir('/sys/block'): for device in os.listdir('/sys/block'):
device_path = '/sys/block/{}/device'.format(device) device_path = '/sys/block/{}/device'.format(device)
size_path = '/sys/block/{}/size'.format(device) size_path = '/sys/block/{}/size'.format(device)
if os.path.islink(device_path): if not os.path.islink(device_path):
continue
try: try:
with open(size_path, 'r') as f: with open(size_path, 'r') as f:
size = int(f.read().strip()) size = int(f.read().strip())
disk += size disk += size
except Exception: except Exception:
pass # Skip the device if any exception occurs pass
disk = disk * 512 // (1024**3) # convert to GB disk = disk * 512 // (1024**3) # convert to GB
logging.info("RAM: {}MB, Disk: {}GB".format(ram, disk)) logging.info("RAM: {}MB, Disk: {}GB".format(ram, disk))