diff --git a/README.md b/README.md index 421dd262a0944135fede3f6c68ab16282d2d0ec9..76ad5ac7e7a6257cdc3455567abb1a4e29279aa1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PACKAGE]: ../../raw/master/mkp/curl-0.3.1-20241123.mkp "curl-0.3.1-20241123.mkp" +[PACKAGE]: ../../raw/master/mkp/curl-0.3.2-20241124.mkp "curl-0.3.2-20241124.mkp" [EXECUTABLE]: ../../raw/master/mkp/curl_executable-20220410.v7.82.0.mkp "curl_executable-20220410.v7.82.0.mkp" # cURL agent plugin for Linux and Windows diff --git a/mkp/curl-0.3.2-20241124.mkp b/mkp/curl-0.3.2-20241124.mkp new file mode 100644 index 0000000000000000000000000000000000000000..e41e1de24e3549a4a96342f6fc52a68e2aae0f0e Binary files /dev/null and b/mkp/curl-0.3.2-20241124.mkp differ diff --git a/source/agent_based/curl.py b/source/agent_based/curl.py index 2e7d2a1d782719c6b7324a91ad6701817abb8f3e..3f2fbf5c040b69f5daa11786517d89cc40aa3048 100644 --- a/source/agent_based/curl.py +++ b/source/agent_based/curl.py @@ -32,6 +32,7 @@ # 2024-06-23: modified imports for cmk 2.3 # removed work around for render negative timespan # 2024-11-23: fixed http_error_code_to_ignore and curl_error_code_to_ignore not working (compare int with str) +# 2024-11-24: removed empty default parameters # Example output from agent: # @@ -316,7 +317,7 @@ def check_curl(item, params, section: Dict[str, Any]) -> CheckResult: yield Result(state=State.OK, notice=f'{label}: {value}') if curl_error_code != 0: - if str(curl_error_code) in params['curl_error_code_to_ignore']: + if str(curl_error_code) in params.get('curl_error_code_to_ignore', []): yield Result( state=State.OK, notice=f'curl error code: {curl_error_code}, {_curl_error_codes.get(curl_error_code, "N/A")}') @@ -330,7 +331,7 @@ def check_curl(item, params, section: Dict[str, Any]) -> CheckResult: if http_return_code < 400: # no connect, Ok, Redirect yield Result(state=State.OK, notice=f'HTTP Return code: {http_return_code}') else: - if str(http_return_code) in params['http_error_code_to_ignore']: + if str(http_return_code) in params.get('http_error_code_to_ignore', []): yield Result( state=State.OK, notice=f'HTTP Return code: {http_return_code}' ) @@ -389,7 +390,7 @@ def check_curl(item, params, section: Dict[str, Any]) -> CheckResult: elif not _data.get('regex'): # missing info yield Result(state=State(regex_missing), notice='Regex state: missing pattern match info') - max_age_warn, max_age_crit, max_age_state = params['max_age'] + max_age_warn, max_age_crit, max_age_state = params.get('max_age', None, None, None) if max_age_warn: max_age = None if _data.get('RESPONSE_HEADER'): @@ -428,14 +429,14 @@ def check_curl(item, params, section: Dict[str, Any]) -> CheckResult: yield Result(state=State.OK, notice=f'{label}: {_data["tls_info"][key]}') if _data['tls_info'].get('time_left'): - if params['cert_time_left'].get('upper'): - warn, crit = params['cert_time_left'].get('upper') + if params.get('cert_time_left', {}).get('upper'): + warn, crit = params.get('cert_time_left', {}).get('upper') upper = (warn * 86400, crit * 86400) else: upper = None - if params['cert_time_left'].get('lower'): - warn, crit = params['cert_time_left'].get('lower') + if params.get('cert_time_left', {}).get('lower'): + warn, crit = params.get('cert_time_left', {}).get('lower') lower = (warn * 86400, crit * 86400) else: lower = None @@ -476,8 +477,8 @@ def check_curl(item, params, section: Dict[str, Any]) -> CheckResult: metric_name=key, notice_only=notice_only, render_func=render_func, - levels_lower=params[key].get('lower'), - levels_upper=params[key].get('upper'), + levels_lower=params.get(key, {}).get('lower'), + levels_upper=params.get(key, {}).get('upper'), ) for key, label, notice_only, render_func in [ @@ -503,11 +504,13 @@ def check_curl(item, params, section: Dict[str, Any]) -> CheckResult: metric_name=key, notice_only=notice_only, render_func=render_func, - levels_lower=params[key].get('lower'), - levels_upper=params[key].get('upper'), + levels_lower=params.get(key, {}).get('lower'), + levels_upper=params.get(key, {}).get('upper'), ) - show_request_header, show_response_headers, show_session_info, show_raw_data = params['show_additional_info'] + show_request_header, show_response_headers, show_session_info, show_raw_data = params.get( + 'show_additional_info', (None, None, None, None) + ) if show_request_header and _data.get('REQUEST_HEADER'): yield Result(state=State.OK, notice=f' ') yield Result(state=State.OK, notice=f'Request headers:') @@ -546,34 +549,35 @@ register.check_plugin( discovery_function=discovery_curl, check_function=check_curl, check_default_parameters={ - 'show_additional_info': (None, None, None, None), - 'max_age': (None, None, None), - 'state_item_not_found': 3, - 'state_http_result_not_200': 1, - 'http_error_code_to_ignore': [], 'state_curl_result_not_0': 1, - 'curl_error_code_to_ignore': [], - 'state_verify_sll_not_0': 1, 'state_expected_str_not_found': 1, - 'state_header_str_not_found': 1, 'state_for_regex': (0, 1, 0), - 'time_namelookup': {}, - 'time_connect': {}, - 'time_appconnect': {}, - 'time_pretransfer': {}, - 'time_redirect': {}, - 'time_starttransfer': {}, - 'time_total': {}, - 'num_connects': {}, - 'num_redirects': {}, - 'num_headers': {}, - 'size_download': {}, - 'size_upload': {}, - 'size_header': {}, - 'size_request': {}, - 'speed_download': {}, - 'speed_upload': {}, - 'cert_time_left': {}, + 'state_header_str_not_found': 1, + 'state_http_result_not_200': 1, + 'state_item_not_found': 3, + 'state_verify_sll_not_0': 1, + + # 'cert_time_left': {}, + # 'curl_error_code_to_ignore': [], + # 'http_error_code_to_ignore': [], + # 'max_age': (None, None, None), + # 'num_connects': {}, + # 'num_headers': {}, + # 'num_redirects': {}, + # 'show_additional_info': (None, None, None, None), + # 'size_download': {}, + # 'size_header': {}, + # 'size_request': {}, + # 'size_upload': {}, + # 'speed_download': {}, + # 'speed_upload': {}, + # 'time_appconnect': {}, + # 'time_connect': {}, + # 'time_namelookup': {}, + # 'time_pretransfer': {}, + # 'time_redirect': {}, + # 'time_starttransfer': {}, + # 'time_total': {}, }, check_ruleset_name='curl' ) diff --git a/source/packages/curl b/source/packages/curl index 1ee0038e1edb68090097803b951d8a295a23ad20..4bfe7f414eaa3654789d1baba608fbc9d646ac0c 100644 --- a/source/packages/curl +++ b/source/packages/curl @@ -28,7 +28,7 @@ 'lib': ['python3/cmk/base/cee/plugins/bakery/curl.py']}, 'name': 'curl', 'title': 'cURL agent plugin', - 'version': '0.3.1-20241123', + 'version': '0.3.2-20241124', 'version.min_required': '2.3.0b1', 'version.packaged': 'cmk-mkp-tool 0.2.0', 'version.usable_until': '2.4.0b1'}