28 lines
880 B
Python
28 lines
880 B
Python
import json
|
|
import requests
|
|
|
|
r = requests.get('http://140.44.4.11:31000/v1/nodes')
|
|
data = r.json()
|
|
print("Number of nodes:", len(data.get('data', [])))
|
|
|
|
total_avail = 0
|
|
total_max = 0
|
|
total_sched = 0
|
|
|
|
for n in data.get('data', []):
|
|
name = n.get('name')
|
|
disks = n.get('disks', {})
|
|
for d_name, d_info in disks.items():
|
|
avail = d_info.get('storageAvailable', 0)
|
|
max_s = d_info.get('storageMaximum', 0)
|
|
sched = d_info.get('storageScheduled', 0)
|
|
total_avail += avail
|
|
total_max += max_s
|
|
total_sched += sched
|
|
|
|
print(f"Total Max: {total_max / (1024**3):.2f} GiB ({total_max / (1024**4):.2f} TiB)")
|
|
print(f"Total Avail: {total_avail / (1024**3):.2f} GiB ({total_avail / (1024**4):.2f} TiB)")
|
|
used = total_max - total_avail
|
|
print(f"Total Used: {used / (1024**3):.2f} GiB ({used / (1024**4):.2f} TiB) ({used/total_max*100:.1f}%)")
|
|
|