proc_stats: update service state in the proc_stat timer
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
8126a73663
commit
97522947ec
|
@ -27,6 +27,7 @@ if TYPE_CHECKING:
|
||||||
from confighelper import ConfigHelper
|
from confighelper import ConfigHelper
|
||||||
from websockets import WebRequest
|
from websockets import WebRequest
|
||||||
from . import shell_command
|
from . import shell_command
|
||||||
|
from .machine import Machine
|
||||||
|
|
||||||
VC_GEN_CMD_FILE = "/usr/bin/vcgencmd"
|
VC_GEN_CMD_FILE = "/usr/bin/vcgencmd"
|
||||||
STATM_FILE_PATH = "/proc/self/smaps_rollup"
|
STATM_FILE_PATH = "/proc/self/smaps_rollup"
|
||||||
|
@ -53,6 +54,7 @@ class ProcStats:
|
||||||
def __init__(self, config: ConfigHelper) -> None:
|
def __init__(self, config: ConfigHelper) -> None:
|
||||||
self.server = config.get_server()
|
self.server = config.get_server()
|
||||||
self.event_loop = self.server.get_event_loop()
|
self.event_loop = self.server.get_event_loop()
|
||||||
|
self.machine: Machine = self.server.load_component(config, 'machine')
|
||||||
self.watchdog = Watchdog(self)
|
self.watchdog = Watchdog(self)
|
||||||
self.stat_update_cb = PeriodicCallback(
|
self.stat_update_cb = PeriodicCallback(
|
||||||
self._handle_stat_update, STAT_UPDATE_TIME_MS) # type: ignore
|
self._handle_stat_update, STAT_UPDATE_TIME_MS) # type: ignore
|
||||||
|
@ -161,6 +163,7 @@ class ProcStats:
|
||||||
self.server.send_event("proc_stats:cpu_throttled", ts)
|
self.server.send_event("proc_stats:cpu_throttled", ts)
|
||||||
self.last_throttled = cur_throttled
|
self.last_throttled = cur_throttled
|
||||||
self.total_throttled |= cur_throttled
|
self.total_throttled |= cur_throttled
|
||||||
|
await self.machine.update_service_status()
|
||||||
|
|
||||||
async def _check_throttled_state(self) -> Dict[str, Any]:
|
async def _check_throttled_state(self) -> Dict[str, Any]:
|
||||||
async with self.throttle_check_lock:
|
async with self.throttle_check_lock:
|
||||||
|
|
Loading…
Reference in New Issue