From cec03c4468df87bcdc68f20c2cf51a7998c56ebd Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Sun, 10 Sep 2023 14:54:21 +0300 Subject: mute false-positive underpower on cm4-based (v4) devices --- configs/kvmd/main/v4mini-hdmi-rpi4.yaml | 2 ++ configs/kvmd/main/v4plus-hdmi-rpi4.yaml | 2 ++ kvmd/apps/__init__.py | 1 + kvmd/apps/kvmd/info/hw.py | 3 +++ web/share/js/kvm/session.js | 17 +++++++++-------- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/configs/kvmd/main/v4mini-hdmi-rpi4.yaml b/configs/kvmd/main/v4mini-hdmi-rpi4.yaml index 208f6603..40bd60c6 100644 --- a/configs/kvmd/main/v4mini-hdmi-rpi4.yaml +++ b/configs/kvmd/main/v4mini-hdmi-rpi4.yaml @@ -10,6 +10,8 @@ kvmd: auth: !include auth.yaml info: + hw: + ignore_past: true fan: unix: /run/kvmd/fan.sock diff --git a/configs/kvmd/main/v4plus-hdmi-rpi4.yaml b/configs/kvmd/main/v4plus-hdmi-rpi4.yaml index 208f6603..40bd60c6 100644 --- a/configs/kvmd/main/v4plus-hdmi-rpi4.yaml +++ b/configs/kvmd/main/v4plus-hdmi-rpi4.yaml @@ -10,6 +10,8 @@ kvmd: auth: !include auth.yaml info: + hw: + ignore_past: true fan: unix: /run/kvmd/fan.sock diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 4bd8a60d..90399638 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -383,6 +383,7 @@ def _get_config_scheme() -> dict: "extras": Option("/usr/share/kvmd/extras", type=valid_abs_dir), "hw": { "vcgencmd_cmd": Option(["/opt/vc/bin/vcgencmd"], type=valid_command), + "ignore_past": Option(False, type=valid_bool), "state_poll": Option(10.0, type=valid_float_f01), }, "fan": { diff --git a/kvmd/apps/kvmd/info/hw.py b/kvmd/apps/kvmd/info/hw.py index fe0008ab..ed6d8a2c 100644 --- a/kvmd/apps/kvmd/info/hw.py +++ b/kvmd/apps/kvmd/info/hw.py @@ -46,10 +46,12 @@ class HwInfoSubmanager(BaseInfoSubmanager): def __init__( self, vcgencmd_cmd: list[str], + ignore_past: bool, state_poll: float, ) -> None: self.__vcgencmd_cmd = vcgencmd_cmd + self.__ignore_past = ignore_past self.__state_poll = state_poll self.__dt_cache: dict[str, str] = {} @@ -127,6 +129,7 @@ class HwInfoSubmanager(BaseInfoSubmanager): "past": bool(flags & (1 << 18)), }, }, + "ignore_past": self.__ignore_past, } return None diff --git a/web/share/js/kvm/session.js b/web/share/js/kvm/session.js index aed82325..7168aeae 100644 --- a/web/share/js/kvm/session.js +++ b/web/share/js/kvm/session.js @@ -91,8 +91,9 @@ export function Session() { var __setAboutInfoHw = function(state) { if (state.health.throttling !== null) { let flags = state.health.throttling.parsed_flags; - let undervoltage = (flags.undervoltage.now || flags.undervoltage.past); - let freq_capped = (flags.freq_capped.now || flags.freq_capped.past); + let ignore_past = state.health.throttling.ignore_past; + let undervoltage = (flags.undervoltage.now || (flags.undervoltage.past && !ignore_past)); + let freq_capped = (flags.freq_capped.now || (flags.freq_capped.past && !ignore_past)); tools.hidden.setVisible($("hw-health-dropdown"), (undervoltage || freq_capped)); $("hw-health-undervoltage-led").className = (undervoltage ? (flags.undervoltage.now ? "led-red" : "led-yellow") : "hidden"); @@ -188,12 +189,12 @@ export function Session() { let pairs = []; for (let field of Object.keys(throttling.parsed_flags).sort()) { let flags = throttling.parsed_flags[field]; - pairs.push([ - tools.upperFirst(field).replace("_", " "), - (flags["now"] ? __colored("red", "RIGHT NOW") : __colored("green", "No")) - + "; " + - (flags["past"] ? __colored("red", "In the past") : __colored("green", "Never")), - ]); + let key = tools.upperFirst(field).replace("_", " "); + let value = (flags["now"] ? __colored("red", "RIGHT NOW") : __colored("green", "No")); + if (!throttling.ignore_past) { + value += "; " + (flags["past"] ? __colored("red", "In the past") : __colored("green", "Never")); + } + pairs.push([key, value]); } return __formatUl(pairs); } else { -- cgit v1.2.3