Add nameservers to supervisor system health response (#149749)

This commit is contained in:
Joakim Sørensen 2025-08-01 09:51:48 +01:00 committed by GitHub
parent 0d7608f7c5
commit 924a86dfb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 0 deletions

View File

@ -9,6 +9,7 @@
"healthy": "Healthy",
"host_os": "Host operating system",
"installed_addons": "Installed add-ons",
"nameservers": "Nameservers",
"supervisor_api": "Supervisor API",
"supervisor_version": "Supervisor version",
"supported": "Supported",

View File

@ -54,6 +54,15 @@ async def system_health_info(hass: HomeAssistant) -> dict[str, Any]:
"error": "Unsupported",
}
nameservers = set()
for interface in network_info.get("interfaces", []):
if not interface.get("primary"):
continue
if ipv4 := interface.get("ipv4"):
nameservers.update(ipv4.get("nameservers", []))
if ipv6 := interface.get("ipv6"):
nameservers.update(ipv6.get("nameservers", []))
information = {
"host_os": host_info.get("operating_system"),
"update_channel": info.get("channel"),
@ -62,6 +71,7 @@ async def system_health_info(hass: HomeAssistant) -> dict[str, Any]:
"docker_version": info.get("docker"),
"disk_total": f"{host_info.get('disk_total')} GB",
"disk_used": f"{host_info.get('disk_used')} GB",
"nameservers": ", ".join(nameservers),
"healthy": healthy,
"supported": supported,
"host_connectivity": network_info.get("host_internet"),

View File

@ -55,6 +55,10 @@ async def test_hassio_system_health(
hass.data["hassio_network_info"] = {
"host_internet": True,
"supervisor_internet": True,
"interfaces": [
{"primary": False, "ipv4": {"nameservers": ["9.9.9.9"]}},
{"primary": True, "ipv4": {"nameservers": ["1.1.1.1"]}},
],
}
with patch.dict(os.environ, MOCK_ENVIRON):
@ -76,6 +80,7 @@ async def test_hassio_system_health(
"host_os": "Home Assistant OS 5.9",
"installed_addons": "Awesome Addon (1.0.0)",
"ntp_synchronized": True,
"nameservers": "1.1.1.1",
"supervisor_api": "ok",
"supervisor_version": "supervisor-2020.11.1",
"supported": True,