fix(monitoring): prevent Vault crash and DNS null error
- Vault: Wrap resp.json() in a try-except block to prevent JSONDecodeError when hitting an HTML error page (e.g. 502/503). This prevents the entire agent from crashing and missing heartbeats. - Uptime Kuma DNS: Explicitly set dns_resolve_server to 1.1.1.1 in Python API payload to prevent Uptime Kuma backend from crashing on null properties.
This commit is contained in:
parent
475eb762b9
commit
8a056a381b
@ -261,6 +261,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
"hostname": hostname,
|
"hostname": hostname,
|
||||||
"port": 53,
|
"port": 53,
|
||||||
"accepted_statuscodes": ["200-299"],
|
"accepted_statuscodes": ["200-299"],
|
||||||
|
"dns_resolve_server": "1.1.1.1",
|
||||||
"dns_resolve_type": dns_resolve_type,
|
"dns_resolve_type": dns_resolve_type,
|
||||||
"interval": interval,
|
"interval": interval,
|
||||||
}
|
}
|
||||||
@ -280,6 +281,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
"hostname": hostname,
|
"hostname": hostname,
|
||||||
"port": 53,
|
"port": 53,
|
||||||
"accepted_statuscodes": ["200-299"],
|
"accepted_statuscodes": ["200-299"],
|
||||||
|
"dns_resolve_server": "1.1.1.1",
|
||||||
"dns_resolve_type": dns_resolve_type,
|
"dns_resolve_type": dns_resolve_type,
|
||||||
"interval": interval,
|
"interval": interval,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,11 +140,14 @@ def check_vault():
|
|||||||
max_ping = max(max_ping, ms)
|
max_ping = max(max_ping, ms)
|
||||||
|
|
||||||
if resp is not None:
|
if resp is not None:
|
||||||
data = resp.json()
|
try:
|
||||||
if not data.get("sealed"):
|
data = resp.json()
|
||||||
unsealed_count += 1
|
if not data.get("sealed"):
|
||||||
else:
|
unsealed_count += 1
|
||||||
errors.append(f"{node} SEALED")
|
else:
|
||||||
|
errors.append(f"{node} SEALED")
|
||||||
|
except Exception as e:
|
||||||
|
errors.append(f"{node} invalid response: {resp.status_code}")
|
||||||
else:
|
else:
|
||||||
errors.append(f"{node} unreachable: {err}")
|
errors.append(f"{node} unreachable: {err}")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user