Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit c7fb33f6 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent c5ecae2a
No related branches found
No related tags found
No related merge requests found
[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
......
File added
......@@ -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'
)
......@@ -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'}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment