15 lines
625 B
Python
15 lines
625 B
Python
#!/usr/bin/env python3
|
|
"""No-model threshold check. Exit 1 at >=85% used or <10GiB available."""
|
|
import json,os,subprocess,sys
|
|
|
|
def pressure(total,available):return available < 10*1024**3 or (total-available)/total >= .85
|
|
|
|
def main():
|
|
s=os.statvfs('/');total=s.f_blocks*s.f_frsize;available=s.f_bavail*s.f_frsize
|
|
alert=pressure(total,available)
|
|
message=json.dumps({'service':'canina-disk-watch','alert':alert,'total':total,'available':available})
|
|
print(message)
|
|
if alert:subprocess.run(['logger','-p','daemon.err','-t','canina-disk-watch',message],check=True)
|
|
return int(alert)
|
|
if __name__=='__main__':sys.exit(main())
|