Пример #1
0
        def _render_master_control_site(site_id):
            site_state = sites.states().get(site_id)
            if site_state["state"] == "dead":
                html.show_error(site_state["exception"])

            elif site_state["state"] == "disabled":
                html.show_message(_("Site is disabled"))

            elif site_state["state"] == "unknown":
                if site_state.get("exception"):
                    html.show_error(site_state["exception"])
                else:
                    html.show_error(_("Site state is unknown"))

            else:
                is_cmc = site_state["program_version"].startswith("Check_MK ")

                try:
                    site_info = site_status_info[site_id]
                except KeyError:
                    site_info = None

                html.open_table(class_="master_control")
                for i, (colname, title) in enumerate(items):
                    # Do not show event handlers on Check_MK Micro Core
                    if is_cmc and title == _("Event handlers"):
                        continue
                    elif not is_cmc and title == _("Alert handlers"):
                        continue

                    colvalue = site_info[i]
                    url = html.makeactionuri_contextless(
                        [
                            ("site", site_id),
                            ("switch", colname),
                            ("state", "%d" % (1 - colvalue)),
                        ],
                        filename="switch_master_state.py")
                    onclick = "cmk.ajax.get_url('%s', cmk.utils.update_contents, 'snapin_master_control')" % url

                    html.open_tr()
                    html.td(title, class_="left")
                    html.open_td()
                    html.toggle_switch(
                        enabled=colvalue,
                        help_txt=_("Switch '%s' to '%s'") %
                        (title, _("off") if colvalue else _("on")),
                        onclick=onclick,
                    )
                    html.close_td()
                    html.close_tr()

                html.close_table()
Пример #2
0
    def show(self):
        # type: () -> None
        html.open_table(cellspacing="0", class_="sitestate")

        sites.update_site_states_from_dead_sites()

        for sitename, _sitealias in config.sorted_sites():
            site = config.site(sitename)

            state = sites.states().get(sitename,
                                       sites.SiteStatus({})).get("state")

            if state is None:
                state = "missing"
                switch = "missing"
                text = sitename

            else:
                if state == "disabled":
                    switch = "on"
                    text = site["alias"]
                else:
                    switch = "off"
                    text = render_link(
                        site["alias"],
                        "view.py?view_name=sitehosts&site=%s" % sitename)

            html.open_tr()
            html.open_td(class_="left")
            html.write(text)
            html.close_td()
            html.open_td(class_="state")
            if switch == "missing":
                html.status_label(content=state,
                                  status=state,
                                  title=_("Site is missing"))
            else:
                url = html.makeactionuri_contextless([
                    ("_site_switch", "%s:%s" % (sitename, switch)),
                ],
                                                     filename="switch_site.py")
                html.status_label_button(
                    content=state,
                    status=state,
                    title=_("enable this site")
                    if state == "disabled" else _("disable this site"),
                    onclick="cmk.sidebar.switch_site(%s)" % (json.dumps(url)))
            html.close_tr()
        html.close_table()
Пример #3
0
def render_page_confirm(acktime, failed_notifications):
    title = _("Confirm failed notifications")
    breadcrumb = make_simple_page_breadcrumb(
        mega_menu_registry.menu_monitoring(), title)

    confirm_url = make_confirm_link(
        url=html.makeactionuri_contextless([
            ("mode", "clear_failed_notifications"),
            ("acktime", str(acktime)),
            ("_confirm", "1"),
        ]),
        message=
        _("Do you really want to acknowledge all failed notifications up to %s?"
          ) % cmk.utils.render.date_and_time(acktime),
    )

    page_menu = PageMenu(
        dropdowns=[
            PageMenuDropdown(
                name="actions",
                title=_("Actions"),
                topics=[
                    PageMenuTopic(
                        title=_("Actions"),
                        entries=[
                            PageMenuEntry(
                                title=_("Confirm"),
                                icon_name="save",
                                item=make_javascript_link(confirm_url),
                                is_shortcut=True,
                                is_suggested=True,
                                is_enabled=failed_notifications,
                            ),
                        ],
                    ),
                ],
            ),
        ],
        breadcrumb=breadcrumb,
    )
    html.header(title, breadcrumb, page_menu)

    render_notification_table(failed_notifications)

    html.footer()