23 lines
517 B
Python
Executable File
23 lines
517 B
Python
Executable File
import os
|
|
import sys
|
|
import subprocess
|
|
|
|
class DiskMonitor:
|
|
def __init__(self, path="/"):
|
|
self.path = path
|
|
|
|
def get_free_gb(self):
|
|
try:
|
|
st = os.statvfs(self.path)
|
|
free_bytes = st.f_bavail * st.f_frsize
|
|
return round(free_bytes / (1024**3), 1)
|
|
except Exception:
|
|
return 0.0
|
|
|
|
def push_update(self):
|
|
sys.stdout.write(f"{self.get_free_gb()}\n")
|
|
sys.stdout.flush()
|
|
|
|
if __name__ == "__main__":
|
|
DiskMonitor().push_update()
|