checkmk-plugins/check_mk-graylog_metrics/local/share/check_mk/web/plugins/wato/graylog_input_metrics.py

98 lines
3.3 KiB
Python

#!/usr/bin/env python3
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
from cmk.gui.i18n import _
from cmk.gui.plugins.wato.special_agents.common import RulespecGroupDatasourceProgramsApps
from cmk.gui.plugins.wato.utils import HostRulespec, IndividualOrStoredPassword, rulespec_registry
from cmk.gui.valuespec import Age, Dictionary, DropdownChoice, Integer, ListChoice, TextInput
from cmk.gui.watolib.rulespecs import Rulespec
def _factory_default_special_agents_graylog_input_metrics():
# No default, do not use setting if no rule matches
return Rulespec.FACTORY_DEFAULT_UNUSED
def _valuespec_special_agents_graylog_input_metrics():
return Dictionary(
title=_("Graylog Input Metrics"),
help=_("Requests input metrics data from a Graylog instance."),
optional_keys=["port", "no-cert-check"],
elements=[
(
"instance",
TextInput(
title=_("Graylog instance to query"),
help=_(
"Use this option to set which instance should be "
"checked by the special agent. Please add the "
"hostname here, eg. my_graylog.com."
),
size=32,
allow_empty=False,
),
),
(
"user",
TextInput(
title=_("Username"),
help=_(
"The username that should be used for accessing the "
"Graylog API. Has to have read permissions at least."
),
size=32,
allow_empty=False,
),
),
(
"password",
IndividualOrStoredPassword(
title=_("Password of the user"),
allow_empty=False,
),
),
(
"protocol",
DropdownChoice(
title=_("Protocol"),
choices=[
("http", "HTTP"),
("https", "HTTPS"),
],
default_value="https",
),
),
(
"port",
Integer(
title=_("Port"),
help=_(
"Use this option to query a port which is different from standard port 443."
),
default_value=443,
),
),
(
"no-cert-check",
FixedValue(
True,
title=_("Disable SSL certificate validation"),
totext=_("SSL certificate validation is disabled"),
),
),
],
)
rulespec_registry.register(
HostRulespec(
factory_default=_factory_default_special_agents_graylog_input_metrics(),
group=RulespecGroupDatasourceProgramsApps,
name="special_agents:graylog_input_metrics",
valuespec=_valuespec_special_agents_graylog_input_metrics,
)
)