Update graylog-metrics so it'll work in CheckMK 2.3.
This commit is contained in:
parent
7fb9a07709
commit
6323fabd31
@ -17,24 +17,11 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
cmk.utils.password_store.replace_passwords()
|
||||
|
||||
|
||||
class GraylogSection(NamedTuple):
|
||||
name: str
|
||||
uri: str
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
|
||||
args = parse_arguments(argv)
|
||||
|
||||
try:
|
||||
handle_request(args)
|
||||
except Exception:
|
||||
if args.debug:
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def handle_request(args): # pylint: disable=too-many-branches
|
||||
@ -106,8 +93,6 @@ def handle_response(url, args):
|
||||
return requests.get(url, auth=(args.user, args.password), verify=not args.no_cert_check)
|
||||
except requests.exceptions.RequestException as e:
|
||||
sys.stderr.write("Error: %s\n" % e)
|
||||
if args.debug:
|
||||
raise
|
||||
|
||||
|
||||
def handle_output(value):
|
||||
@ -136,9 +121,6 @@ def parse_arguments(argv):
|
||||
parser.add_argument(
|
||||
"-p", "--port", default=443, type=int, help="Use alternative port (default: 443)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--debug", action="store_true", help="Debug mode: let Python exceptions come through"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-cert-check", action="store_true", help="Disable SSL certificate validation"
|
||||
)
|
||||
|
||||
@ -10,12 +10,7 @@
|
||||
# 'password': 'yeah',
|
||||
# }
|
||||
|
||||
from typing import Any, Mapping, Optional, Sequence, Union
|
||||
|
||||
|
||||
def agent_graylog_input_metrics_arguments(
|
||||
params: Mapping[str, Any], hostname: str, ipaddress: Optional[str]
|
||||
) -> Sequence[Union[str, tuple[str, str, str]]]:
|
||||
def agent_graylog_input_metrics_arguments(params, hostname, ipaddress):
|
||||
args = [
|
||||
"-P",
|
||||
params["protocol"],
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
# resolving legacy discovery results such as [("SUMMARY", "diskstat_default_levels")]. Furthermore,
|
||||
# it might also remove variables needed for accessing discovery rulesets.
|
||||
import json
|
||||
from cmk.base.check_api import check_levels, LegacyCheckDefinition
|
||||
from cmk.base.config import check_info
|
||||
from cmk.agent_based.v2 import Service
|
||||
|
||||
#<<<graylog_input_metrics:sep(0)>>>
|
||||
# {"641e88d05d447a677efde199": {"input_state": "FAILED", "input_name": "kafka_cef_test",
|
||||
@ -29,7 +32,7 @@ def parse_graylog_input_metrics(section):
|
||||
def inventory_graylog_input_metrics(parsed):
|
||||
for input_id, input_info in parsed.items():
|
||||
input_name = input_info["input_name"]
|
||||
yield Service(f"{input_name} ({input_id})")
|
||||
yield Service(item=f"{input_name} ({input_id})")
|
||||
|
||||
|
||||
def check_graylog_input_metrics(item, params, parsed):
|
||||
@ -71,11 +74,11 @@ def check_graylog_input_metrics(item, params, parsed):
|
||||
infoname=infotext
|
||||
)
|
||||
|
||||
check_info["graylog_input_metrics"] = {
|
||||
"parse_function": parse_graylog_input_metrics,
|
||||
"check_function": check_graylog_input_metrics,
|
||||
"inventory_function": inventory_graylog_input_metrics,
|
||||
"service_description": "Graylog Input %s",
|
||||
"has_perfdata": True,
|
||||
"group": "graylog_input_metrics",
|
||||
}
|
||||
check_info["graylog_input_metrics"] = LegacyCheckDefinition(
|
||||
parse_function = parse_graylog_input_metrics,
|
||||
check_function = check_graylog_input_metrics,
|
||||
discovery_function = inventory_graylog_input_metrics,
|
||||
service_name = "Graylog Input %s",
|
||||
check_ruleset_name = "graylog_input_metrics",
|
||||
check_default_parameters={},
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user