Skip to content

Add state coercion helper function for drive checks#28

Open
uh-dk wants to merge 1 commit intoiteratio-com:mainfrom
uh-dk:main
Open

Add state coercion helper function for drive checks#28
uh-dk wants to merge 1 commit intoiteratio-com:mainfrom
uh-dk:main

Conversation

@uh-dk
Copy link

@uh-dk uh-dk commented Jan 21, 2026

The current version crashes if the tape library reports "Cleaning needed"

Operating System: Ubuntu 22.04.5 LTS
Checkmk Version: 2.3.0p41
Edition: cme

Crash Report

Exception

TypeError ('state' must be a checkmk State constant, got 1)

Traceback

File "/omd/sites/intern/lib/python3/cmk/base/checkers.py", line 734, in get_aggregated_result check_result = check_function(**item_kw, **params_kw, **section_kws) File "/omd/sites/intern/lib/python3/cmk/base/checkers.py", line 514, in __check_function return _aggregate_results(consume_check_results(check_function(*args, **kw))) File "/omd/sites/intern/lib/python3/cmk/base/checkers.py", line 572, in consume_check_results for subr in subresults: File "/omd/sites/intern/lib/python3/cmk/base/api/agent_based/register/check_plugins.py", line 95, in filtered_generator for element in generator(*args, **kwargs): File "/omd/sites/intern/local/lib/python3/cmk_addons/plugins/dell_emc_ml3/agent_based/dell_emc_ml3_drive.py", line 91, in check_dell_emc_ml3_drive if params.get("ava_map"): File "/omd/sites/intern/lib/python3.12/site-packages/cmk/agent_based/v1/_checking_classes.py", line 404, in __new__ state, summary, details = _create_result_fields(**kwargs) # type: ignore[misc] File "/omd/sites/intern/lib/python3.12/site-packages/cmk/agent_based/v1/_checking_classes.py", line 430, in _create_result_fields raise TypeError(f"'state' must be a checkmk State constant, got {state}")

Local Variables

{'details': None, 'notice': None, 'state': 1, 'summary': 'Cleaning Status: cleaning needed'}


  • Add _to_state helper to safely coerce values (State / int / str) into a State with a fallback.
  • Accept custom ava_map / opa_map entries that are strings, ints or State instances (no longer crash on unexpected types or None).
  • Allow cleaning_needed rule to be supplied as State/int/str and normalize it (default remains WARN). Small robustness improvements to avoid exceptions when rule values are missing or invalid.

Add _to_state helper to safely coerce values (State / int / str) into a State with a fallback.
Accept custom ava_map / opa_map entries that are strings, ints or State instances (no longer crash on unexpected types or None).
Allow cleaning_needed rule to be supplied as State/int/str and normalize it (default remains WARN).
Small robustness improvements to avoid exceptions when rule values are missing or invalid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant