Repository navigation
Add SSH metrics and watchdog control, moved from the Home Assistant integration - #66
Merged
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Moves the SSH metric commands and their parsing from the Home Assistant integration into
NanoKVMSSH, returning a typed model, and adds control of the non-Pro firmware's watchdog with a firmware check, so callers no longer gate it by version.Changes
get_metrics()returns anSSHMetricsdataclass:boot_time(UTC),cpu_temperature(°C),memory_totalandstorage_total(MiB, root filesystem),memory_used_percent,storage_used_percentandwatchdog_enabled. The commands are the integration's (/proc/stat,thermal_zone0/temp,/proc/meminfo,df -k /).Noneinstead of failing the whole snapshot. Before, unexpected temperature output raised from a barefloat(); a missing thermal zone now yieldsNonetoo.get_watchdog_enabled()/set_watchdog_enabled().kvm_systemreboots the device when the video service misses its heartbeat (/tmp/nanokvm_wd) for more than 10 seconds, but only while/etc/kvm/watchdogexists. Support is detected by looking for that path in thekvm_systembinary, which the Pro doesn't have. Without it, the getter returnsNoneand the setter raisesNanoKVMNotSupportedError.docs/ssh.mdgains a metrics and watchdog section.Notes
kvm_systembinary on every watchdog call (about 0.3 s on the PCIe). It could be cached per connection if polling gets tight.NanoKVMSSHdoesn't keep the password.Behaviour changes
None. All methods are additions.
Testing
507 unit tests pass, 3 of them new. Against devices, every command run one by one, then through the new methods:
False; enabled, the heartbeat appeared within 1.3 s and it readTrue; disabled again after 3.9 s. Boot time unchanged afterwards, so no reboot.None, andset_watchdog_enabled(False)raisedNanoKVMNotSupportedErrorwithout touching the file.