forked from Sysdeploy/idlers-agent
updated get_ram_and_disk method
This commit is contained in:
parent
54d0b0decd
commit
28c8729b93
15
agent.py
15
agent.py
|
@ -101,13 +101,14 @@ class ServerData:
|
|||
for device in os.listdir('/sys/block'):
|
||||
device_path = '/sys/block/{}/device'.format(device)
|
||||
size_path = '/sys/block/{}/size'.format(device)
|
||||
if os.path.islink(device_path):
|
||||
try:
|
||||
with open(size_path, 'r') as f:
|
||||
size = int(f.read().strip())
|
||||
disk += size
|
||||
except Exception:
|
||||
pass # Skip the device if any exception occurs
|
||||
if not os.path.islink(device_path):
|
||||
continue
|
||||
try:
|
||||
with open(size_path, 'r') as f:
|
||||
size = int(f.read().strip())
|
||||
disk += size
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
disk = disk * 512 // (1024**3) # convert to GB
|
||||
logging.info("RAM: {}MB, Disk: {}GB".format(ram, disk))
|
||||
|
|
Loading…
Reference in New Issue
Block a user