Ejemplo n.º 1
0
def test_is_raw_edition(monkeypatch):
    monkeypatch.setattr(cmk, "omd_version", lambda: "1.4.0i1.cre")
    assert cmk.is_raw_edition() == True
    monkeypatch.setattr(cmk, "omd_version", lambda: "1.4.0i1.cee")
    assert cmk.is_raw_edition() == False
    monkeypatch.setattr(cmk, "omd_version", lambda: "2016.09.22.cee")
    assert cmk.is_raw_edition() == False
    monkeypatch.setattr(cmk, "omd_version", lambda: "2016.09.22.cee.demo")
    assert cmk.is_raw_edition() == False
Ejemplo n.º 2
0
def test_is_raw_edition(monkeypatch):
    monkeypatch.setattr(cmk, "omd_version", lambda: "1.4.0i1.cre")
    assert cmk.is_raw_edition() == True
    monkeypatch.setattr(cmk, "omd_version", lambda: "1.4.0i1.cee")
    assert cmk.is_raw_edition() == False
    monkeypatch.setattr(cmk, "omd_version", lambda: "2016.09.22.cee")
    assert cmk.is_raw_edition() == False
    monkeypatch.setattr(cmk, "omd_version", lambda: "2016.09.22.cee.demo")
    assert cmk.is_raw_edition() == False
Ejemplo n.º 3
0
def _vs_annotation():
    extra_elements = []
    if not cmk.is_raw_edition():
        extra_elements.append(("hide_from_report", Checkbox(title=_("Hide annotation in report"))))

    return Dictionary(
        elements=[
            ("site", TextAscii(title=_("Site"))),
            ("host", TextUnicode(title=_("Hostname"))),
            ("service", Optional(TextUnicode(allow_empty=False), sameline=True,
                                 title=_("Service"))),
            ("from", AbsoluteDate(title=_("Start-Time"), include_time=True)),
            ("until", AbsoluteDate(title=_("End-Time"), include_time=True)),
            ("downtime",
             Optional(
                 DropdownChoice(choices=[
                     (True, _("regard as scheduled downtime")),
                     (False, _("do not regard as scheduled downtime")),
                 ],),
                 title=_("Scheduled downtime"),
                 label=_("Reclassify downtime of this period"),
             )),
            ("text", TextAreaUnicode(title=_("Annotation"), allow_empty=False)),
        ] + extra_elements,
        title=_("Edit annotation"),
        optional_keys=[],
    )
Ejemplo n.º 4
0
    def factory():
        if cmk.is_raw_edition():
            cls = CRESiteManagement
        else:
            cls = CEESiteManagement

        return cls()
Ejemplo n.º 5
0
def test_filters_filter_table(register_builtin_html, test, monkeypatch):
    # Needed for DeploymentTristateFilter test
    def deployment_states(host_name):
        return {
            "abc": {
                "target_aghash": "abc",
            },
            "zzz": {},
        }[host_name]

    if not cmk.is_raw_edition():
        import cmk.gui.cee.agent_bakery as agent_bakery # pylint: disable=redefined-outer-name
        monkeypatch.setattr(agent_bakery, "get_cached_deployment_status", deployment_states)

    # Needed for FilterInvFloat test
    monkeypatch.setattr(cmk.gui.inventory, "get_inventory_data", get_inventory_data_patch)

    # Needed for FilterAggrServiceUsed test
    def is_part_of_aggregation_patch(what, site, host, service):
        return {
            ("s", "h", "srv1"): True
        }.get((site, host, service), False)

    monkeypatch.setattr(cmk.gui.bi, "is_part_of_aggregation", is_part_of_aggregation_patch)

    with html.stashed_vars(), on_time('2018-04-15 16:50', 'CET'):
        html.request.del_vars()
        for key, val in test.request_vars:
            html.request.set_var(key, val)

        # TODO: Fix this for real...
        if not cmk.is_raw_edition or test.ident != "deployment_has_agent":
            filt = cmk.gui.plugins.visuals.utils.filter_registry[test.ident]()
            assert filt.filter_table(test.rows) == test.expected_rows
Ejemplo n.º 6
0
def test_refresh_snapins():
    expected_refresh_snapins = [
        'admin',
        'admin_mini',
        'performance',
        'hostmatrix',
        'mkeventd_performance',
        'nagvis_maps',
        'problem_hosts',
        'sitestatus',
        'tactical_overview',
        'tag_tree',
        'time',
    ]

    if not cmk.is_raw_edition():
        expected_refresh_snapins += [
            'cmc_stats',
        ]

    refresh_snapins = [
        s.type_name() for s in snapin_registry.values()
        if s.refresh_regularly()
    ]
    assert sorted(refresh_snapins) == sorted(expected_refresh_snapins)
def test_registered_ac_tests():
    expected_ac_tests = [
        'ACTestAlertHandlerEventTypes',
        'ACTestApacheNumberOfProcesses',
        'ACTestApacheProcessUsage',
        'ACTestBackupConfigured',
        'ACTestBackupNotEncryptedConfigured',
        'ACTestBrokenGUIExtension',
        'ACTestCheckMKHelperUsage',
        'ACTestESXDatasources',
        'ACTestGenericCheckHelperUsage',
        'ACTestHTTPSecured',
        'ACTestLDAPSecured',
        'ACTestLiveproxyd',
        'ACTestLivestatusUsage',
        'ACTestLivestatusSecured',
        'ACTestNumberOfUsers',
        'ACTestOldDefaultCredentials',
        'ACTestPersistentConnections',
        'ACTestRulebasedNotifications',
        'ACTestSizeOfExtensions',
        'ACTestTmpfs',
    ]

    if not cmk.is_raw_edition():
        expected_ac_tests += [
            'ACTestSecureAgentUpdaterTransport',
            'ACTestSecureNotificationSpoolerMessages',
        ]

    registered_plugins = sorted(watolib.ac_test_registry.keys())
    assert registered_plugins == sorted(expected_ac_tests)
Ejemplo n.º 8
0
def test_dashlet_registry_plugins():
    expected_plugins = [
        'hoststats',
        'notify_failed_notifications',
        'mk_logo',
        'network_topology',
        'servicestats',
        'url',
        'overview',
        'pnpgraph',
        'view',
        'linked_view',
        'notify_users',
        'nodata',
        'snapin',
    ]

    if not cmk.is_raw_edition():
        expected_plugins += [
            'custom_graph',
        ]

    dashboard._transform_old_dict_based_dashlets()
    assert sorted(
        dashboard.dashlet_registry.keys()) == sorted(expected_plugins)
Ejemplo n.º 9
0
def show_annotations(annotations, av_rawdata, what, avoptions, omit_service):
    annos_to_render = get_relevant_annotations(annotations, av_rawdata, what, avoptions)
    render_date = get_annotation_date_render_function(annos_to_render, avoptions)

    with table_element(title=_("Annotations"), omit_if_empty=True) as table:
        for (site_id, host, service), annotation in annos_to_render:
            table.row()
            table.cell("", css="buttons")
            anno_vars = [
                ("anno_site", site_id),
                ("anno_host", host),
                ("anno_service", service or ""),
                ("anno_from", int(annotation["from"])),
                ("anno_until", int(annotation["until"])),
            ]
            edit_url = html.makeuri(anno_vars)
            html.icon_button(edit_url, _("Edit this annotation"), "edit")
            delete_url = html.makeactionuri([("_delete_annotation", "1")] + anno_vars)
            html.icon_button(delete_url, _("Delete this annotation"), "delete")

            if not omit_service:
                if not "omit_host" in avoptions["labelling"]:
                    host_url = "view.py?" + html.urlencode_vars([("view_name", "hoststatus"),
                                                                 ("site", site_id), ("host", host)])
                    table.cell(_("Host"), html.render_a(host, host_url))

                if what == "service":
                    if service:
                        service_url = "view.py?" + html.urlencode_vars([("view_name", "service"),
                                                                        ("site", site_id),
                                                                        ("host", host),
                                                                        ("service", service)])
                        # TODO: honor use_display_name. But we have no display names here...
                        service_name = service
                        table.cell(_("Service"), html.render_a(service_name, service_url))
                    else:
                        table.cell(_("Service"), "")  # Host annotation in service table

            table.cell(_("From"), render_date(annotation["from"]), css="nobr narrow")
            table.cell(_("Until"), render_date(annotation["until"]), css="nobr narrow")
            table.cell("", css="buttons")
            if annotation.get("downtime") is True:
                html.icon(_("This period has been reclassified as a scheduled downtime"),
                          "downtime")
            elif annotation.get("downtime") is False:
                html.icon(
                    _("This period has been reclassified as a not being a scheduled downtime"),
                    "nodowntime")
            table.cell(_("Annotation"), html.render_text(annotation["text"]))
            table.cell(_("Author"), annotation["author"])
            table.cell(_("Entry"), render_date(annotation["date"]), css="nobr narrow")
            if not cmk.is_raw_edition():
                table.cell(_("Hide in report"),
                           _("Yes") if annotation.get("hide_from_report") else _("No"))
Ejemplo n.º 10
0
def test_registered_generators():
    expected_generators = [
        'acknowledge_initial_werks',
        'basic_wato_config',
        'create_automation_user',
        'ec_sample_rule_pack',
    ]

    if not cmk.is_raw_edition():
        expected_generators += [
            'cee_agent_bakery',
            'cee_basic_config',
        ]

    assert sorted(utils.sample_config_generator_registry.keys()) == sorted(expected_generators)
Ejemplo n.º 11
0
def test_registered_jobs():

    expected = [
        'cmk.gui.inventory.run',
        'cmk.gui.plugins.cron.gui_background_job.housekeeping',
        'cmk.gui.userdb.execute_userdb_job',
        'cmk.gui.wato.execute_network_scan_job',
    ]

    if not cmk.is_raw_edition():
        expected += [
            'cmk.gui.cee.reporting.cleanup_stored_reports',
            'cmk.gui.cee.reporting.do_scheduled_reports',
        ]

    found_jobs = sorted(["%s.%s" % (f.__module__, f.__name__) for f in cron.multisite_cronjobs])
    assert found_jobs == sorted(expected)
Ejemplo n.º 12
0
def test_builtin_icons_and_actions():
    expected_icons_and_actions = [
        'action_menu',
        'aggregation_checks',
        'aggregations',
        'check_manpage',
        'check_period',
        'crashed_check',
        'custom_action',
        'download_agent_output',
        'download_snmp_walk',
        'icon_image',
        'inventory',
        'logwatch',
        'mkeventd',
        'notes',
        'parent_child_topology',
        'perfgraph',
        'prediction',
        'reschedule',
        'rule_editor',
        'stars',
        'status_acknowledged',
        'status_active_checks',
        'status_comments',
        'status_downtimes',
        'status_flapping',
        'status_notification_period',
        'status_notifications_enabled',
        'status_passive_checks',
        'status_service_period',
        'status_stale',
        'wato',
    ]

    if not cmk.is_raw_edition():
        expected_icons_and_actions += [
            'agent_deployment',
            'deployment_status',
            'status_shadow',
        ]

    cmk.gui.views.transform_old_dict_based_icons()
    builtin_icons = sorted(icons.get_multisite_icons().keys())
    assert builtin_icons == sorted(expected_icons_and_actions)
Ejemplo n.º 13
0
def test_get_sorted_generators():
    expected = [
        'basic_wato_config',
    ]

    if not cmk.is_raw_edition():
        expected += [
            'cee_basic_config',
            'cee_agent_bakery',
        ]

    expected += [
        'acknowledge_initial_werks',
        'ec_sample_rule_pack',
        'create_automation_user',
    ]

    assert [g.ident() for g in utils.sample_config_generator_registry.get_generators()] == expected
Ejemplo n.º 14
0
def test_registered_background_jobs():
    expected_jobs = [
        'ParentScanBackgroundJob',
        'DummyBackgroundJob',
        'RenameHostsBackgroundJob',
        'RenameHostBackgroundJob',
        'FetchAgentOutputBackgroundJob',
        'BulkDiscoveryBackgroundJob',
        'UserSyncBackgroundJob',
        'ServiceDiscoveryBackgroundJob',
    ]

    if not cmk.is_raw_edition():
        expected_jobs += [
            'BakeAgentsBackgroundJob',
            'ReportingBackgroundJob',
        ]

    assert sorted(gui_background_job.job_registry.keys()) == sorted(expected_jobs)
Ejemplo n.º 15
0
def _expected_intervals():
    expected = [
        ('hoststats', 60),
        ('mk_logo', False),
        ('network_topology', False),
        ('nodata', False),
        ('notify_failed_notifications', 60),
        ('notify_users', False),
        ('overview', False),
        ('pnpgraph', 60),
        ('servicestats', 60),
        ('snapin', 30),
        ('url', False),
        ('view', False),
    ]

    if not cmk.is_raw_edition():
        expected += [
            ('custom_graph', 60),
        ]

    return expected
Ejemplo n.º 16
0
def test_registered_snapins():
    expected_snapins = [
        'about',
        'admin',
        'admin_mini',
        'biaggr_groups',
        'biaggr_groups_tree',
        'bookmarks',
        'custom_links',
        'dashboards',
        'hostgroups',
        'hostmatrix',
        'hosts',
        'master_control',
        'mkeventd_performance',
        'nagios_legacy',
        'nagvis_maps',
        'performance',
        'problem_hosts',
        'search',
        'servicegroups',
        'sitestatus',
        'speedometer',
        'tactical_overview',
        'tag_tree',
        'time',
        'views',
        'wato_folders',
        'wato_foldertree',
        'wiki',
    ]

    if not cmk.is_raw_edition():
        expected_snapins += [
            'cmc_stats',
            'reports',
        ]

    assert sorted(snapin_registry.keys()) == sorted(expected_snapins)
Ejemplo n.º 17
0
def evaluate_time_series_expression(expression, rrd_data):
    if rrd_data:
        num_points = len(list(rrd_data.values())[0])
    else:
        num_points = 1

    if expression[0] == "operator":
        operator_id, operands = expression[1:]
        operands_evaluated = [
            evaluate_time_series_expression(a, rrd_data) for a in operands
        ]
        return time_series_math(operator_id, operands_evaluated)

    if expression[0] == "transformation":
        (transform, conf), operands = expression[1:]
        operands_evaluated = evaluate_time_series_expression(
            operands[0], rrd_data)
        if transform == 'percentile':
            return time_series_operator_perc(operands_evaluated, conf)
        if transform == 'forecast':
            if cmk.is_raw_edition():
                raise MKGeneralException(
                    _("Forecast calculations are only available with the "
                      "Checkmk Enterprise Editions"))
            # Suppression is needed to silence pylint in CRE environment
            from cmk.gui.cee.plugins.metrics.forecasts import time_series_transform_forecast  # pylint: disable=no-name-in-module
            return time_series_transform_forecast(operands_evaluated, conf)

    if expression[0] == "rrd":
        key = tuple(expression[1:])
        if key in rrd_data:
            return rrd_data[key]
        return [None] * num_points

    if expression[0] == "constant":
        return [expression[1]] * num_points

    raise NotImplementedError()
Ejemplo n.º 18
0
def test_registered_permission_sections():
    expected_sections = [
        ('bookmark_list', (50, u'Bookmark lists', True)),
        ('custom_snapin', (50, u'Custom snapins', True)),
        ('sidesnap', (50, u'Sidebar snapins', True)),
        ('notification_plugin', (50, u'Notification plugins', True)),
        ('wato', (50, u"WATO - Check_MK's Web Administration Tool", False)),
        ('background_jobs', (50, u'Background jobs', False)),
        ('bi', (50, u'BI - Check_MK Business Intelligence', False)),
        ('general', (10, u'General Permissions', False)),
        ('mkeventd', (50, u'Event Console', False)),
        ('action', (50, u'Commands on host and services', True)),
        ('dashboard', (50, u'Dashboards', True)),
        ('nagvis', (50, u'NagVis', False)),
        ('view', (50, u'Views', True)),
        ('icons_and_actions', (50, u'Icons', True)),
    ]

    if not cmk.is_raw_edition():
        expected_sections += [
            ('custom_graph', (50, u'Custom Graphs', True)),
            ('forecast_graph', (50, u'Forecast Graphs', True)),
            ('graph_collection', (50, u'Graph Collections', True)),
            ('graph_tuning', (50, u'Graph tunings', True)),
            ('sla_configuration', (50, u'Service Level Agreements', True)),
            ('report', (50, u'Reports', True)),
        ]

    section_names = permission_section_registry.keys()
    assert sorted([s[0] for s in expected_sections]) == sorted(section_names)

    for name, (sort_index, title, do_sort) in expected_sections:
        section = permission_section_registry[name]()
        assert section.title == title
        assert section.sort_index == sort_index
        assert section.do_sort == do_sort
Ejemplo n.º 19
0
from cmk.gui.watolib.wato_background_job import WatoBackgroundJob
if cmk.is_managed_edition():
    import cmk.gui.cme.managed as managed  # pylint: disable=no-name-in-module

from cmk.gui.plugins.watolib.utils import (
    ABCConfigDomain,
    config_domain_registry,
    config_variable_registry,
    wato_fileheader,
    SampleConfigGenerator,
    sample_config_generator_registry,
)

import cmk.gui.plugins.watolib

if not cmk.is_raw_edition():
    import cmk.gui.cee.plugins.watolib  # pylint: disable=no-name-in-module

# Disable python warnings in background job output or logs like "Unverified
# HTTPS request is being made". We warn the user using analyze configuration.
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


def load_watolib_plugins():
    cmk.gui.utils.load_web_plugins("watolib", globals())


# TODO: Must only be unlocked when it was not locked before. We should find a more
# robust way for doing something like this. If it is locked before, it can now happen
# that this call unlocks the wider locking when calling this funktion in a wrong way.
def init_wato_datastructures(with_wato_lock=False):
Ejemplo n.º 20
0
def test_registered_permissions():
    expected_permissions = [
        'action.acknowledge',
        'action.addcomment',
        'action.clearmodattr',
        'action.customnotification',
        'action.downtimes',
        'action.enablechecks',
        'action.fakechecks',
        'action.notifications',
        'action.remove_all_downtimes',
        'action.reschedule',
        'action.star',
        'action.delete_crash_report',
        'background_jobs.delete_foreign_jobs',
        'background_jobs.delete_jobs',
        'background_jobs.manage_jobs',
        'background_jobs.see_foreign_jobs',
        'background_jobs.stop_foreign_jobs',
        'background_jobs.stop_jobs',
        'bi.see_all',
        'dashboard.main',
        'dashboard.simple_problems',
        'dashboard.topology',
        'general.acknowledge_werks',
        'general.act',
        'general.change_password',
        'general.configure_sidebar',
        'general.csv_export',
        'general.delete_foreign_bookmark_list',
        'general.delete_foreign_custom_snapin',
        'general.delete_foreign_dashboards',
        'general.delete_foreign_views',
        'general.disable_notifications',
        'general.edit_bookmark_list',
        'general.edit_custom_snapin',
        'general.edit_dashboards',
        'general.edit_foreign_bookmark_list',
        'general.edit_foreign_dashboards',
        'general.edit_foreign_views',
        'general.edit_foreign_custom_snapin',
        'general.edit_notifications',
        'general.edit_profile',
        'general.edit_user_attributes',
        'general.edit_views',
        'general.force_bookmark_list',
        'general.force_custom_snapin',
        'general.force_dashboards',
        'general.force_views',
        'general.ignore_hard_limit',
        'general.ignore_soft_limit',
        'general.logout',
        'general.notify',
        'general.painter_options',
        'general.publish_bookmark_list',
        'general.publish_to_foreign_groups_bookmark_list',
        'general.publish_custom_snapin',
        'general.publish_to_foreign_groups_custom_snapin',
        'general.publish_dashboards',
        'general.publish_dashboards_to_foreign_groups',
        'general.publish_views',
        'general.publish_views_to_foreign_groups',
        'general.see_all',
        'general.see_availability',
        'general.see_crash_reports',
        'general.see_failed_notifications',
        'general.see_failed_notifications_24h',
        'general.see_sidebar',
        'general.see_stales_in_tactical_overview',
        'general.see_user_bookmark_list',
        'general.see_user_custom_snapin',
        'general.see_user_dashboards',
        'general.see_user_views',
        'general.use',
        'general.view_option_columns',
        'general.view_option_refresh',
        'icons_and_actions.action_menu',
        'icons_and_actions.aggregation_checks',
        'icons_and_actions.aggregations',
        'icons_and_actions.check_manpage',
        'icons_and_actions.check_period',
        'icons_and_actions.crashed_check',
        'icons_and_actions.custom_action',
        'icons_and_actions.download_agent_output',
        'icons_and_actions.download_snmp_walk',
        'icons_and_actions.icon_image',
        'icons_and_actions.inventory',
        'icons_and_actions.logwatch',
        'icons_and_actions.mkeventd',
        'icons_and_actions.notes',
        'icons_and_actions.perfgraph',
        'icons_and_actions.prediction',
        'icons_and_actions.reschedule',
        'icons_and_actions.rule_editor',
        'icons_and_actions.stars',
        'icons_and_actions.status_acknowledged',
        'icons_and_actions.status_active_checks',
        'icons_and_actions.status_comments',
        'icons_and_actions.status_downtimes',
        'icons_and_actions.status_flapping',
        'icons_and_actions.status_notification_period',
        'icons_and_actions.status_notifications_enabled',
        'icons_and_actions.status_passive_checks',
        'icons_and_actions.status_service_period',
        'icons_and_actions.status_stale',
        'icons_and_actions.wato',
        'icons_and_actions.parent_child_topology',
        'mkeventd.actions',
        'mkeventd.activate',
        'mkeventd.archive_events_of_hosts',
        'mkeventd.changestate',
        'mkeventd.config',
        'mkeventd.delete',
        'mkeventd.edit',
        'mkeventd.see_in_tactical_overview',
        'mkeventd.seeall',
        'mkeventd.seeunrelated',
        'mkeventd.switchmode',
        'mkeventd.update',
        'mkeventd.update_comment',
        'mkeventd.update_contact',
        'nagvis.*_*_*',
        'nagvis.Map_delete',
        'nagvis.Map_delete_*',
        'nagvis.Map_edit',
        'nagvis.Map_edit_*',
        'nagvis.Map_view',
        'nagvis.Map_view_*',
        'nagvis.Rotation_view_*',
        'notification_plugin.asciimail',
        'notification_plugin.jira_issues',
        'notification_plugin.mail',
        'notification_plugin.mkeventd',
        'notification_plugin.opsgenie_issues',
        'notification_plugin.pagerduty',
        'notification_plugin.pushover',
        'notification_plugin.servicenow',
        'notification_plugin.slack',
        'notification_plugin.sms',
        'notification_plugin.spectrum',
        'notification_plugin.victorops',
        'sidesnap.about',
        'sidesnap.admin',
        'sidesnap.admin_mini',
        'sidesnap.biaggr_groups',
        'sidesnap.biaggr_groups_tree',
        'sidesnap.bookmarks',
        'sidesnap.custom_links',
        'sidesnap.dashboards',
        'sidesnap.hostgroups',
        'sidesnap.hostmatrix',
        'sidesnap.hosts',
        'sidesnap.master_control',
        'sidesnap.mkeventd_performance',
        'sidesnap.nagios_legacy',
        'sidesnap.nagvis_maps',
        'sidesnap.performance',
        'sidesnap.problem_hosts',
        'sidesnap.search',
        'sidesnap.servicegroups',
        'sidesnap.sitestatus',
        'sidesnap.speedometer',
        'sidesnap.tactical_overview',
        'sidesnap.tag_tree',
        'sidesnap.time',
        'sidesnap.views',
        'sidesnap.wato_folders',
        'sidesnap.wato_foldertree',
        'sidesnap.wiki',
        'view.aggr_all',
        'view.aggr_all_api',
        'view.aggr_group',
        'view.aggr_host',
        'view.aggr_hostgroup_boxed',
        'view.aggr_hostnameaggrs',
        'view.aggr_hostproblems',
        'view.aggr_problems',
        'view.aggr_service',
        'view.aggr_single',
        'view.aggr_single_api',
        'view.aggr_singlehost',
        'view.aggr_singlehosts',
        'view.aggr_summary',
        'view.alerthandlers',
        'view.alertstats',
        'view.allhosts',
        'view.allhosts_mini',
        'view.bi_map_hover_host',
        'view.bi_map_hover_service',
        'view.allservices',
        'view.api_downtimes',
        'view.comments',
        'view.comments_of_host',
        'view.comments_of_service',
        'view.contactnotifications',
        'view.crash_reports',
        'view.downtime_history',
        'view.downtimes',
        'view.downtimes_of_host',
        'view.downtimes_of_service',
        'view.docker_containers',
        'view.docker_nodes',
        'view.vpshere_vms',
        'view.vsphere_servers',
        'view.ec_event',
        'view.ec_event_mobile',
        'view.ec_events',
        'view.ec_events_mobile',
        'view.ec_events_of_host',
        'view.ec_events_of_monhost',
        'view.ec_history_of_event',
        'view.ec_history_of_host',
        'view.ec_history_recent',
        'view.ec_historyentry',
        'view.events',
        'view.events_dash',
        'view.failed_notifications',
        'view.host',
        'view.host_crit',
        'view.host_dt_hist',
        'view.host_export',
        'view.host_ok',
        'view.host_pending',
        'view.host_unknown',
        'view.host_warn',
        'view.hostevents',
        'view.hostgroup',
        'view.hostgroup_up',
        'view.hostgroup_down',
        'view.hostgroup_unreach',
        'view.hostgroup_pend',
        'view.hostgroupgrid',
        'view.hostgroups',
        'view.hostgroupservices',
        'view.hostgroupservices_ok',
        'view.hostgroupservices_warn',
        'view.hostgroupservices_crit',
        'view.hostgroupservices_unknwn',
        'view.hostgroupservices_pend',
        'view.hostnotifications',
        'view.hostpnp',
        'view.hostproblems',
        'view.hostproblems_dash',
        'view.hosts',
        'view.hostsbygroup',
        'view.hoststatus',
        'view.hostsvcevents',
        'view.hostsvcnotifications',
        'view.hosttiles',
        'view.inv_host',
        'view.inv_host_history',
        'view.inv_hosts_cpu',
        'view.inv_hosts_ports',
        'view.invbackplane_of_host',
        'view.invbackplane_search',
        'view.invchassis_of_host',
        'view.invchassis_search',
        'view.invcontainer_of_host',
        'view.invcontainer_search',
        'view.invdockercontainers_of_host',
        'view.invdockercontainers_search',
        'view.invdockerimages_of_host',
        'view.invdockerimages_search',
        'view.invfan_of_host',
        'view.invfan_search',
        'view.invinterface_of_host',
        'view.invinterface_search',
        'view.invmodule_of_host',
        'view.invmodule_search',
        'view.invoradataguardstats_of_host',
        'view.invoradataguardstats_search',
        'view.invorainstance_of_host',
        'view.invorainstance_search',
        'view.invorarecoveryarea_of_host',
        'view.invorarecoveryarea_search',
        'view.invorasga_of_host',
        'view.invorasga_search',
        'view.invoratablespace_of_host',
        'view.invoratablespace_search',
        'view.invother_of_host',
        'view.invother_search',
        'view.invpsu_of_host',
        'view.invpsu_search',
        'view.invsensor_of_host',
        'view.invsensor_search',
        'view.invstack_of_host',
        'view.invstack_search',
        'view.invswpac_of_host',
        'view.invswpac_search',
        'view.invtunnels_of_host',
        'view.invtunnels_search',
        'view.invunknown_of_host',
        'view.invunknown_search',
        'view.logfile',
        'view.mobile_contactnotifications',
        'view.mobile_events',
        'view.mobile_host',
        'view.mobile_hostproblems',
        'view.mobile_hostproblems_unack',
        'view.mobile_hoststatus',
        'view.mobile_hostsvcevents',
        'view.mobile_hostsvcnotifications',
        'view.mobile_notifications',
        'view.mobile_searchhost',
        'view.mobile_searchsvc',
        'view.mobile_service',
        'view.mobile_svcevents',
        'view.mobile_svcnotifications',
        'view.mobile_svcproblems',
        'view.mobile_svcproblems_unack',
        'view.nagstamon_hosts',
        'view.nagstamon_svc',
        'view.notifications',
        'view.pending_discovery',
        'view.pendingsvc',
        'view.perf_matrix',
        'view.perf_matrix_search',
        'view.problemsofhost',
        'view.recentsvc',
        'view.searchhost',
        'view.searchpnp',
        'view.searchsvc',
        'view.service',
        'view.service_check_durations',
        'view.servicedesc',
        'view.servicedescpnp',
        'view.servicegroup',
        'view.sitehosts',
        'view.sitesvcs',
        'view.sitesvcs_crit',
        'view.sitesvcs_ok',
        'view.sitesvcs_pend',
        'view.sitesvcs_unknwn',
        'view.sitesvcs_warn',
        'view.stale_hosts',
        'view.starred_hosts',
        'view.starred_services',
        'view.svc_dt_hist',
        'view.svcbygroups',
        'view.svcbyhgroups',
        'view.svcevents',
        'view.svcgroups',
        'view.svcgroups_grid',
        'view.svcnotifications',
        'view.svcproblems',
        'view.svcproblems_dash',
        'view.topology_hover_host',
        'view.topology_filters',
        'view.uncheckedsvc',
        'view.unmonitored_services',
        'wato.activate',
        'wato.activateforeign',
        'wato.add_or_modify_executables',
        'wato.all_folders',
        'wato.analyze_config',
        'wato.api_allowed',
        'wato.auditlog',
        'wato.automation',
        'wato.backups',
        'wato.bi_admin',
        'wato.bi_rules',
        'wato.clear_auditlog',
        'wato.clone_hosts',
        'wato.custom_attributes',
        'wato.diag_host',
        'wato.download_agent_output',
        'wato.download_agents',
        'wato.edit',
        'wato.edit_all_passwords',
        'wato.edit_all_predefined_conditions',
        'wato.edit_folders',
        'wato.edit_hosts',
        'wato.global',
        'wato.groups',
        'wato.hosts',
        'wato.hosttags',
        'wato.icons',
        'wato.manage_folders',
        'wato.manage_hosts',
        'wato.move_hosts',
        'wato.notifications',
        'wato.parentscan',
        'wato.passwords',
        'wato.pattern_editor',
        'wato.random_hosts',
        'wato.rename_hosts',
        'wato.rulesets',
        'wato.see_all_folders',
        'wato.seeall',
        'wato.service_discovery_to_ignored',
        'wato.service_discovery_to_monitored',
        'wato.service_discovery_to_removed',
        'wato.service_discovery_to_undecided',
        'wato.services',
        'wato.set_read_only',
        'wato.sites',
        'wato.snapshots',
        'wato.timeperiods',
        'wato.update_dns_cache',
        'wato.use',
        'wato.users',
    ]

    if not cmk.is_raw_edition():
        expected_permissions += [
            'general.edit_reports',
            'icons_and_actions.agent_deployment',
            'icons_and_actions.status_shadow',
            'report.bi_availability',
            'report.default',
            'report.host',
            'report.instant',
            'report.instant_availability',
            'report.instant_graph_collection',
            'report.instant_view',
            'report.service_availability',
            'sidesnap.cmc_stats',
            'sidesnap.reports',
            'view.allhosts_deploy',
            'view.host_graphs',
            'view.service_graphs',
            'wato.agent_deploy_custom_files',
            'wato.agent_deployment',
            'wato.agents',
            'wato.alert_handlers',
            'wato.bake_agents',
            'wato.dcd_connections',
            'wato.download_all_agents',
            'wato.manage_mkps',
            'wato.mkps',
            'wato.sign_agents',
            'general.delete_foreign_custom_graph',
            'general.delete_foreign_forecast_graph',
            'general.delete_foreign_graph_collection',
            'general.delete_foreign_graph_tuning',
            'general.delete_foreign_reports',
            'general.delete_foreign_sla_configuration',
            'general.delete_foreign_stored_report',
            'general.delete_stored_report',
            'general.edit_custom_graph',
            'general.edit_forecast_graph',
            'general.edit_foreign_forecast_graph',
            'general.edit_foreign_custom_graph',
            'general.edit_foreign_graph_collection',
            'general.edit_foreign_graph_tuning',
            'general.edit_foreign_reports',
            'general.edit_foreign_sla_configuration',
            'general.edit_graph_collection',
            'general.edit_graph_tuning',
            'general.edit_sla_configuration',
            'general.force_custom_graph',
            'general.publish_forecast_graph',
            'general.force_graph_collection',
            'general.force_graph_tuning',
            'general.publish_graph_collection',
            'general.publish_to_foreign_groups_graph_collection',
            'general.publish_graph_tuning',
            'general.publish_to_foreign_groups_graph_tuning',
            'general.publish_reports',
            'general.publish_reports_to_foreign_groups',
            'general.publish_sla_configuration',
            'general.publish_to_foreign_groups_sla_configuration',
            'general.publish_stored_report',
            'general.publish_to_foreign_groups_forecast_graph',
            'general.see_user_custom_graph',
            'general.see_user_forecast_graph',
            'general.see_user_graph_collection',
            'general.see_user_graph_tuning',
            'general.see_user_reports',
            'general.see_user_sla_configuration',
            'general.see_user_stored_report',
            'general.reporting',
            'general.schedule_reports',
            'general.schedule_reports_all',
            'general.force_forecast_graph',
            'general.force_reports',
            'general.force_sla_configuration',
            'general.instant_reports',
            'general.publish_custom_graph',
            'general.publish_to_foreign_groups_custom_graph',
            'icons_and_actions.deployment_status',
        ]

    assert sorted(expected_permissions) == sorted(permission_registry.keys())

    for perm_class in permission_registry.values():
        perm = perm_class()
        assert isinstance(perm.description, six.string_types)
        assert isinstance(perm.title, six.string_types)
        assert isinstance(perm.defaults, list)
Ejemplo n.º 21
0
def test_registered_pages():
    expected_pages = [
        'add_bookmark',
        'ajax_cascading_render_painer_parameters',
        'ajax_activation_state',
        'ajax_add_visual',
        'ajax_autocomplete_labels',
        'ajax_backup_job_state',
        'ajax_dashlet_pos',
        'ajax_delete_user_notification',
        'ajax_dict_host_tag_condition_get_choice',
        'ajax_inv_render_tree',
        'ajax_nagvis_maps_snapin',
        'ajax_popup_action_menu',
        'ajax_popup_add_visual',
        'ajax_popup_icon_selector',
        'ajax_popup_move_to_folder',
        'ajax_reschedule',
        'ajax_search',
        'ajax_service_discovery',
        'ajax_set_foldertree',
        'ajax_set_rowselection',
        'ajax_set_viewoption',
        'ajax_start_activation',
        'ajax_switch_help',
        'ajax_userdb_sync',
        'ajax_visual_filter_list_get_choice',
        'ajax_vs_autocomplete',
        'ajax_fetch_aggregation_data',
        'ajax_save_bi_template_layout',
        'ajax_save_bi_aggregation_layout',
        'ajax_load_bi_template_layout',
        'ajax_load_bi_aggregation_layout',
        'ajax_delete_bi_template_layout',
        'ajax_delete_bi_aggregation_layout',
        'ajax_fetch_topology',
        'ajax_get_all_bi_template_layouts',
        'automation_login',
        'bi',
        'bi_map',
        'bi_debug',
        'bi_render_tree',
        'bi_save_treestate',
        'bi_set_assumption',
        'bookmark_lists',
        'clear_failed_notifications',
        'count_context_button',
        'create_dashboard',
        'create_view',
        'create_view_dashlet',
        'create_view_dashlet_infos',
        'create_link_view_dashlet',
        'create_view_infos',
        'custom_snapins',
        'dashboard',
        'dashboard_dashlet',
        'delete_dashlet',
        'download_agent_output',
        'download_crash_report',
        'edit_bookmark_list',
        'edit_custom_snapin',
        'edit_dashboard',
        'edit_dashboards',
        'edit_dashlet',
        'edit_view',
        'edit_views',
        'export_views',
        'fetch_agent_output',
        'graph_dashlet',
        'crash',
        'host_inv_api',
        'host_service_graph_popup',
        'index',
        'login',
        'logout',
        'logwatch',
        'mobile',
        'mobile_view',
        'noauth:automation',
        'noauth:pnp_template',
        'noauth:run_cron',
        'notify',
        'prediction_graph',
        'parent_child_topology',
        'search_open',
        'side',
        'sidebar_add_snapin',
        'sidebar_ajax_set_snapin_site',
        'sidebar_ajax_speedometer',
        'sidebar_ajax_tag_tree',
        'sidebar_ajax_tag_tree_enter',
        'sidebar_fold',
        'sidebar_get_messages',
        'sidebar_message_read',
        'sidebar_move_snapin',
        'sidebar_openclose',
        'sidebar_snapin',
        'switch_master_state',
        'switch_site',
        'tree_openclose',
        'user_change_pw',
        'user_profile',
        'version',
        'view',
        'wato',
        'wato_ajax_diag_host',
        'wato_ajax_execute_check',
        'wato_ajax_fetch_site_status',
        'wato_ajax_profile_repl',
        'webapi',
        'werk',
    ]

    if not cmk.is_raw_edition():
        expected_pages += [
            'ajax_graph',
            'ajax_graph_hover',
            'ajax_metric_choice',
            'ajax_pagetype_add_element',
            'ajax_popup_add_metric_to_graph',
            'ajax_render_graph_content',
            'ajax_scalar_choice',
            'combined_graphs',
            'create_report',
            'custom_graph',
            'custom_graph_design',
            'custom_graphs',
            'download_agent',
            'download_mkp',
            'download_stored_report',
            'edit_custom_graph',
            'edit_forecast_graph',
            'edit_graph_collection',
            'edit_graph_tuning',
            'edit_report',
            'edit_report_content',
            'edit_report_element',
            'edit_report_fixel',
            'edit_reports',
            'edit_sla_configuration',
            'forecast_editor',
            'forecast_graph',
            'forecast_graphs',
            'graph_collection',
            'graph_collections',
            'graph_export',
            'graph_image',
            'graph_tunings',
            'noauth:ajax_graph_images',
            'noauth:deploy_agent',
            'register_agent',
            'report',
            'report_download_preview',
            'report_instant',
            'report_instant_graph_collection',
            'report_scheduler',
            'report_scheduler_edit',
            'report_scheduler_preview',
            'report_store',
            'report_thumbnail',
            'sla_configurations',
            'sla_details',
        ]

    assert sorted(cmk.gui.pages.page_registry.keys()) == sorted(expected_pages)
Ejemplo n.º 22
0
    def _parameter_elements(self):
        elements = _vs_add_common_mail_elements([
            ("elements",
             ListChoice(
                 title=_("Information to be displayed in the email body"),
                 choices=[
                     ("omdsite", _("OMD Site")),
                     ("hosttags", _("Tags of the Host")),
                     ("address", _("IP Address of Host")),
                     ("abstime", _("Absolute Time of Alert")),
                     ("reltime", _("Relative Time of Alert")),
                     ("longoutput", _("Additional Plugin Output")),
                     ("ack_author", _("Acknowledgement Author")),
                     ("ack_comment", _("Acknowledgement Comment")),
                     ("perfdata", _("Performance Data")),
                     ("graph", _("Performance Graphs")),
                     ("notesurl", _("Custom Host/Service Notes URL")),
                     ("context", _("Complete variable list (for testing)")),
                 ],
                 default_value=[
                     "perfdata", "graph", "abstime", "address", "longoutput"
                 ],
             )),
            ("insert_html_section",
             TextAreaUnicode(
                 title=_("Insert HTML section between body and table"),
                 default_value="<HTMLTAG>CONTENT</HTMLTAG>",
                 cols=40,
                 rows="auto",
             )),
            ("url_prefix",
             Transform(CascadingDropdown(
                 title=_("URL prefix for links to Check_MK"),
                 help=
                 _("If you use <b>Automatic HTTP/s</b> the URL prefix for "
                   "host and service links within the notification mail "
                   "is filled automatically. "
                   "If you specify an URL prefix here, then several parts of the "
                   "email body are armed with hyperlinks to your Check_MK GUI. In both cases "
                   "the recipient of the email can directly visit the host or "
                   "service in question in Check_MK. Specify an absolute URL including "
                   "the <tt>.../check_mk/</tt>"),
                 choices=[
                     ("automatic_http", _("Automatic HTTP")),
                     ("automatic_https", _("Automatic HTTPs")),
                     ("manual", _("Specify URL prefix"),
                      TextAscii(
                          regex="^(http|https)://.*/check_mk/$",
                          regex_error=_(
                              "The URL must begin with <tt>http</tt> or "
                              "<tt>https</tt> and end with <tt>/check_mk/</tt>."
                          ),
                          size=64,
                          default_value="http://" + socket.gethostname() +
                          "/" + (config.omd_site() and config.omd_site() + "/"
                                 or "") + "check_mk/",
                      )),
                 ],
                 default_value=html.request.is_ssl_request
                 and "automatic_https" or "automatic_http",
             ),
                       forth=transform_forth_html_mail_url_prefix,
                       back=transform_back_html_mail_url_prefix)),
            ("no_floating_graphs",
             FixedValue(
                 True,
                 title=_("Display graphs among each other"),
                 totext=_("Graphs are shown among each other"),
                 help=
                 _("By default all multiple graphs in emails are displayed floating "
                   "nearby. You can enable this option to show the graphs among each "
                   "other."),
             )),
        ])

        if not cmk.is_raw_edition():
            elements += cmk.gui.cee.plugins.wato.syncsmtp.cee_html_mail_smtp_sync_option  # pylint: disable=no-member

        return elements
Ejemplo n.º 23
0
 def enabled(cls):
     return not cmk.is_raw_edition() and config.liveproxyd_enabled
Ejemplo n.º 24
0
def test_registered_api_call_collections():
    registered_api_actions = (action \
                              for cls in api_call_collection_registry.values()
                              for action in cls().get_api_calls().iterkeys())

    expected_api_actions = [
        'activate_changes',
        'execute_remote_automation',
        'add_contactgroup',
        'add_folder',
        'add_host',
        'add_hostgroup',
        'add_hosts',
        'add_servicegroup',
        'add_users',
        'bulk_discovery_start',
        'bulk_discovery_status',
        'delete_contactgroup',
        'delete_folder',
        'delete_host',
        'delete_hostgroup',
        'delete_hosts',
        'delete_servicegroup',
        'delete_site',
        'delete_users',
        'discover_services',
        'edit_contactgroup',
        'edit_folder',
        'edit_host',
        'edit_hostgroup',
        'edit_hosts',
        'edit_servicegroup',
        'edit_users',
        'get_all_contactgroups',
        'get_all_folders',
        'get_all_hostgroups',
        'get_all_hosts',
        'get_all_servicegroups',
        'get_all_sites',
        'get_all_users',
        'get_bi_aggregations',
        'get_combined_graph_identifications',
        'get_folder',
        'get_graph_annotations',
        'get_graph_recipes',
        'get_host',
        'get_host_names',
        'get_hosttags',
        'get_inventory',
        'get_metrics_of_host',
        'get_ruleset',
        'get_rulesets_info',
        'get_site',
        'get_user_sites',
        'login_site',
        'logout_site',
        'set_all_sites',
        'set_hosttags',
        'set_ruleset',
        'set_site',
    ]

    if not cmk.is_raw_edition():
        expected_api_actions += [
            'bake_agents',
            'get_graph',
            'get_sla',
        ]

    assert sorted(registered_api_actions) == sorted(expected_api_actions)
Ejemplo n.º 25
0
class MainModuleDownloadAgents(MainModule):
    @property
    def mode_or_url(self):
        return "download_agents"

    @property
    def title(self):
        return _("Monitoring Agents")

    @property
    def icon(self):
        return "download_agents"

    @property
    def permission(self):
        return "download_agents"

    @property
    def description(self):
        return _("Downloads the Check_MK monitoring agents")

    @property
    def sort_index(self):
        return 5


# Register the builtin agent download page on the top level of WATO only when the agent bakery
# does not exist (e.g. when using CRE)
if cmk.is_raw_edition():
    main_module_registry.register(MainModuleDownloadAgents)
Ejemplo n.º 26
0
def test_normal_auth(
    wsgi_app,  # type: WebTestAppForCMK
    with_user,
):
    username, password = with_user
    login = wsgi_app.get(
        '/NO_SITE/check_mk/login.py')  # type: webtest.TestResponse
    login.form['_username'] = username
    login.form['_password'] = password
    resp = login.form.submit('_login', index=1)

    assert "Invalid credentials." not in resp.body


@pytest.mark.skipif(cmk.is_raw_edition(),
                    reason="No agent deployment in raw edition")
def test_deploy_agent(wsgi_app):
    response = wsgi_app.get('/NO_SITE/check_mk/deploy_agent.py')
    assert response.body.startswith("Missing or invalid")

    response = wsgi_app.get('/NO_SITE/check_mk/deploy_agent.py?mode=agent')
    assert response.body.startswith("Missing host")


def test_openapi_app(
    wsgi_app,  # type: WebTestAppForCMK
    with_automation_user,
):
    username, secret = with_automation_user
    wsgi_app.set_authorization(('Bearer', username + " " + secret))
Ejemplo n.º 27
0
def has_agent_bakery():
    return not cmk.is_raw_edition()
Ejemplo n.º 28
0
# 10 -> full dump of all variables and command
notification_logging = 15
notification_backlog = 10  # keep the last 10 notification contexts for reference

# Settings for new rule based notifications
enable_rulebased_notifications = False
notification_fallback_email = ""
notification_rules = []  # type: _List[_Dict[str, _Any]]
# Check every 10 seconds for ripe bulks
notification_bulk_interval = 10
notification_plugin_timeout = 60

# Notification Spooling.

# Possible values for notification_spooling
# "off"    - Direct local delivery without spooling
# "local"  - Asynchronous local delivery by notification spooler
# "remote" - Forward to remote site by notification spooler
# "both"   - Asynchronous local delivery plus remote forwarding
# False    - legacy: sync delivery  (and notification_spool_to)
# True     - legacy: async delivery (and notification_spool_to)
if _cmk.is_raw_edition():
    notification_spooling = "off"
else:
    notification_spooling = "local"

# Legacy setting. The spool target is now specified in the
# configuration of the spooler. notification_spool_to has
# the tuple format (remote_host, tcp_port, also_local)
notification_spool_to = None