Compare commits
12
Commits
3ed1be8d60
..
v2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5dd99ecdc | ||
|
|
f74fa8f7c8 | ||
|
|
fa451fbf93 | ||
|
|
39e6536db1 | ||
|
|
8ff42c8cc0 | ||
|
|
1de64378f2 | ||
|
|
3f91ba88f9 | ||
|
|
3b2b2fd082 | ||
|
|
d54b9ac132 | ||
|
|
787f138488 | ||
|
|
2aa915d5fb | ||
|
|
690aec65e7 |
@@ -362,16 +362,19 @@ def on_message(client, userdata, msg):
|
|||||||
notify_update() # <--- WEBSOCKET
|
notify_update() # <--- WEBSOCKET
|
||||||
|
|
||||||
# --- PUSH TRIGGER: NODE STATE ---
|
# --- PUSH TRIGGER: NODE STATE ---
|
||||||
if payload.upper() == 'OFFLINE':
|
# L'agente invia "OFFLINE - <ID>" (anche come LWT) e "ONLINE - <profilo>": si confronta il PREFISSO.
|
||||||
if last_notified_errors.get(f"{cid}_NODE") != 'OFFLINE':
|
# I messaggi retained (già sul broker quando il server si avvia) non generano notifiche.
|
||||||
|
state_up = payload.upper()
|
||||||
|
if state_up.startswith('OFFLINE'):
|
||||||
|
if not msg.retain and last_notified_errors.get(f"{cid}_NODE") != 'OFFLINE':
|
||||||
broadcast_push_notification(f"💀 NODE OFFLINE: {cid.upper()}", "Connection lost with broker.", cid=cid)
|
broadcast_push_notification(f"💀 NODE OFFLINE: {cid.upper()}", "Connection lost with broker.", cid=cid)
|
||||||
last_notified_errors[f"{cid}_NODE"] = 'OFFLINE'
|
last_notified_errors[f"{cid}_NODE"] = 'OFFLINE'
|
||||||
elif payload.upper() == 'ONLINE':
|
elif state_up.startswith('ONLINE'):
|
||||||
if last_notified_errors.get(f"{cid}_NODE") == 'OFFLINE':
|
if last_notified_errors.get(f"{cid}_NODE") == 'OFFLINE':
|
||||||
broadcast_push_notification(f"🌤️ NODE ONLINE: {cid.upper()}", "Node is back online.", cid=cid)
|
broadcast_push_notification(f"🌤️ NODE ONLINE: {cid.upper()}", "Node is back online.", cid=cid)
|
||||||
del last_notified_errors[f"{cid}_NODE"]
|
del last_notified_errors[f"{cid}_NODE"]
|
||||||
|
|
||||||
if payload.upper() not in ['OFF', 'OFFLINE', '']:
|
if not state_up.startswith('OFF') and state_up != '':
|
||||||
tel = client_telemetry.get(cid, {})
|
tel = client_telemetry.get(cid, {})
|
||||||
if isinstance(tel, dict) and '🔄' in str(tel.get('ts1', '')):
|
if isinstance(tel, dict) and '🔄' in str(tel.get('ts1', '')):
|
||||||
client_telemetry[cid] = {"ts1": "Waiting...", "ts2": "Waiting...", "alt": ""}
|
client_telemetry[cid] = {"ts1": "Waiting...", "ts2": "Waiting...", "alt": ""}
|
||||||
@@ -388,7 +391,8 @@ def on_message(client, userdata, msg):
|
|||||||
"disk": round(data.get("disk_usage_percent", 0), 1),
|
"disk": round(data.get("disk_usage_percent", 0), 1),
|
||||||
"processes": data.get("processes", {}),
|
"processes": data.get("processes", {}),
|
||||||
"files": data.get("files", data.get("config_files", [])),
|
"files": data.get("files", data.get("config_files", [])),
|
||||||
"profiles": data.get("profiles", {"A": "PROFILE A", "B": "PROFILE B"})
|
"profiles": data.get("profiles", {"A": "PROFILE A", "B": "PROFILE B"}),
|
||||||
|
"interval": data.get("update_interval")
|
||||||
}
|
}
|
||||||
health_changed = device_health.get(cid) != new_health
|
health_changed = device_health.get(cid) != new_health
|
||||||
device_health[cid] = new_health
|
device_health[cid] = new_health
|
||||||
@@ -442,7 +446,7 @@ def on_message(client, userdata, msg):
|
|||||||
logger.error(f"Error parsing DMRGateway for {cid}: {e}")
|
logger.error(f"Error parsing DMRGateway for {cid}: {e}")
|
||||||
|
|
||||||
# --- MMDVMHOST INFO MANAGEMENT (FREQUENZE & LOCATION) ---
|
# --- MMDVMHOST INFO MANAGEMENT (FREQUENZE & LOCATION) ---
|
||||||
elif len(parts) >= 4 and p0 == 'data' and p2 == 'mmdvm' and parts[3].lower() == 'info':
|
elif len(parts) >= 4 and p0 == 'data' and p2 in ('mmdvm', 'mmdvmhost') and parts[3].lower() == 'info':
|
||||||
try:
|
try:
|
||||||
cid = parts[1].lower()
|
cid = parts[1].lower()
|
||||||
data = json.loads(payload)
|
data = json.loads(payload)
|
||||||
@@ -471,7 +475,7 @@ def on_message(client, userdata, msg):
|
|||||||
logger.error(f"Error parsing MMDVMHost info for {cid}: {e}")
|
logger.error(f"Error parsing MMDVMHost info for {cid}: {e}")
|
||||||
|
|
||||||
# --- MMDVMHOST GENERAL MANAGEMENT (CALLSIGN & ID & DUPLEX) ---
|
# --- MMDVMHOST GENERAL MANAGEMENT (CALLSIGN & ID & DUPLEX) ---
|
||||||
elif len(parts) >= 4 and p0 == 'data' and p2 == 'mmdvm' and parts[3].lower() == 'general':
|
elif len(parts) >= 4 and p0 == 'data' and p2 in ('mmdvm', 'mmdvmhost') and parts[3].lower() == 'general':
|
||||||
try:
|
try:
|
||||||
cid = parts[1].lower()
|
cid = parts[1].lower()
|
||||||
data = json.loads(payload)
|
data = json.loads(payload)
|
||||||
|
|||||||
@@ -516,7 +516,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Agent: heartbeat periodico, se tace a lungo con nodo "online" qualcosa non va
|
// Agent: heartbeat periodico, se tace a lungo con nodo "online" qualcosa non va
|
||||||
const warnA = isOnline && (ages.health === undefined ? upSec > 300 : ages.health > 180);
|
// Soglia in base all'intervallo di telemetria dichiarato dall'agente (default 60 s): 3 intervalli, minimo 180 s
|
||||||
|
const hObj = (data.health && data.health[c.id.toLowerCase()]) || {};
|
||||||
|
const iv = Number(hObj.interval) > 0 ? Number(hObj.interval) : 60;
|
||||||
|
const warnA = isOnline && (ages.health === undefined ? upSec > Math.max(300, iv * 5) : ages.health > Math.max(180, iv * 3));
|
||||||
const tipA = warnA
|
const tipA = warnA
|
||||||
? (it ? 'L\'agent del nodo non invia più lo stato (devices/<id>/services): connessione bloccata?' : 'The node agent stopped sending its status (devices/<id>/services): stuck connection?')
|
? (it ? 'L\'agent del nodo non invia più lo stato (devices/<id>/services): connessione bloccata?' : 'The node agent stopped sending its status (devices/<id>/services): stuck connection?')
|
||||||
: (it ? 'Ultimo stato ricevuto dall\'agent del nodo (devices/<id>/services)' : 'Last status received from the node agent (devices/<id>/services)');
|
: (it ? 'Ultimo stato ricevuto dall\'agent del nodo (devices/<id>/services)' : 'Last status received from the node agent (devices/<id>/services)');
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
hook check
|
|
||||||
test ok
|
|
||||||
test bash
|
|
||||||
test hook log
|
|
||||||
debug trace
|
|
||||||
test syslog
|
|
||||||
Reference in New Issue
Block a user