Esempio n. 1
0
    def liveproxyd_connection_params_elements(cls):
        defaults = ConfigDomainLiveproxy.connection_params_defaults()

        return [
            ("channels",
             Integer(
                 title=_("Number of channels to keep open"),
                 minvalue=2,
                 maxvalue=50,
                 default_value=defaults["channels"],
             )),
            ("heartbeat",
             Tuple(title=_("Regular heartbeat"),
                   orientation="float",
                   elements=[
                       Integer(
                           label=_("One heartbeat every"),
                           unit=_("sec"),
                           minvalue=1,
                           default_value=defaults["heartbeat"][0],
                       ),
                       Float(label=_("with a timeout of"),
                             unit=_("sec"),
                             minvalue=0.1,
                             default_value=defaults["heartbeat"][1],
                             display_format="%.1f"),
                   ])),
            ("channel_timeout",
             Float(
                 title=_("Timeout waiting for a free channel"),
                 minvalue=0.1,
                 default_value=defaults["channel_timeout"],
                 unit=_("sec"),
             )),
            ("query_timeout",
             Float(
                 title=_("Total query timeout"),
                 minvalue=0.1,
                 unit=_("sec"),
                 default_value=defaults["query_timeout"],
             )),
            ("connect_retry",
             Float(
                 title=_("Cooling period after failed connect/heartbeat"),
                 minvalue=0.1,
                 unit=_("sec"),
                 default_value=defaults["connect_retry"],
             )),
            ("cache",
             Checkbox(
                 title=_("Enable Caching"),
                 label=_("Cache several non-status queries"),
                 help=
                 _("This option will enable the caching of several queries that "
                   "need no current data. This reduces the number of Livestatus "
                   "queries to sites and cuts down the response time of remote "
                   "sites with large latencies."),
                 default_value=defaults["cache"],
             )),
        ]
Esempio n. 2
0
    def transform_old_connection_params(cls, value):
        if "params" in value:
            return value

        new_value = {
            "params": value,
        }

        defaults = ConfigDomainLiveproxy.connection_params_defaults()
        for key, val in value.items():
            if val == defaults[key]:
                del value[key]

        if not value:
            new_value["params"] = None

        return new_value
Esempio n. 3
0
    def _save_liveproxyd_config(cls, sites):
        path = cmk.utils.paths.default_config_dir + "/liveproxyd.mk"

        conf = {}
        for siteid, siteconf in sites.items():
            proxy_params = siteconf["proxy"]
            if proxy_params is None:
                continue

            conf[siteid] = {
                "socket": siteconf["socket"],
            }

            if "tcp" in proxy_params:
                conf[siteid]["tcp"] = proxy_params["tcp"]

            if proxy_params["params"]:
                conf[siteid].update(proxy_params["params"])

        store.save_to_mk_file(path, "sites", conf)

        ConfigDomainLiveproxy().activate()