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