code: def __init__(
      self,
      settings: "SettingsStatic",
      interface: "Interface",
  ) -> None:
      self._shutdown_event: threading.Event = threading.Event()
      self._process: Optional[threading.Thread] = None
  
      self.settings = settings
  
      # settings._stats_join_assets controls whether we should join stats from different assets
      # before publishing them to the backend. If set to False, we will publish stats from each
      # asset separately, using the backend interface. If set to True, we will aggregate stats from
      # all assets before publishing them, using an internal queue interface, and then publish
      # them using the interface to the backend.
      # This is done to improve compatibility with older versions of the backend as it used to
      # collect the names of the metrics to be displayed in the UI from the first stats message.
  
      # compute the global publishing interval if _stats_join_assets is requested
      sampling_interval: float = float(
          max(
              0.1,
              self.settings._stats_sample_rate_seconds,
          )
      )  # seconds
      # The number of samples to aggregate (e.g. average or compute max/min etc.)
      # before publishing; defaults to 15; valid range: [1:30]
      samples_to_aggregate: int = min(
          30, max(1, self.settings._stats_samples_to_average)
      )
      self.publishing_interval: float = (
          sampling_interval * samples_to_aggregate
      )
      self.join_assets: bool = self.settings._stats_join_assets
  
      self.backend_interface = interface
      self.asset_interface: Optional[AssetInterface] = (
          AssetInterface() if self.join_assets else None
      )
  
      # hardware assets
      self.assets: List[Asset] = self._get_assets()
  
      # OpenMetrics/Prometheus-compatible endpoints
      self.assets.extend(self._get_open_metrics_assets())
  
      # static system info, both hardware and software
      self.system_info: SystemInfo = SystemInfo(
          settings=self.settings, interface=interface
      )
  
      self.buffer: Dict[str, Deque[Tuple[float, float]]] = defaultdict(
          lambda: deque([], maxlen=self.settings._stats_buffer_size)
      )
  
imports: import datetime
  import logging
  import queue
  import threading
  from collections import defaultdict, deque
  from typing import TYPE_CHECKING, Deque, Dict, List, Optional, Tuple
  from .assets.asset_registry import asset_registry
  from .assets.interfaces import Asset, Interface
  from .assets.open_metrics import OpenMetrics
  from .system_info import SystemInfo
label_desc: Use image node_id 1 to create a new SystemMonitor object  with example: obj = SystemMonitor(settings, interface)