Exemplo n.º 1
0
def create_rule(param):
    """Create rule"""
    body = param["body"]
    folder = body["folder"]
    value = body["value_raw"]
    rulesets = watolib.FolderRulesets(folder)
    rulesets.load()
    try:
        ruleset = rulesets.get(body["ruleset"])
    except KeyError:
        return problem(
            status=400,
            detail=f"Ruleset {body['ruleset']!r} could not be found.",
        )

    try:
        ruleset.valuespec().validate_value(value, "")
    except exceptions.MKUserError as exc:
        if exc.varname is None:
            title = "A field has a problem"
        else:
            field_name = exc.varname.replace("_p_", "")
            title = f"Problem in (sub-)field {field_name!r}"

        return problem(
            status=400,
            detail=strip_tags(exc.message),
            title=title,
        )

    rule = watolib.Rule(
        gen_id(),
        folder,
        ruleset,
        RuleConditions(
            host_folder=folder,
            host_tags=body["conditions"].get("host_tag"),
            host_labels=body["conditions"].get("host_label"),
            host_name=body["conditions"].get("host_name"),
            service_description=body["conditions"].get("service_description"),
            service_labels=body["conditions"].get("service_label"),
        ),
        RuleOptions.from_config(body["properties"]),
        value,
    )
    index = ruleset.append_rule(folder, rule)
    rulesets.save()
    # TODO Duplicated code is in pages/rulesets.py:2670-
    # TODO Move to watolib
    add_change(
        "new-rule",
        _l('Created new rule #%d in ruleset "%s" in folder "%s"')
        % (index, ruleset.title(), folder.alias_path()),
        sites=folder.all_site_ids(),
        diff_text=make_diff_text({}, rule.to_log()),
        object_ref=rule.object_ref(),
    )
    return serve_json(_serialize_rule(folder, index, rule))
Exemplo n.º 2
0
 def __init__(self):
     super().__init__(
         _FilterRangeConfig(
             column="topology_max_nodes",
             title=_l("Topology max nodes"),
             step=100,
             default=2000,
             min=200,
             max=10000,
         ))
Exemplo n.º 3
0
def test_lazy_localization():
    lazy_str = i18n._l("Age")

    assert lazy_str == "Age"

    i18n.localize("de")
    assert lazy_str == "Alter"

    i18n.unlocalize()
    assert lazy_str == "Age"
Exemplo n.º 4
0
 def __init__(self):
     super().__init__(
         _FilterRangeConfig(
             column="topology_mesh_depth",
             title=_l("Topology mesh depth"),
             step=1,
             default=0,
             min=0,
             max=10,
         ))
Exemplo n.º 5
0
 def __init__(self) -> None:
     super().__init__(
         title=_l("Has Inventory Data"),
         sort_index=801,
         info="host",
         query_filter=query_filters.TristateQuery(
             ident="has_inv",
             filter_code=lambda x: "",  # No Livestatus filtering right now
             filter_row=query_filters.has_inventory,
         ),
         is_show_more=True,
     )
Exemplo n.º 6
0
 def __init__(self) -> None:
     self._varprefix = "invswpac_host_"
     super().__init__(
         ident="invswpac",
         title=_l("Host has software package"),
         sort_index=801,
         info="host",
         htmlvars=[
             self._varprefix + "name",
             self._varprefix + "version_from",
             self._varprefix + "version_to",
             self._varprefix + "negate",
             self._varprefix + "match",
         ],
         link_columns=[],
         is_show_more=True,
     )
Exemplo n.º 7
0
def register_omd_apache_metrics():
    for ty, unit in [("requests", "1/s"), ("bytes", "bytes/s"), ("secs", "1/s")]:
        metric_info[ty + "_cmk_views"] = {
            "title": "%s: %s" % (_l("Checkmk: Views"), ty.capitalize()),
            "unit": unit,
            "color": "#ff8080",
        }

        metric_info[ty + "_cmk_wato"] = {
            "title": "%s: %s" % (_l("Checkmk: WATO"), ty.capitalize()),
            "unit": unit,
            "color": "#377cab",
        }

        metric_info[ty + "_cmk_bi"] = {
            "title": "%s: %s" % (_l("Checkmk: BI"), ty.capitalize()),
            "unit": unit,
            "color": "#4eb0f2",
        }

        metric_info[ty + "_cmk_snapins"] = {
            "title": "%s: %s" % (_l("Checkmk: Sidebar elements"), ty.capitalize()),
            "unit": unit,
            "color": "#ff4040",
        }

        metric_info[ty + "_cmk_dashboards"] = {
            "title": "%s: %s" % (_l("Checkmk: Dashboards"), ty.capitalize()),
            "unit": unit,
            "color": "#4040ff",
        }

        metric_info[ty + "_cmk_other"] = {
            "title": "%s: %s" % (_l("Checkmk: Other"), ty.capitalize()),
            "unit": unit,
            "color": "#5bb9eb",
        }

        metric_info[ty + "_nagvis_snapin"] = {
            "title": "%s: %s" % (_l("NagVis: Sidebar element"), ty.capitalize()),
            "unit": unit,
            "color": "#f2904e",
        }

        metric_info[ty + "_nagvis_ajax"] = {
            "title": "%s: %s" % (_l("NagVis: AJAX"), ty.capitalize()),
            "unit": unit,
            "color": "#af91eb",
        }

        metric_info[ty + "_nagvis_other"] = {
            "title": "%s: %s" % (_l("NagVis: Other"), ty.capitalize()),
            "unit": unit,
            "color": "#f2df40",
        }

        metric_info[ty + "_images"] = {
            "title": "%s: %s" % (_l("Image"), ty.capitalize()),
            "unit": unit,
            "color": "#91cceb",
        }

        metric_info[ty + "_styles"] = {
            "title": "%s: %s" % (_l("Styles"), ty.capitalize()),
            "unit": unit,
            "color": "#c6f24e",
        }

        metric_info[ty + "_scripts"] = {
            "title": "%s: %s" % (_l("Scripts"), ty.capitalize()),
            "unit": unit,
            "color": "#4ef26c",
        }

        metric_info[ty + "_other"] = {
            "title": "%s: %s" % (_l("Other"), ty.capitalize()),
            "unit": unit,
            "color": "#4eeaf2",
        }
Exemplo n.º 8
0
#   .--Metrics-------------------------------------------------------------.
#   |                   __  __      _        _                             |
#   |                  |  \/  | ___| |_ _ __(_) ___ ___                    |
#   |                  | |\/| |/ _ \ __| '__| |/ __/ __|                   |
#   |                  | |  | |  __/ |_| |  | | (__\__ \                   |
#   |                  |_|  |_|\___|\__|_|  |_|\___|___/                   |
#   |                                                                      |
#   +----------------------------------------------------------------------+
#   |  Definitions of metrics                                              |
#   '----------------------------------------------------------------------'

# Title are always lower case - except the first character!
# Colors: See indexed_color() in cmk/gui/plugins/metrics/utils.py

metric_info["citrix_load"] = {
    "title": _l("Citrix Load"),
    "unit": "%",
    "color": "34/a",
}

# .
#   .--Graphs--------------------------------------------------------------.
#   |                    ____                 _                            |
#   |                   / ___|_ __ __ _ _ __ | |__  ___                    |
#   |                  | |  _| '__/ _` | '_ \| '_ \/ __|                   |
#   |                  | |_| | | | (_| | |_) | | | \__ \                   |
#   |                   \____|_|  \__,_| .__/|_| |_|___/                   |
#   |                                  |_|                                 |
#   +----------------------------------------------------------------------+
#   |  Definitions of time series graphs                                   |
#   '----------------------------------------------------------------------'
Exemplo n.º 9
0
    """Create a breadcrumb for the main menu level"""
    return Breadcrumb([BreadcrumbItem(
        title=menu.title,
        url=None,
    )])


def _view_menu_topics() -> List[TopicMenuTopic]:
    from cmk.gui.plugins.sidebar.views import get_view_menu_items
    return get_view_menu_items()


MegaMenuMonitoring = mega_menu_registry.register(
    MegaMenu(
        name="monitoring",
        title=_l("Monitor"),
        icon_name="main_monitoring",
        sort_index=5,
        topics=_view_menu_topics,
    ))


def _setup_menu_topics() -> List[TopicMenuTopic]:
    from cmk.gui.plugins.sidebar.wato import get_wato_menu_items
    return get_wato_menu_items()


MegaMenuSetup = mega_menu_registry.register(
    MegaMenu(
        name="setup",
        title=_l("Setup"),
Exemplo n.º 10
0
    if modes:
        raise MKGeneralException(
            _("Deprecated WATO modes found: %r. "
              "They need to be refactored to new API.") % list(modes.keys()))

    # This must be set after plugin loading to make broken plugins raise
    # exceptions all the time and not only the first time (when the plugins
    # are loaded).
    loaded_with_language = cmk.gui.i18n.get_current_language()


permission_registry.register(
    Permission(
        section=cmk.gui.plugins.wato.utils.PermissionSectionWATO,
        name="use",
        title=_l("Use WATO"),
        description=_l("This permissions allows users to use WATO - Check_MK's "
                       "Web Administration Tool. Without this "
                       "permission all references to WATO (buttons, links, "
                       "snapins) will be invisible."),
        defaults=["admin", "user"],
    ))

permission_registry.register(
    Permission(
        section=cmk.gui.plugins.wato.utils.PermissionSectionWATO,
        name="edit",
        title=_l("Make changes, perform actions"),
        description=_l("This permission is needed in order to make any "
                       "changes or perform any actions at all. "
                       "Without this permission, the user is only "
Exemplo n.º 11
0
#   |                    |_   _|__  _ __ (_) ___ ___                       |
#   |                      | |/ _ \| '_ \| |/ __/ __|                      |
#   |                      | | (_) | |_) | | (__\__ \                      |
#   |                      |_|\___/| .__/|_|\___|___/                      |
#   |                              |_|                                     |
#   +----------------------------------------------------------------------+
#   | Register the builtin topics. These are the ones that may be          |
#   | referenced by different WATO plugins. Additional individual plugins  |
#   | are allowed to create their own topics.                              |
#   '----------------------------------------------------------------------'
#.

MainModuleTopicHosts = main_module_topic_registry.register(
    MainModuleTopic(
        name="hosts",
        title=_l("Hosts"),
        icon_name="topic_hosts",
        sort_index=10,
    ))

MainModuleTopicServices = main_module_topic_registry.register(
    MainModuleTopic(
        name="services",
        title=_l("Services"),
        icon_name="topic_services",
        sort_index=20,
    ))

MainModuleTopicBI = main_module_topic_registry.register(
    MainModuleTopic(
        name="bi",
Exemplo n.º 12
0
@permission_section_registry.register
class PermissionSectionNagVis(PermissionSection):
    @property
    def name(self):
        return "nagvis"

    @property
    def title(self):
        return _('NagVis')


permission_registry.register(
    Permission(
        section=PermissionSectionNagVis,
        name="*_*_*",
        title=_l('Full access'),
        description=_l('This permission grants full access to NagVis.'),
        defaults=["admin"],
    ))

permission_registry.register(
    Permission(
        section=PermissionSectionNagVis,
        name="Rotation_view_*",
        title=_l('Use all map rotations'),
        description=_l('Grants read access to all rotations.'),
        defaults=["guest"],
    ))

permission_registry.register(
    Permission(
Exemplo n.º 13
0

#   .--Reschedule----------------------------------------------------------.
#   |          ____                _              _       _                |
#   |         |  _ \ ___  ___  ___| |__   ___  __| |_   _| | ___           |
#   |         | |_) / _ \/ __|/ __| '_ \ / _ \/ _` | | | | |/ _ \          |
#   |         |  _ <  __/\__ \ (__| | | |  __/ (_| | |_| | |  __/          |
#   |         |_| \_\___||___/\___|_| |_|\___|\__,_|\__,_|_|\___|          |
#   |                                                                      |
#   '----------------------------------------------------------------------'

PermissionActionReschedule = permission_registry.register(
    Permission(
        section=PermissionSectionAction,
        name="reschedule",
        title=_l("Reschedule checks"),
        description=_l("Reschedule host and service checks"),
        defaults=["user", "admin"],
    ))


@command_registry.register
class CommandReschedule(Command):
    @property
    def ident(self):
        return "reschedule"

    @property
    def title(self):
        return _("Reschedule active checks")
Exemplo n.º 14
0
            icon="topic_user_interface",
            items=quick_items,
        ),
        TopicMenuTopic(
            name="user",
            title=_("User profile"),
            icon="topic_profile",
            items=items,
        ),
    ]


mega_menu_registry.register(
    MegaMenu(
        name="user",
        title=_l("User"),
        icon="main_user",
        sort_index=20,
        topics=_user_menu_topics,
        info_line=lambda: f"{user.id} ({user.baserole_id})",
    ))


@page_registry.register_page("ajax_ui_theme")
class ModeAjaxCycleThemes(AjaxPage):
    """AJAX handler for quick access option 'Interface theme" in user menu"""
    def page(self) -> AjaxPageResult:
        themes = [theme for theme, _title in theme_choices()]
        current_theme = theme.get()
        try:
            theme_index = themes.index(current_theme)
Exemplo n.º 15
0
#   .--Metrics-------------------------------------------------------------.
#   |                   __  __      _        _                             |
#   |                  |  \/  | ___| |_ _ __(_) ___ ___                    |
#   |                  | |\/| |/ _ \ __| '__| |/ __/ __|                   |
#   |                  | |  | |  __/ |_| |  | | (__\__ \                   |
#   |                  |_|  |_|\___|\__|_|  |_|\___|___/                   |
#   |                                                                      |
#   +----------------------------------------------------------------------+
#   |  Definitions of metrics                                              |
#   '----------------------------------------------------------------------'

# Title are always lower case - except the first character!
# Colors: See indexed_color() in cmk/gui/plugins/metrics/utils.py

metric_info["vbuckets"] = {
    "title": _l("vBuckets"),
    "unit": "count",
    "color": "11/a",
}

metric_info["pending_vbuckets"] = {
    "title": _l("Pending vBuckets"),
    "unit": "count",
    "color": "11/a",
}

metric_info["memused_couchbase_bucket"] = {
    "color": "#80ff40",
    "title": _l("Memory used"),
    "unit": "bytes",
}
Exemplo n.º 16
0
    # Sort the items of all topics
    for topic in by_topic.values():
        topic.items.sort(key=lambda i: (i.sort_index, i.title))

    # Return the sorted topics
    return [
        v for k, v in sorted(by_topic.items(),
                             key=lambda e: (e[0].sort_index, e[0].title))
    ]


mega_menu_registry.register(
    MegaMenu(
        name="setup",
        title=_l("Setup"),
        icon="main_setup",
        sort_index=15,
        topics=get_wato_menu_items,
        search=search.SetupSearch("setup_search"),
    ))


class MatchItemGeneratorSetupMenu(ABCMatchItemGenerator):
    def __init__(
        self,
        name: str,
        topic_generator: Callable[[], Iterable[TopicMenuTopic]],
    ) -> None:
        super().__init__(name)
        self._topic_generator = topic_generator
Exemplo n.º 17
0
        # global multisite_filters var and self.path_to_tree is not refreshed when
        # rendering this title. Thus the threads might have old information about the
        # file titles and so on.
        # The call below needs to use some sort of indicator wether the cache needs
        # to be renewed or not.
        self.check_wato_data_update()
        current = value.get(self.ident)
        if current and current != "/":
            return self.path_to_tree.get(current)
        return None


filter_registry.register(
    FilterWatoFolder(
        ident="wato_folder",
        title=_l("Folder"),
        sort_index=10,
        info="host",
        htmlvars=["wato_folder"],
        link_columns=[],
    ), )


class FilterMultipleWatoFolder(FilterWatoFolder):
    # Once filters are managed by a valuespec and we get more complex
    # datastuctures beyond FilterHTTPVariable there must be a back&forth
    # for data
    def valuespec(self):
        # Drop Main directory represented by empty string, because it means
        # don't filter after any folder due to recursive folder filtering.
        choices = [(name, folder) for name, folder in self.choices() if name]
Exemplo n.º 18
0
#   .--Metrics-------------------------------------------------------------.
#   |                   __  __      _        _                             |
#   |                  |  \/  | ___| |_ _ __(_) ___ ___                    |
#   |                  | |\/| |/ _ \ __| '__| |/ __/ __|                   |
#   |                  | |  | |  __/ |_| |  | | (__\__ \                   |
#   |                  |_|  |_|\___|\__|_|  |_|\___|___/                   |
#   |                                                                      |
#   +----------------------------------------------------------------------+
#   |  Definitions of metrics                                              |
#   '----------------------------------------------------------------------'

# Title are always lower case - except the first character!
# Colors: See indexed_color() in cmk/gui/plugins/metrics/utils.py

metric_info["host_check_rate"] = {
    "title": _l("Host check rate"),
    "unit": "1/s",
    "color": "52/a",
}

metric_info["monitored_hosts"] = {
    "title": _l("Monitored hosts"),
    "unit": "count",
    "color": "52/b",
}

metric_info["hosts_active"] = {
    "title": _l("Active hosts"),
    "unit": "count",
    "color": "11/a",
}
Exemplo n.º 19
0
    (22, "local6"),
    (23, "local7"),
    (31, "snmptrap"),
]

phase_names = {
    "counting": _("counting"),
    "delayed": _("delayed"),
    "open": _("open"),
    "ack": _("acknowledged"),
    "closed": _("closed"),
}

action_whats = {
    "ORPHANED":
    _l("Event deleted in counting state because rule was deleted."),
    "NOCOUNT":
    _l("Event deleted in counting state because rule does not count anymore"),
    "DELAYOVER":
    _l("Event opened because the delay time has elapsed before cancelling event arrived."
       ),
    "EXPIRED":
    _l("Event deleted because its livetime expired"),
    "COUNTREACHED":
    _l("Event deleted because required count had been reached"),
    "COUNTFAILED":
    _l("Event created by required count was not reached in time"),
    "UPDATE":
    _l("Event information updated by user"),
    "NEW":
    _l("New event created"),
Exemplo n.º 20
0
            not config.hidden_views or name not in config.hidden_views)
    ]

    network_topology_visual_spec = ParentChildTopologyPage.visual_spec()
    pages_to_show = [(network_topology_visual_spec["name"],
                      network_topology_visual_spec)]

    visuals_to_show = [("views", e) for e in views_to_show]
    visuals_to_show += [("dashboards", e)
                        for e in dashboard.get_permitted_dashboards().items()]
    visuals_to_show += [("pages", e) for e in pages_to_show]
    visuals_to_show += page_type_items

    if reporting:
        reporting.load_reports()
        visuals_to_show += [("reports", e)
                            for e in reporting.permitted_reports().items()]

    return make_topic_menu(visuals_to_show)


mega_menu_registry.register(
    MegaMenu(
        name="monitoring",
        title=_l("Monitor"),
        icon="main_monitoring",
        sort_index=5,
        topics=get_view_menu_items,
        search=search.MonitoringSearch("monitoring_search"),
    ))
Exemplo n.º 21
0
        "mail": {
            "title": _("Send an E-Mail"),
            "handler": notify_mail,
        },
        "dashlet": {
            "title": _("Show notification in dashboard element 'User notifications'"),
            "handler": notify_gui_msg,
        },
    }


permission_registry.register(
    Permission(
        section=PermissionSectionGeneral,
        name="notify",
        title=_l("Notify Users"),
        description=_l(
            "This permissions allows users to send notifications to the users of "
            "the monitoring system using the web interface."
        ),
        defaults=["admin"],
    )
)


@cmk.gui.pages.register("notify")
def page_notify():
    if not user.may("general.notify"):
        raise MKAuthException(_("You are not allowed to use the notification module."))

    title = _("Notify users")
Exemplo n.º 22
0
        return "general"

    @property
    def title(self):
        return _("General Permissions")

    @property
    def sort_index(self):
        return 10


PermissionGeneralUse = permission_registry.register(
    Permission(
        section=PermissionSectionGeneral,
        name="use",
        title=_l("Use the GUI at all"),
        description=_l("Users without this permission are not let in at all"),
        defaults=config.builtin_role_ids,
    )
)

permission_registry.register(
    Permission(
        section=PermissionSectionGeneral,
        name="server_side_requests",
        title=_l("Perform requests from the Checkmk server"),
        description=_l(
            "Users with this permission can use GUI features that initiate network connections "
            "from the Checkmk server to other hosts on the intra/internet. Although this feature "
            "makes it e.g. easier to fetch CAs from servers it may be used to scan the internal "
            "network for open ports and running services."
Exemplo n.º 23
0
                TopicMenuItem(
                    name="change_log",
                    title=_("Change log (Werks)"),
                    url="change_log.py",
                    sort_index=20,
                    icon="tribe29",
                ),
            ],
        ),
    ]


mega_menu_registry.register(
    MegaMenu(
        name="help_links",
        title=_l("Help"),
        icon="main_help",
        sort_index=18,
        topics=_help_menu_topics,
        info_line=lambda:
        f"{edition().title} {__version__}{free_edition_status()}",
    ))


def free_edition_status() -> str:
    if not is_free_edition():
        return ""

    passed_time = get_age_trial()
    # Hardcoded 30 days of trial. For dynamic trial time change the 30 days
    remaining_time = timedelta(seconds=30 * 24 * 60 * 60 - passed_time)
Exemplo n.º 24
0
#   .--Metrics-------------------------------------------------------------.
#   |                   __  __      _        _                             |
#   |                  |  \/  | ___| |_ _ __(_) ___ ___                    |
#   |                  | |\/| |/ _ \ __| '__| |/ __/ __|                   |
#   |                  | |  | |  __/ |_| |  | | (__\__ \                   |
#   |                  |_|  |_|\___|\__|_|  |_|\___|___/                   |
#   |                                                                      |
#   +----------------------------------------------------------------------+
#   |  Definitions of metrics                                              |
#   '----------------------------------------------------------------------'

# Title are always lower case - except the first character!
# Colors: See indexed_color() in cmk/gui/plugins/metrics/utils.py

metric_info["major_page_faults"] = {
    "title": _l("Major page faults"),
    "unit": "1/s",
    "color": "#20ff80",
}

metric_info["page_swap_in"] = {
    "title": _l("Page Swap In"),
    "unit": "1/s",
    "color": "33/a",
}

metric_info["page_swap_out"] = {
    "title": _l("Page Swap Out"),
    "unit": "1/s",
    "color": "36/a",
}
Exemplo n.º 25
0
    @property
    def title(self):
        return _("Crash time")

    @property
    def columns(self):
        return ['crash_time']

    def cmp(self, r1, r2):
        return cmp_simple_number("crash_time", r1, r2)


permission_registry.register(PermissionActionDeleteCrashReport := Permission(
    section=PermissionSectionAction,
    name="delete_crash_report",
    title=_l("Delete crash reports"),
    description=_l("Delete crash reports created by Checkmk"),
    defaults=["admin"],
))

@command_registry.register
class CommandDeleteCrashReports(Command):
    @property
    def ident(self):
        return "delete_crash_reports"

    @property
    def title(self):
        return _("Delete crash reports")

    @property
Exemplo n.º 26
0
@permission_section_registry.register
class PermissionSectionBI(PermissionSection):
    @property
    def name(self):
        return "bi"

    @property
    def title(self):
        return _("BI - Checkmk Business Intelligence")


permission_registry.register(
    Permission(
        section=PermissionSectionBI,
        name="see_all",
        title=_l("See all hosts and services"),
        description=_l(
            "With this permission set, the BI aggregation rules are applied to all "
            "hosts and services - not only those the user is a contact for. If you "
            "remove this permissions then the user will see incomplete aggregation "
            "trees with status based only on those items."
        ),
        defaults=["admin", "guest"],
    )
)


def is_part_of_aggregation(host, service):
    if BIAggregationPacks.get_num_enabled_aggregations() == 0:
        return False
    return get_cached_bi_compiler().is_part_of_aggregation(host, service)
Exemplo n.º 27
0
    (13, "(13: unused)"),
    (14, "(14: unused)"),
    (15, "(15: unused)"),
    (16, "local0"),
    (17, "local1"),
    (18, "local2"),
    (19, "local3"),
    (20, "local4"),
    (21, "local5"),
    (22, "local6"),
    (23, "local7"),
    (31, "snmptrap"),
]

phase_names = {
    "counting": _l("counting"),
    "delayed": _l("delayed"),
    "open": _l("open"),
    "ack": _l("acknowledged"),
    "closed": _l("closed"),
}

action_whats = {
    "ORPHANED": _l("Event deleted in counting state because rule was deleted."),
    "NOCOUNT": _l("Event deleted in counting state because rule does not count anymore"),
    "DELAYOVER": _l(
        "Event opened because the delay time has elapsed before cancelling event arrived."
    ),
    "EXPIRED": _l("Event deleted because its livetime expired"),
    "COUNTREACHED": _l("Event deleted because required count had been reached"),
    "COUNTFAILED": _l("Event created by required count was not reached in time"),
Exemplo n.º 28
0
    if loaded_with_language == cmk.gui.i18n.get_current_language() and not force:
        return

    utils.load_web_plugins("webapi", globals())

    # This must be set after plugin loading to make broken plugins raise
    # exceptions all the time and not only the first time (when the plugins
    # are loaded).
    loaded_with_language = cmk.gui.i18n.get_current_language()


permission_registry.register(
    Permission(
        section=PermissionSectionWATO,
        name="api_allowed",
        title=_l("Access to Web-API"),
        description=_l("This permissions specifies if the role "
                       "is able to use Web-API functions. It is only available "
                       "for automation users."),
        defaults=config.builtin_role_ids,
    ))

Formatter = Callable[[Dict[str, Any]], str]

_FORMATTERS: Dict[str, Tuple[Formatter, Formatter]] = {
    "json":
        (json.dumps,
         lambda response: json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))),
    "python": (repr, pprint.pformat),
    "xml":
        (dicttoxml.dicttoxml,
Exemplo n.º 29
0
@permission_section_registry.register
class PermissionSectionBackgroundJobs(PermissionSection):
    @property
    def name(self):
        return "background_jobs"

    @property
    def title(self):
        return _("Background jobs")


permission_registry.register(
    Permission(
        section=PermissionSectionBackgroundJobs,
        name="manage_jobs",
        title=_l("Manage background jobs"),
        description=_l("Allows you to see the job overview page."),
        defaults=["admin"],
    ))

permission_registry.register(
    Permission(
        section=PermissionSectionBackgroundJobs,
        name="stop_jobs",
        title=_l("Stop background jobs"),
        description=_l(
            "Configures the permission to stop background jobs. Note: some jobs cannot be stopped."
        ),
        defaults=["user", "admin"],
    ))
Exemplo n.º 30
0
#   .--Metrics-------------------------------------------------------------.
#   |                   __  __      _        _                             |
#   |                  |  \/  | ___| |_ _ __(_) ___ ___                    |
#   |                  | |\/| |/ _ \ __| '__| |/ __/ __|                   |
#   |                  | |  | |  __/ |_| |  | | (__\__ \                   |
#   |                  |_|  |_|\___|\__|_|  |_|\___|___/                   |
#   |                                                                      |
#   +----------------------------------------------------------------------+
#   |  Definitions of metrics                                              |
#   '----------------------------------------------------------------------'

# Title are always lower case - except the first character!
# Colors: See indexed_color() in cmk/gui/plugins/metrics/utils.py

metric_info["faas_total_instance_count"] = {
    "title": _l("Total number of instances"),
    "unit": "count",
    "color": "11/a",
}

metric_info["faas_active_instance_count"] = {
    "title": _l("Number of active instances"),
    "unit": "count",
    "color": "12/a",
}

metric_info["faas_execution_count"] = {
    "title": _l("Number of requests"),
    "unit": "count",
    "color": "11/a",
}