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

update project

parent cafdc529
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@
# 2022-03-12: added cafile and capath to Cert info section
# added max_age
# 2022-03-18: added regex pattern match
# 2022-03-22: added curl_error_code_to_ignore and http_error_code_to_ignore options
#
# Example output from agent:
......@@ -268,16 +269,29 @@ def check_curl(item, params, section: Dict[str, Any]) -> CheckResult:
yield Result(state=State.OK, notice=f'{label}: {value}')
if curl_error_code != 0:
yield Result(
state=State(params['state_curl_result_not_0']),
summary=f'curl error code: {curl_error_code} see details',
details=f'curl error code: {curl_error_code}, {_curl_error_codes.get(curl_error_code, "N/A")}'
)
if curl_error_code in params['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")}')
else:
yield Result(
state=State(params['state_curl_result_not_0']),
summary=f'curl error code: {curl_error_code} see details',
details=f'curl error code: {curl_error_code}, {_curl_error_codes.get(curl_error_code, "N/A")}'
)
if http_return_code < 400: # no connect, Ok, Redirect
yield Result(state=State.OK, notice=f'HTTP Return code: {http_return_code}')
else:
yield Result(state=State(params['state_http_result_not_200']), summary=f'HTTP Return code: {http_return_code}')
if http_return_code in params['http_error_code_to_ignore']:
yield Result(
state=State.OK, notice=f'HTTP Return code: {http_return_code}'
)
else:
yield Result(
state=State(params['state_http_result_not_200']),
notice=f'HTTP Return code: {http_return_code}'
)
if ssl_verify_result == 0:
yield Result(state=State.OK, notice=f'SSL verify result: {ssl_verify_result}')
......@@ -473,7 +487,9 @@ register.check_plugin(
'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,
......
......@@ -65,13 +65,13 @@ def get_curl_files(conf: Tuple[str, Dict[str, List[any]]]) -> FileGenerator:
if conf[0] == 'linux':
_os = OS.LINUX
_script = 'curl.sh'
_curl_output = '-o /dev/null'
_curl_output = '--output /dev/null'
_temp_path = '/var/tmp/'
_conf_path = '/etc/check_mk/'
elif conf[0] == 'windows':
_os = OS.WINDOWS
_script = 'curl.ps1'
_curl_output = '-o NUL'
_curl_output = '--output NUL'
_temp_path = 'c:/windows/temp/'
_conf_path = 'C:/ProgramData/checkmk/agent/config/'
else:
......@@ -400,7 +400,7 @@ def get_curl_files(conf: Tuple[str, Dict[str, List[any]]]) -> FileGenerator:
url_settings.pop('ftp_settings')
if save_output:
options_array.append(f'-o {_temp_path}curl_output')
options_array.append(f'--output {_temp_path}curl_output')
else:
options_array.append(_curl_output)
......
......@@ -58,7 +58,7 @@ if (Test-Path -Path "C:\ProgramData\checkmk\agent\bin\curl.exe" -PathType Leaf)
exit 0
}
$CURL_OPTIONS="-q -w %{json} -s --verbose --stderr $TEMP_DIR\curl_session"
$CURL_OPTIONS="--disable --write-out %{json} --silent --verbose --include --stderr $TEMP_DIR\curl_session"
$CURL_OPTIONS=$CURL_OPTIONS.Substring(0,$CURL_OPTIONS.Length -0)
$CURL_RUN="FIRST"
$CURL_RESULT=""
......
......@@ -28,7 +28,7 @@ CONF_DIR="/etc/check_mk"
LIB_DIR="/usr/lib/check_mk_agent"
TEMP_DIR="/var/tmp"
CURL_OPTIONS="-q -w %{json} -s --verbose --stderr $TEMP_DIR/curl_session"
CURL_OPTIONS="--disable --write-out %{json} --silent --verbose --include --stderr $TEMP_DIR/curl_session"
CURL_CONFIG=curl.cfg
CURL_RUN="FIRST"
CURL_OUTPUT="$TEMP_DIR/curl_output"
......
No preview for this file type
......@@ -21,7 +21,7 @@
'name': 'curl',
'num_files': 6,
'title': 'cURL agent plugin',
'version': '20220320.v0.1.2',
'version': '20220322.v0.1.2',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
......@@ -58,6 +58,8 @@
# added options --ftp-ssl-control, --ftp-ssl-ccc, --ftp-ssl-ccc-mode
# 2022-03-21: moved --connect-timeout, --limit-rate, --max-filesize, --max-time, --speed-limit, --speed-time
# to "limits" sub Directory
# 2022-03-22: added curl_error_code_to_ignore and http_error_code_to_ignore options
#
import ipaddress
from cmk.gui.i18n import _
from cmk.gui.exceptions import MKUserError
......@@ -137,12 +139,26 @@ _curl_check_elements = [
title=_('State on HTTP result not OK'),
help=_('Monitoring state if the HTTP return code is not in 2xx or 3xx. Default is WARN.')
)),
('http_error_code_to_ignore',
ListOfStrings(
title=_('HTTP:q error codes to ignore'),
allow_empty=False,
orientation='horizontal',
valuespec=Integer(size=3, minvalue=0, maxvalue=999),
)),
('state_curl_result_not_0',
MonitoringState(
default_value=1,
title=_('State on cURL exit code not OK'),
help=_('Monitoring state if the exit code is not 0. Default is WARN.')
)),
('curl_error_code_to_ignore',
ListOfStrings(
title=_('cURL error codes to ignore'),
allow_empty=False,
orientation='horizontal',
valuespec=Integer(size=3, minvalue=0, maxvalue=999),
)),
('state_verify_sll_not_0',
MonitoringState(
default_value=1,
......@@ -683,7 +699,7 @@ _option_header_strings = ('header_strings',
title=_('Strings to expect in header'),
# orientation='horizontal',
allow_empty=False,
valuespec=TextInput(allow_empty=False, regex='[a-zA-Z0-9\.]'),
valuespec=TextInput(allow_empty=False, regex='[a-zA-Z0-9\\.]'),
))
_url_header_strings = ('header_strings',
CascadingDropdown(
......
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