]>
code.delx.au - monosys/blob - healthcheck/checkspace
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
)))
31 for line
in open("/etc/fstab"):
32 if line
.startswith("#"):
34 _
, path
, _
= line
.split(maxsplit
=2)
35 if path
.startswith("/"):
40 paths
.update(read_fstab())
44 if __name__
== "__main__":