release: support Raspberry Pi OS Trixie
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import time,socket,subprocess,configparser,signal,re,argparse,json,os,platform
|
||||
from pathlib import Path
|
||||
APP_VERSION="3.7.0"
|
||||
APP_VERSION="3.7.1"
|
||||
import sys
|
||||
sys.path.append("/usr/local/share/pigway-pi-control")
|
||||
from shutil import disk_usage
|
||||
@@ -105,6 +105,7 @@ page=0; page_since=time.monotonic()
|
||||
cpu_hi=mem_hi=0
|
||||
net_ok=link_ok=True
|
||||
net_iface=""; net_kind="NET"; net_metric="DOWN"; ip_label="IP4"; ip="NO IP"
|
||||
link_failure_since=internet_failure_since=None
|
||||
wifi_weak_since=None; wifi_weak_active=False
|
||||
last_net=last_watch=0
|
||||
watch_state=[]
|
||||
@@ -202,6 +203,8 @@ SENSOR_INTERVAL=cf("timing","sensor_interval",1.0)
|
||||
NETWORK_INTERVAL=cf("timing","network_interval",5.0)
|
||||
SERVICE_INTERVAL=cf("timing","service_interval",5.0)
|
||||
HEALTH_INTERVAL=cf("timing","health_interval",1.0)
|
||||
STARTUP_GRACE_SECONDS=max(0.0,cf("timing","startup_grace_seconds",15.0))
|
||||
NETWORK_FAILURE_SECONDS=max(0.0,cf("timing","network_failure_seconds",15.0))
|
||||
|
||||
CPU_HIGH=cf("alerts","cpu_high",90.0)
|
||||
CPU_RECOVER=cf("alerts","cpu_recover",75.0)
|
||||
@@ -433,6 +436,7 @@ if args.diagnose: raise SystemExit(diagnose())
|
||||
watch_state=[]
|
||||
last_sensor=last_status=0.0
|
||||
last_net=last_watch=last_health=0.0
|
||||
monitor_ready_at=time.monotonic()+STARTUP_GRACE_SECONDS
|
||||
health={}; fs_readonly=False
|
||||
agent={"last_sensor_ok":0.0,"last_network_ok":0.0,"last_watch_ok":0.0,"last_health_ok":0.0,"loop_errors":0}
|
||||
event_state={}
|
||||
@@ -455,9 +459,23 @@ try:
|
||||
c=cpu_pct(); t=temp_c(); m=mem_pct(); d=disk_pct()
|
||||
latest=(c,t,m,d); last_sensor=now; agent["last_sensor_ok"]=now
|
||||
|
||||
if now-last_net >= NETWORK_INTERVAL:
|
||||
if now>=monitor_ready_at and now-last_net >= NETWORK_INTERVAL:
|
||||
old_id=(net_iface,ip)
|
||||
net_iface,net_kind,net_metric,ip_label,ip=primary_network(); link_ok=ip!="NO IP"; net_ok=internet() if link_ok else False
|
||||
net_iface,net_kind,net_metric,ip_label,ip=primary_network()
|
||||
raw_link_ok=ip!="NO IP"; raw_net_ok=internet() if raw_link_ok else False
|
||||
if raw_link_ok:
|
||||
link_failure_since=None;link_ok=True
|
||||
else:
|
||||
if link_failure_since is None:link_failure_since=now
|
||||
link_ok=now-link_failure_since>=NETWORK_FAILURE_SECONDS
|
||||
link_ok=not link_ok
|
||||
if not raw_link_ok:
|
||||
internet_failure_since=None;net_ok=True
|
||||
elif raw_net_ok:
|
||||
internet_failure_since=None;net_ok=True
|
||||
else:
|
||||
if internet_failure_since is None:internet_failure_since=now
|
||||
net_ok=not (now-internet_failure_since>=NETWORK_FAILURE_SECONDS)
|
||||
new_id=(net_iface,ip)
|
||||
if new_id!=old_id:
|
||||
log("INFO","NET_SWITCH",old_if=old_id[0],old_ip=old_id[1],new_if=net_iface,new_ip=ip)
|
||||
@@ -465,7 +483,7 @@ try:
|
||||
transition("internet_down",link_ok and not net_ok,"INTERNET_DOWN","INTERNET_RECOVERED",iface=net_iface,ip=ip)
|
||||
last_net=now; agent["last_network_ok"]=now
|
||||
|
||||
if now-last_watch >= SERVICE_INTERVAL:
|
||||
if now>=monitor_ready_at and now-last_watch >= SERVICE_INTERVAL:
|
||||
watch_state=[check_watch(w) for w in watches]
|
||||
for w,ok in zip(watches,watch_state):
|
||||
transition("watch:"+w[0]+":"+w[1],not ok,"WATCH_DOWN","WATCH_RECOVERED",name=w[1],target=w[2])
|
||||
|
||||
Reference in New Issue
Block a user