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

update project

parent 892c8046
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,8 @@
# fixed options in curl.cfg for windows
# 2022-02-24: removed deployment of curl.format
# added noproxy option in per url settings
# 2022-02-25: optimized file write
# added double quotas to curl option for linux to be equal with windows
from pathlib import Path
from typing import List
......@@ -69,15 +71,34 @@ def get_curl_files(conf: List[any]) -> FileGenerator:
field_separator: str = '|' # needs matching separator in the shell scripts
options_separator: str = ' '
os = conf[0]
_os = None
_script = None
if conf[0] == 'linux':
_os = OS.LINUX
_script = 'curl.sh'
elif conf[0] == 'windows':
_os = OS.WINDOWS
_script = 'curl.cmd'
options = conf[1].copy()
ca_certs = []
url_cfg_lines_linux = []
url_cfg_lines_windows = []
url_cfg_lines = []
url_list = options['url_list']
default_settings = options.get('default_settings', {})
interval = None
timeout = None
if options.get('interval'):
interval = options['interval']
options.pop('interval')
if options.get('timeout'):
timeout = options['timeout']
options.pop('timeout')
for entry in url_list:
options_array = []
service_name = entry['service_name']
......@@ -135,38 +156,21 @@ def get_curl_files(conf: List[any]) -> FileGenerator:
curl_options = options_separator.join(options_array)
# if curl_options:
url_cfg_lines_linux.append(f'{service_name}{field_separator}{url}{field_separator}{curl_options.strip()}')
url_cfg_lines_windows.append(f'{service_name}{field_separator}{url}{field_separator}"{curl_options.strip()}"')
# else:
# url_cfg_lines.append(f'{service_name}{field_separator}"{url}"')
if os == 'linux':
yield Plugin(
base_os=OS.LINUX,
source=Path('curl.sh'),
target=Path('curl.sh'),
)
yield PluginConfig(
base_os=OS.LINUX,
lines=url_cfg_lines_linux,
target=Path('curl.cfg'),
include_header=False,
)
elif os == 'windows':
yield Plugin(
base_os=OS.WINDOWS,
source=Path('curl.cmd'),
target=Path('curl.cmd'),
)
yield PluginConfig(
base_os=OS.WINDOWS,
lines=url_cfg_lines_windows,
target=Path('curl.cfg'),
include_header=False,
)
url_cfg_lines.append(f'{service_name}{field_separator}{url}{field_separator}"{curl_options.strip()}"')
yield Plugin(
base_os=_os,
source=Path(_script),
target=Path(_script),
interval=interval,
timeout=timeout,
)
yield PluginConfig(
base_os=_os,
lines=url_cfg_lines,
target=Path('curl.cfg'),
include_header=False,
)
register.bakery_plugin(
......
......@@ -59,10 +59,11 @@ while read -r LINE; do
fi
printf '"%s":{"url":"%s","data":' "$SERVICE_NAME" "$URL"
$CURL_EXECUTABLE --url $URL $CURL_OPTIONS $OPTIONS
# cut double quotas from options, added in bakery to be equal with windows version
$CURL_EXECUTABLE --url $URL $CURL_OPTIONS ${OPTIONS:1:-1}
ERROR_LEVEL=$?
printf ',"error_level":"%s"' "$ERROR_LEVEL"
printf ',"curl_options":"%s %s"}' "$CURL_OPTIONS" "$OPTIONS"
printf ',"curl_options":"%s %s"}' "$CURL_OPTIONS" "${OPTIONS:1:-1}"
done <"$CURL_CONFIG"
......
No preview for this file type
......@@ -24,7 +24,7 @@
'name': 'curl',
'num_files': 7,
'title': 'cURL agent plugin',
'version': '20220124.v0.0.3',
'version': '20220125.v0.0.3',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
......@@ -35,6 +35,7 @@ from cmk.gui.valuespec import (
UploadOrPasteTextFile,
MonitoringState,
Float,
Checkbox,
)
from cmk.gui.plugins.wato import (
rulespec_registry,
......@@ -104,28 +105,29 @@ for key, label, unit in _limits:
('upper',
Tuple(
title=_('Upper limits'),
orientation='horizontal',
elements=[
Float(title=_('Warning at'), minvalue=0, unit=_(unit), ),
Float(title=_('Critical at'), minvalue=0, unit=_(unit), ),
Float(title=_('Warning at'), minvalue=0, unit=_(unit), size=10),
Float(title=_('Critical at'), minvalue=0, unit=_(unit), size=10),
])),
('lower',
Tuple(
title=_('Lower limits'),
orientation='horizontal',
elements=[
Float(title=_('Warning below'), minvalue=0, unit=_(unit), ),
Float(title=_('Critical below'), minvalue=0, unit=_(unit), ),
Float(title=_('Warning below'), minvalue=0, unit=_(unit), size=10),
Float(title=_('Critical below'), minvalue=0, unit=_(unit), size=10),
])),
],
required_keys=['upper']
# required_keys=['upper']
))
)
def _valuespec_curl():
return Dictionary(
elements=_curl_check_elements
elements=_curl_check_elements,
)
......@@ -413,8 +415,38 @@ _option_default_settings = ('default_settings',
]
))
_base_options_config_interval = (
'interval',
Integer(
title=_('Plugin run interval'),
# minvalue=60,
unit=_('s'),
# default_value=86400,
help=_(
'This is the interval at witch the plugin runs. If not set the plugin will run with every cycle of'
' the agent (By default every 60 seconds).'
),
),
)
_base_options_config_timeout = (
'timeout',
Integer(
title=_('Plugin timeout'),
# minvalue=60,
unit=_('s'),
# default_value=300,
help=_(
'This is the maximum run time for the plugin. If not set the timeout for the plugin is 60 seconds (1 mon)'
'by default.'
),
),
)
elements = [
_option_url,
_base_options_config_interval,
_base_options_config_timeout,
_option_default_settings
]
......
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