MCPcopy Create free account
hub / github.com/apache/cloudstack / main

Function main

systemvm/debian/root/health_checks/disk_space_check.py:23–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21
22
23def main():
24 entries = getHealthChecksData("systemThresholds")
25 data = {}
26 if entries is not None and len(entries) == 1:
27 data = entries[0]
28
29 if "minDiskNeeded" not in data:
30 print("Missing minDiskNeeded in health_checks_data systemThresholds, skipping")
31 exit(3)
32
33 minDiskNeeded = float(data["minDiskNeeded"]) * 1024
34 s = statvfs('/')
35 freeSpace = (s.f_bavail * s.f_frsize) / 1024
36
37 if (freeSpace < minDiskNeeded):
38 print("Insufficient free space is " + str(freeSpace/1024) + " MB")
39 exit(1)
40 else:
41 print("Sufficient free space is " + str(freeSpace/1024) + " MB")
42 exit(0)
43
44
45if __name__ == "__main__":

Callers 1

Calls 2

getHealthChecksDataFunction · 0.90
exitFunction · 0.85

Tested by

no test coverage detected