diff --git a/README.md b/README.md index a61b806f6e30d1688e1d8ba97b10296c960d741f..dda613d8021faf970372b359bd21f9700ab1c7b3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PACKAGE]: ../../raw/master/mkp/cisco_asyncos-0.4.1-20240418.mkp "cisco_asyncos-0.4.1-20240418.mkp" +[PACKAGE]: ../../raw/master/mkp/cisco_asyncos-0.4.2-20240616.mkp "cisco_asyncos-0.4.2-20240616.mkp" # Cisco AsyncOS (IronPort) **Note: this package is for CheckMK version 2.x. For other versions see the corresponding branch.** diff --git a/mkp/cisco_asyncos-0.4.2-20240616.mkp b/mkp/cisco_asyncos-0.4.2-20240616.mkp new file mode 100644 index 0000000000000000000000000000000000000000..1a56ac69de3d7be2d3d9f2a73d483641398c7715 Binary files /dev/null and b/mkp/cisco_asyncos-0.4.2-20240616.mkp differ diff --git a/source/agent_based/cisco_asyncos_updates.py b/source/agent_based/cisco_asyncos_updates.py index f6c8bf51690a14b5bfa12a882b549a8a8b60ca6a..00297048243239e79f35cc0e4aa884cb15106f4f 100644 --- a/source/agent_based/cisco_asyncos_updates.py +++ b/source/agent_based/cisco_asyncos_updates.py @@ -9,7 +9,8 @@ # # 2020-05-14: added wato option to ignore items # 2021-03-25: rewrite for CMK2.0 -# +# 2024-06-16: replaced get_item_state/set_item_state by get_value_store to work on CMK 2.3 also + # # sample snmpwalk # @@ -154,14 +155,10 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import ( Service, State, contains, + get_value_store, register, ) -from cmk.base.item_state import ( - get_item_state, - set_item_state, -) - class CiscoAsyncosUpdate(NamedTuple): updates: int @@ -229,41 +226,43 @@ def check_cisco_asyncos_updates(params, section: Mapping[str, CiscoAsyncosUpdate features_ignore = params.get('features_ignore', []) warn, crit = params.get('failedLevel') ignore_count = 0 + value_store = get_value_store() + for feature in section.keys(): failed = section[feature].update_failures passed = section[feature].updates # read counters - passed_last = get_item_state('cisco_asyncos_updates_%s_passedLast' % feature) - failed_last = get_item_state('cisco_asyncos_updates_%s_failedLast' % feature) - failed_attempts = get_item_state('cisco_asyncos_updates_%s_failedAttempts' % feature) + passed_last = value_store.get(f'cisco_asyncos_updates_{feature}_passedLast') + failed_last = value_store.get(f'cisco_asyncos_updates_{feature}_failedLast') + failed_attempts = value_store.get(f'cisco_asyncos_updates_{feature}_failedAttempts') if (passed_last is None) or (failed_last is None) or (failed_attempts is None): # or (lastState is None): # init counters - set_item_state('cisco_asyncos_updates_%s_passedLast' % feature, passed) - set_item_state('cisco_asyncos_updates_%s_failedLast' % feature, failed) - set_item_state('cisco_asyncos_updates_%s_failedAttempts' % feature, 0) + value_store[f'cisco_asyncos_updates_{feature}_passedLast'] = passed + value_store[f'cisco_asyncos_updates_{feature}_failedLast'] = failed + value_store[f'cisco_asyncos_updates_{feature}_failedAttempts'] = 0 else: - set_item_state('cisco_asyncos_updates_%s_passedLast' % feature, passed) - set_item_state('cisco_asyncos_updates_%s_failedLast' % feature, failed) + value_store[f'cisco_asyncos_updates_{feature}_passedLast'] = passed + value_store[f'cisco_asyncos_updates_{feature}_failedLast'] = failed passed_last = int(passed_last) failed_last = int(failed_last) failed_attempts = int(failed_attempts) # reset counter if overrun if failed < failed_last: - set_item_state('cisco_asyncos_updates_%s_failedLast' % feature, failed) + value_store[f'cisco_asyncos_updates_{feature}_failedLast'] = failed failed_last = failed if passed < passed_last: - set_item_state('cisco_asyncos_updates_%s_passedLast' % feature, passed) + value_store[f'cisco_asyncos_updates_{feature}_passedLast'] = passed passed_last = passed if passed > passed_last: # reset error counter after passed update attempt - set_item_state('cisco_asyncos_updates_%s_failedAttempts' % feature, 0) + value_store[f'cisco_asyncos_updates_{feature}_failedAttempts'] = 0 else: failed_attempts = failed_attempts + failed - failed_last - set_item_state('cisco_asyncos_updates_%s_failedAttempts' % feature, failed_attempts) + value_store[f'cisco_asyncos_updates_{feature}_failedAttempts'] = failed_attempts base_message = f'{feature}: {passed}/{failed}' if feature in features_ignore: yield Result(state=State.OK, notice=f'{base_message} updates/update failures. Feature ignored!') diff --git a/source/packages/cisco_asyncos b/source/packages/cisco_asyncos index a9ee6c9d91e6ead7a2858698d59de6b5482b2306..75ba9064e58d47d6ef257ddbb3042a117b53b72f 100644 --- a/source/packages/cisco_asyncos +++ b/source/packages/cisco_asyncos @@ -47,7 +47,7 @@ 'wato/cisco_asyncos_dns.py']}, 'name': 'cisco_asyncos', 'title': 'Cisco AsyncOS (IronPort) checks', - 'version': '0.4.1-20240418', + 'version': '0.4.2-20240616', 'version.min_required': '2.1.0b1', 'version.packaged': 'cmk-mkp-tool 0.2.0', - 'version.usable_until': '2.3.0b1'} + 'version.usable_until': '2.4.0b1'}