forked from Sysdeploy/idlers-agent
Compare commits
3 Commits
6a3c5737e5
...
75744e0010
Author | SHA1 | Date | |
---|---|---|---|
75744e0010 | |||
2c19f2eefc | |||
ea4675a56c |
17
agent.py
17
agent.py
|
@ -157,7 +157,7 @@ class ServerData:
|
||||||
return devices
|
return devices
|
||||||
|
|
||||||
# Get the list of nvme devices starting with 'nvme'
|
# Get the list of nvme devices starting with 'nvme'
|
||||||
nvme_devices = [device for device in os.listdir('/dev') if device.startswith('nvme')]
|
nvme_devices = [device for device in os.listdir('/sys/block') if device.startswith('nvme')]
|
||||||
|
|
||||||
for device in nvme_devices:
|
for device in nvme_devices:
|
||||||
device_path = '/dev/' + device
|
device_path = '/dev/' + device
|
||||||
|
@ -193,13 +193,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):
|
||||||
try:
|
continue
|
||||||
with open(size_path, 'r') as f:
|
try:
|
||||||
size = int(f.read().strip())
|
with open(size_path, 'r') as f:
|
||||||
disk += size
|
size = int(f.read().strip())
|
||||||
except Exception:
|
disk += size
|
||||||
pass # Skip the device if any exception occurs
|
except Exception:
|
||||||
|
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))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user