You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `check_levels` function is the recommended way to handle threshold checking in CheckMK 2.3+. It automatically handles SimpleLevels from rulesets, generates proper Result and Metric objects, and supports custom formatting.
According to the CheckMK 2.3 documentation, `check_levels` supports these parameters:
800
+
801
+
```python
802
+
check_levels(
803
+
value, # float: The currently measured value
804
+
*,
805
+
levels_upper=None, # Upper level parameters from SimpleLevels
806
+
levels_lower=None, # Lower level parameters from SimpleLevels
807
+
metric_name=None, # str: Name for performance data metric
808
+
render_func=None, # Callable: Function to format values
809
+
label=None, # str: Label to prepend to output
810
+
boundaries=None, # tuple: (min, max) for metric boundaries
811
+
notice_only=False# bool: Only show in details if not OK
812
+
)
813
+
```
814
+
815
+
##### SimpleLevels Format Handling
816
+
817
+
CheckMK 2.3 rulesets generate SimpleLevels in dictionary format. The `check_levels` function expects levels in `("fixed", (warn, crit))` format. This applies to both `levels_upper` and `levels_lower`:
levels_upper=("fixed", params['storage_levels'].get('levels_upper')) if params.get('storage_levels') elseNone,
1015
+
metric_name="storage_percent",
1016
+
render_func=render.percent,
1017
+
label="Storage usage",
1018
+
boundaries=(0.0, 100.0)
1019
+
)
1020
+
1021
+
# Network throughput
1022
+
if'network_levels'in params:
1023
+
yield from check_levels(
1024
+
section.get("network_bytes", 0),
1025
+
levels_upper=("fixed", params['network_levels'].get('levels_upper')) if params.get('network_levels') elseNone,
1026
+
metric_name="network_throughput",
1027
+
render_func=render.bytes,
1028
+
label="Network throughput"
1029
+
)
1030
+
1031
+
# Response time
1032
+
if'latency_levels'in params:
1033
+
yield from check_levels(
1034
+
section.get("latency_ms", 0),
1035
+
levels_upper=("fixed", params['latency_levels'].get('levels_upper')) if params.get('latency_levels') elseNone,
1036
+
metric_name="latency",
1037
+
render_func=_render_milliseconds,
1038
+
label="Response latency"
1039
+
)
1040
+
```
1041
+
793
1042
## Agent Bakery Integration
794
1043
795
1044
The Agent Bakery allows centralized configuration and deployment of agent plugins across multiple hosts using the `cmk.base.pyugins.bakery.bakery_api.v1` API.
0 commit comments