diff --git a/README.md b/README.md index e39630ffe5fe9eceb1519f95610686ec84136516..187781c8963ddf7c6ed417a6be6944833cbd38db 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PACKAGE]: ../../raw/master/mkp/curl-0.2.1-20231021.mkp "curl-0.2.1-20231021.mkp" +[PACKAGE]: ../../raw/master/mkp/curl-0.2.0-20240623.mkp "curl-0.2.0-20240623.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.2.0-20240623.mkp b/mkp/curl-0.2.0-20240623.mkp new file mode 100644 index 0000000000000000000000000000000000000000..6cf92275bc1e6392d049c679e4302046d87773a5 Binary files /dev/null and b/mkp/curl-0.2.0-20240623.mkp differ diff --git a/source/agent_based/curl.py b/source/agent_based/curl.py index 87881577030e718ffd3303ff825bb69bb8f6e199..3bfa3e1745192756136a7bb2e78f2f52629bd36c 100644 --- a/source/agent_based/curl.py +++ b/source/agent_based/curl.py @@ -29,7 +29,8 @@ # 2022-05-15: added workaround for raise ValueError("Cannot render negative timespan") # 2022-05-17: fixed wrong import path for _TIME_UNITS and _gen_timespan_chunks # 2023-06-07: moved gui files to ~/local/lib/chek_mk/gui/plugins/... -# +# 2024-06-23: modified imports for cmk 2.3 +# removed work around for render negative timespan # Example output from agent: # @@ -65,49 +66,49 @@ import json import time -from typing import Dict, Any, List, Iterable +from typing import Any, Dict, List from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( - DiscoveryResult, CheckResult, + DiscoveryResult, ) from cmk.base.plugins.agent_based.agent_based_api.v1 import ( - register, + Result, Service, State, check_levels, - Result, + register, render, ) # # start workaround for : raise ValueError("Cannot render negative timespan") # -from cmk.base.api.agent_based.render import ( - _TIME_UNITS, - _gen_timespan_chunks, -) - - -def timespan(seconds: float) -> str: - """Render a time span in seconds - - Example: - >>> timespan(1606721) - '18 days 14 hours' - >>> timespan(0.0001) - '100 microseconds' - - """ - if seconds >= 0: - ts = " ".join(_gen_timespan_chunks(float(seconds), nchunks=2)) - else: - seconds = -1 * seconds - ts = " ".join(_gen_timespan_chunks(float(seconds), nchunks=2)) - ts = f"-{ts}" - if ts == "0 %s" % _TIME_UNITS[-1][0]: - ts = "0 seconds" - return ts +# from cmk.base.api.agent_based.render import ( +# _TIME_UNITS, +# _gen_timespan_chunks, +# ) +# +# +# def timespan(seconds: float) -> str: +# """Render a time span in seconds +# +# Example: +# >>> timespan(1606721) +# '18 days 14 hours' +# >>> timespan(0.0001) +# '100 microseconds' +# +# """ +# if seconds >= 0: +# ts = " ".join(_gen_timespan_chunks(float(seconds), nchunks=2)) +# else: +# seconds = -1 * seconds +# ts = " ".join(_gen_timespan_chunks(float(seconds), nchunks=2)) +# ts = f"-{ts}" +# if ts == "0 %s" % _TIME_UNITS[-1][0]: +# ts = "0 seconds" +# return ts # # end workaround for : raise ValueError("Cannot render negative timespan") @@ -442,7 +443,7 @@ def check_curl(item, params, section: Dict[str, Any]) -> CheckResult: label='Certificate time left', value=_data['tls_info']['time_left'], metric_name='cert_time_left', - render_func=timespan, + render_func=render.timespan, notice_only=True, levels_upper=upper, levels_lower=lower, diff --git a/source/gui/metrics/curl.py b/source/gui/metrics/curl.py index bf186c5e436ba65459cd49fea5339465e8edd928..0304e3dc917d0544049154d49be0199301c92bc7 100644 --- a/source/gui/metrics/curl.py +++ b/source/gui/metrics/curl.py @@ -13,15 +13,12 @@ # 2022-02-20: added num_connects, num_redirects, size_download, size_header and speed_download # 2022-03-13: moved cert time left graph to the end of graphs # 2022-05-17: added scalars to cert_time_left +# 2024-06-23: modified imports for CMK 2.3 +from cmk.gui.graphing import perfometer_info +from cmk.gui.graphing._utils import graph_info, metric_info from cmk.gui.i18n import _ -from cmk.gui.plugins.metrics.utils import ( - metric_info, - graph_info, - perfometer_info, -) - metric_info['time_namelookup'] = { 'title': _('Time name lookup'), 'unit': 's', diff --git a/source/gui/wato/check_parameters/curl_bakery.py b/source/gui/wato/check_parameters/curl_bakery.py index 3c7c37d1df11b37541bff9538a50a13371adefd5..2c58a0a9e03d1f329f541cbe3e56d19b4a047c8c 100644 --- a/source/gui/wato/check_parameters/curl_bakery.py +++ b/source/gui/wato/check_parameters/curl_bakery.py @@ -70,39 +70,37 @@ # 2022-04-26: added check option clickable_url # clarified option 'Don\'t verify certificate/pub key', 'Don\'t stop at verify errors (certificate/pub key)' # 2023-10-21: changed for CMK 2.2.0 +# 2024-06-23: modified imports for CMK 2.3 +# changed PasswordFromStore -> MigrateToIndividualOrStoredPassword import ipaddress -from cmk.gui.i18n import _ + +from cmk.gui.cee.plugins.wato.agent_bakery.rulespecs.utils import ( + RulespecGroupMonitoringAgentsAgentPlugins, +) from cmk.gui.exceptions import MKUserError +from cmk.gui.i18n import _ +from cmk.gui.plugins.wato.utils import HostRulespec, rulespec_registry from cmk.gui.valuespec import ( - Dictionary, - ListOf, + Alternative, + CAorCAChain, CascadingDropdown, - TextUnicode, + Checkbox, + Dictionary, + DropdownChoice, FixedValue, + Foldable, Integer, - Tuple, - DropdownChoice, + ListOf, ListOfStrings, - TextInput, - Checkbox, - CAorCAChain, Optional, - Foldable, + TextInput, + TextUnicode, + Tuple, UploadOrPasteTextFile, - Alternative, -) -from cmk.gui.plugins.wato.utils import ( - rulespec_registry, - HostRulespec, -) -from cmk.gui.plugins.wato.utils import ( - PasswordFromStore, ) +from cmk.gui.wato import MigrateToIndividualOrStoredPassword -from cmk.gui.cee.plugins.wato.agent_bakery.rulespecs.utils import ( - RulespecGroupMonitoringAgentsAgentPlugins, -) # unsafe characters https://www.tutorialspoint.com/html/html_url_encoding.htm forbidden_chars = '"<>#%{}|\^~[]` \'' @@ -225,7 +223,7 @@ _option_auth_user = ('user_auth', forbidden_chars=forbidden_chars, placeholder='username', ), - PasswordFromStore( + MigrateToIndividualOrStoredPassword( title=_('Password of the user'), allow_empty=False, ), @@ -252,7 +250,7 @@ _option_auth_priv_key = ('priv_key_auth', forbidden_chars=forbidden_chars, placeholder='username', ), - PasswordFromStore( + MigrateToIndividualOrStoredPassword( title=_('Pass phrase'), allow_empty=False, ), @@ -318,7 +316,7 @@ _option_proxy_auth = ('proxy_auth', forbidden_chars=forbidden_chars, placeholder='proxyusername', ), - PasswordFromStore( + MigrateToIndividualOrStoredPassword( title=_('Password of the user'), allow_empty=False, ), @@ -470,9 +468,9 @@ _option_ftp_settings = ('ftp_settings', TextUnicode( label=_('Address to use'), help=_( - 'Can be the interface name ie "eth0", a exact ip address, a ' - 'hostname/FQDN or "-" to use the same address used for the ' - 'control connection' + 'Can be the interface name ie "eth0", a exact ip address,' + ' a hostname/FQDN or "-" to use the same address used for' + ' the control connection' ), default_value='-', regex='[0-9a-zA-Z\\.:\\-_]', @@ -637,7 +635,7 @@ _option_api_key_header = ('api_key_header', forbidden_chars='|"', placeholder='X-API-Key: ', ), - PasswordFromStore( + MigrateToIndividualOrStoredPassword( title=_('API Key'), allow_empty=False, ), diff --git a/source/lib/python3/cmk/base/cee/plugins/bakery/curl.py b/source/lib/python3/cmk/base/cee/plugins/bakery/curl.py index e9cd95dd5099b88b162b1b3f81d09f1fef3db156..025ed9e258b8de58abc18e6b0f35795efcfe5039 100644 --- a/source/lib/python3/cmk/base/cee/plugins/bakery/curl.py +++ b/source/lib/python3/cmk/base/cee/plugins/bakery/curl.py @@ -53,13 +53,10 @@ # reworked to make scalable for multiple OSs (THX to andreas.doehler[at]gmail[dot]com) # 2022-10-21: moved from ~/local/share/check_mk/agents_bakery to ~/local/lib/check_mk/base/cee/plugins/bakery -from pathlib import Path -from typing import List, Tuple, Dict, Any from dataclasses import dataclass +from pathlib import Path +from typing import Any, Dict, List -from cmk.utils import ( - password_store, -) from cmk.base.cee.plugins.bakery.bakery_api.v1 import ( FileGenerator, OS, @@ -67,6 +64,7 @@ from cmk.base.cee.plugins.bakery.bakery_api.v1 import ( PluginConfig, register ) +from cmk.utils import password_store @dataclass @@ -334,7 +332,7 @@ def get_curl_files(conf) -> FileGenerator: except ValueError: # 2022-03-23: added ssh settings insecure, ocsp, no_revoke, cert_chain, pub_md5, pub_sha256, pub_key = url_settings['cert_verify'] - _options.append(f'--insecure') if insecure else None + _options.append(f'--insecure') if insecure else None _options.append(f'--cert-status') if ocsp else None _options.append(f'--ssl-no-revoke') if no_revoke else None _options.append(f'--hostpubmd5 {pub_md5}') if pub_md5 else None diff --git a/source/packages/curl b/source/packages/curl index 37ee079cc3de712e91a7b84812d444e0c90a805e..d0416526178e5b60f53d669d449d7fe14b98fdb8 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.2.1-20231021', - 'version.min_required': '2.2.0b1', - 'version.packaged': '2.2.0p24', - 'version.usable_until': '2.3.0b1'} + 'version': '0.2.0-20240623', + 'version.min_required': '2.3.0b1', + 'version.packaged': 'cmk-mkp-tool 0.2.0', + 'version.usable_until': '2.4.0b1'}