]>
code.delx.au - monosys/blob - healthcheck/disk-usage
7 suffixes
= ["", "KiB", "MiB", "GiB"]
8 for i
, suffix
in enumerate(suffixes
):
12 return "%.2f %s" % (size
, suffix
)
16 stat
= os
.statvfs(path
)
17 total
= stat
.f_bsize
* stat
.f_blocks
18 free
= stat
.f_bsize
* stat
.f_bavail
21 if total
< 5*1024*1024*1024:
22 if free
< total
* 0.05:
24 elif free
< 2*1024*1024*1024:
28 print("WARNING! %s has only %s remaining" % (path
, pp_size(free
)))
34 for line
in open("/etc/fstab"):
35 if line
.startswith("#") or not line
.strip():
37 _
, path
, _
= line
.split(maxsplit
=2)
38 if path
.startswith("/"):
43 paths
.update(read_fstab())
46 ok
= ok
and check_path(path
)
51 if __name__
== "__main__":