-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Add system health section for the Supervisor #43074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d7f3ca0
Add system_health for supervisor
ludeeus 968b292
Address review comments
ludeeus 3569443
Apply suggestion about more info
ludeeus 7165403
Use manifest and not strings for name
ludeeus 3c2adfe
Merge branch 'dev' into supervisor-health
ludeeus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "system_health": { | ||
| "info": { | ||
| "board": "Board", | ||
| "disk_total": "Disk Total", | ||
| "disk_used": "Disk Used", | ||
| "docker_version": "Docker Version", | ||
| "healthy": "Healthy", | ||
| "host_os": "Host Operating System", | ||
| "installed_addons": "Installed Add-ons", | ||
| "supervisor_api": "Supervisor API", | ||
| "supervisor_version": "Supervisor Version", | ||
| "supported": "Supported", | ||
| "update_channel": "Update Channel", | ||
| "version_api": "Version API" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """Provide info to system health.""" | ||
| import os | ||
|
|
||
| from homeassistant.components import system_health | ||
| from homeassistant.core import HomeAssistant, callback | ||
|
|
||
| SUPERVISOR_PING = f"http://{os.environ['HASSIO']}/supervisor/ping" | ||
| OBSERVER_URL = f"http://{os.environ['HASSIO']}:4357" | ||
|
|
||
|
|
||
| @callback | ||
| def async_register( | ||
| hass: HomeAssistant, register: system_health.SystemHealthRegistration | ||
| ) -> None: | ||
| """Register system health callbacks.""" | ||
| register.async_register_info(system_health_info, "/hassio") | ||
|
|
||
|
|
||
| async def system_health_info(hass: HomeAssistant): | ||
| """Get info for the info page.""" | ||
| info = hass.components.hassio.get_info() | ||
| host_info = hass.components.hassio.get_host_info() | ||
| supervisor_info = hass.components.hassio.get_supervisor_info() | ||
|
|
||
| if supervisor_info.get("healthy"): | ||
| healthy = True | ||
| else: | ||
| healthy = { | ||
| "type": "failed", | ||
| "error": "Unhealthy", | ||
| "more_info": "/hassio/system", | ||
| } | ||
|
|
||
| if supervisor_info.get("supported"): | ||
| supported = True | ||
| else: | ||
| supported = { | ||
| "type": "failed", | ||
| "error": "Unsupported", | ||
| "more_info": "/hassio/system", | ||
| } | ||
|
|
||
| information = { | ||
| "host_os": host_info.get("operating_system"), | ||
| "update_channel": info.get("channel"), | ||
| "supervisor_version": info.get("supervisor"), | ||
| "docker_version": info.get("docker"), | ||
| "disk_total": f"{host_info.get('disk_total')} GB", | ||
| "disk_used": f"{host_info.get('disk_used')} GB", | ||
| "healthy": healthy, | ||
| "supported": supported, | ||
| } | ||
|
|
||
| if info.get("hassos") is not None: | ||
| os_info = hass.components.hassio.get_os_info() | ||
| information["board"] = os_info.get("board") | ||
|
|
||
| information["supervisor_api"] = system_health.async_check_can_reach_url( | ||
| hass, SUPERVISOR_PING, OBSERVER_URL | ||
| ) | ||
| information["version_api"] = system_health.async_check_can_reach_url( | ||
| hass, | ||
| f"https://version.home-assistant.io/{info.get('channel')}.json", | ||
| "/hassio/system", | ||
| ) | ||
|
|
||
| information["installed_addons"] = ", ".join( | ||
| f"{addon['name']} ({addon['version']})" | ||
| for addon in supervisor_info.get("addons", []) | ||
| ) | ||
|
|
||
| return information | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,18 @@ | ||
| { | ||
| "title": "Hass.io" | ||
| } | ||
| "system_health": { | ||
| "info": { | ||
| "board": "Board", | ||
| "disk_total": "Disk Total", | ||
| "disk_used": "Disk Used", | ||
| "docker_version": "Docker Version", | ||
| "healthy": "Healthy", | ||
| "host_os": "Host Operating System", | ||
| "installed_addons": "Installed Add-ons", | ||
| "supervisor_api": "Supervisor API", | ||
| "supervisor_version": "Supervisor Version", | ||
| "supported": "Supported", | ||
| "update_channel": "Update Channel", | ||
| "version_api": "Version API" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,16 @@ | ||
| { | ||
| "system_health": { | ||
| "info": { | ||
| "installation_type": "Installation Type", | ||
| "version": "Version", | ||
| "arch": "CPU Architecture", | ||
| "dev": "Development", | ||
| "virtualenv": "Virtual Environment", | ||
| "python_version": "Python Version", | ||
| "docker": "Docker", | ||
| "arch": "CPU Architecture", | ||
| "timezone": "Timezone", | ||
| "os_name": "Operating System Name", | ||
| "installation_type": "Installation Type", | ||
|
ludeeus marked this conversation as resolved.
|
||
| "os_name": "Operating System Family", | ||
| "os_version": "Operating System Version", | ||
| "supervisor": "Supervisor", | ||
| "host_os": "Home Assistant OS", | ||
| "chassis": "Chassis", | ||
| "docker_version": "Docker" | ||
| "python_version": "Python Version", | ||
| "timezone": "Timezone", | ||
| "version": "Version", | ||
| "virtualenv": "Virtual Environment" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 15 additions & 18 deletions
33
homeassistant/components/homeassistant/translations/en.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,17 @@ | ||
| { | ||
| "system_health": { | ||
| "info": { | ||
| "arch": "CPU Architecture", | ||
| "chassis": "Chassis", | ||
| "dev": "Development", | ||
| "docker": "Docker", | ||
| "docker_version": "Docker", | ||
| "host_os": "Home Assistant OS", | ||
| "installation_type": "Installation Type", | ||
| "os_name": "Operating System Name", | ||
| "os_version": "Operating System Version", | ||
| "python_version": "Python Version", | ||
| "supervisor": "Supervisor", | ||
| "timezone": "Timezone", | ||
| "version": "Version", | ||
| "virtualenv": "Virtual Environment" | ||
| } | ||
| "system_health": { | ||
| "info": { | ||
| "arch": "CPU Architecture", | ||
| "dev": "Development", | ||
| "docker": "Docker", | ||
| "installation_type": "Installation Type", | ||
| "os_name": "Operating System Family", | ||
| "os_version": "Operating System Version", | ||
| "python_version": "Python Version", | ||
| "timezone": "Timezone", | ||
| "version": "Version", | ||
| "virtualenv": "Virtual Environment" | ||
| } | ||
| } | ||
| }, | ||
| "title": "Home Assistant" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.