mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Misc tweak for disk usage diagnosis, some values were inconsistent / bad UX / ...
This commit is contained in:
parent
94c9bf0f6d
commit
25a1e56921
1 changed files with 20 additions and 24 deletions
|
@ -61,40 +61,36 @@ class SystemResourcesDiagnoser(Diagnoser):
|
||||||
# Disks usage
|
# Disks usage
|
||||||
#
|
#
|
||||||
|
|
||||||
disk_partitions = psutil.disk_partitions()
|
disk_partitions = sorted(psutil.disk_partitions(), key=lambda k: k.mountpoint)
|
||||||
|
|
||||||
for disk_partition in disk_partitions:
|
for disk_partition in disk_partitions:
|
||||||
device = disk_partition.device
|
device = disk_partition.device
|
||||||
mountpoint = disk_partition.mountpoint
|
mountpoint = disk_partition.mountpoint
|
||||||
|
|
||||||
usage = psutil.disk_usage(mountpoint)
|
usage = psutil.disk_usage(mountpoint)
|
||||||
free_percent = round_(100 - usage.percent)
|
free_percent = 100 - round_(usage.percent)
|
||||||
|
|
||||||
item = dict(meta={"test": "diskusage", "mountpoint": mountpoint},
|
item = dict(meta={"test": "diskusage", "mountpoint": mountpoint},
|
||||||
data={"device": device, "total": human_size(usage.total), "free": human_size(usage.free), "free_percent": free_percent})
|
data={"device": device,
|
||||||
|
# N.B.: we do not use usage.total because we want
|
||||||
|
# to take into account the 5% security margin
|
||||||
|
# correctly (c.f. the doc of psutil ...)
|
||||||
|
"total": human_size(usage.used+usage.free),
|
||||||
|
"free": human_size(usage.free),
|
||||||
|
"free_percent": free_percent})
|
||||||
|
|
||||||
# Special checks for /boot partition because they sometimes are
|
# We have an additional absolute constrain on / and /var because
|
||||||
# pretty small and that's kind of okay... (for example on RPi)
|
# system partitions are critical, having them full may prevent
|
||||||
if mountpoint.startswith("/boot"):
|
# upgrades etc...
|
||||||
if usage.free < 10 * MB or free_percent < 10:
|
if free_percent < 2.5 or (mountpoint in ["/", "/var"] and usage.free < 1 * GB):
|
||||||
item["status"] = "ERROR"
|
item["status"] = "ERROR"
|
||||||
item["summary"] = "diagnosis_diskusage_verylow"
|
item["summary"] = "diagnosis_diskusage_verylow"
|
||||||
elif usage.free < 20 * MB or free_percent < 20:
|
elif free_percent < 5 or (mountpoint in ["/", "/var"] and usage.free < 2 * GB):
|
||||||
item["status"] = "WARNING"
|
item["status"] = "WARNING"
|
||||||
item["summary"] = "diagnosis_diskusage_low"
|
item["summary"] = "diagnosis_diskusage_low"
|
||||||
else:
|
|
||||||
item["status"] = "SUCCESS"
|
|
||||||
item["summary"] = "diagnosis_diskusage_ok"
|
|
||||||
else:
|
else:
|
||||||
if usage.free < 1 * GB or free_percent < 5:
|
item["status"] = "SUCCESS"
|
||||||
item["status"] = "ERROR"
|
item["summary"] = "diagnosis_diskusage_ok"
|
||||||
item["summary"] = "diagnosis_diskusage_verylow"
|
|
||||||
elif usage.free < 2 * GB or free_percent < 10:
|
|
||||||
item["status"] = "WARNING"
|
|
||||||
item["summary"] = "diagnosis_diskusage_low"
|
|
||||||
else:
|
|
||||||
item["status"] = "SUCCESS"
|
|
||||||
item["summary"] = "diagnosis_diskusage_ok"
|
|
||||||
|
|
||||||
|
|
||||||
yield item
|
yield item
|
||||||
|
|
Loading…
Add table
Reference in a new issue