telegraf_to_vu1/dial_configs/CPULoad.py
2024-12-02 18:28:01 +01:00

19 lines
640 B
Python

from dial_configs.dial_config import DialConfig
class CPULoad(DialConfig):
def __init__(self, target_dial, asset_path):
super().__init__(target_dial, asset_path, "cpu-load.png")
def transform_color(self, value):
return super().Colors.get_threshold_color(self, value)
def transform_value(self, json_data):
v = int(json_data.get("fields", {}).get("usage_idle", 0))
value = 100 - v
return value
def __eq__(self, other):
try:
return (other.get("name", "") == "cpu" and other.get("tages", {}).get("host", "") != "gameloader")
except Exception:
return False