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 0b7d9096 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent f6d65e2a
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,8 @@
# 2022-03-22: added curl_error_code_to_ignore and http_error_code_to_ignore options
# 2022-04-06: removed .replace('://', ': //')) from json.loads() so service name is without space
# 2022-04-26: made http(s) URLs clickable
# 2022-05-15: added workaround for raise ValueError("Cannot render negative timespan")
#
# Example output from agent:
#
......@@ -61,7 +63,7 @@
import json
import time
from typing import Dict, Any, List
from typing import Dict, Any, List, Iterable
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
......@@ -76,6 +78,40 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import (
render,
)
#
# start workaround for : raise ValueError("Cannot render negative timespan")
#
from cmk.base.plugins.agent_based.agent_based_api.v1.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")
#
_curl_error_codes = {
1: 'Unsupported protocol. This build of curl has no support for this protocol.',
2: 'Failed to initialize.',
......@@ -404,7 +440,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=render.timespan,
render_func=timespan,
notice_only=True,
levels_upper=upper,
levels_lower=lower,
......
No preview for this file type
......@@ -26,7 +26,7 @@
'name': 'curl',
'num_files': 6,
'title': 'cURL agent plugin',
'version': '20220426.v0.1.8a',
'version': '20220515.v0.1.8b',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
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