Пример #1
0
    ["5", "2", "4", "4", "0"],
    ["111001", "0", "5", "5", "0"],
    ["111002", "0", "6", "6", "1"],
    ["111003", "0", "0", "5", "0"],
    ["111004", "1", "4", "5", "0"],
    ["111005", "2", "4", "5", "0"],
]


@pytest.mark.parametrize(
    "string_table, result",
    [
        (
            DATA,
            [
                Service(item="000001"),
                Service(item="000002"),
                Service(item="000003"),
                Service(item="000004"),
                Service(item="000005"),
                Service(item="111001"),
                Service(item="111002"),
                Service(item="111003"),
                Service(item="111004"),
                Service(item="111005"),
            ],
        ),
    ],
)
def test_discover_aruba_fan_status(
    string_table: StringTable,
Пример #2
0
    ],
)
def test_parse_cisco_wlc(string_table, expected_parsed_data):
    assert parse_cisco_wlc(string_table) == expected_parsed_data


@pytest.mark.parametrize(
    "section,services",
    [
        (
            {
                "AP19": "1",
                "AP02": "1"
            },
            [
                Service(item="AP19"),
                Service(item="AP02"),
            ],
        ),
    ],
)
def test_discovery_cisco_wlc(section, services):
    assert list(discovery_cisco_wlc(section)) == services


@pytest.mark.parametrize(
    "item,params,section,results",
    [
        (
            "AP19",
            {},
Пример #3
0
     [u'26', u'137690798', u'94151631', u'bulk_count'],
     [u'28', u'9280', u'8044', u'bulk_count'],
     [u'30', u'0', u'0', u'large_rawcount'],
     [u'32', u'0', u'0', u'large_rawcount'],
     [u'34', u'0', u'0', u'large_rawcount'],
     [u'1086', u'0', u'0', u'large_rawcount'],
     [u'1088', u'0', u'0', u'large_rawcount'],
     [u'1090', u'0', u'0', u'bulk_count'],
     [u'1092', u'0', u'0', u'bulk_count'],
     [u'1094', u'0', u'0', u'large_rawcount'],
 ],
 [
     Service(
         item='1',
         parameters={
             'discovered_oper_status': ['1'],
             'discovered_speed': 10000000000,
         },
     ),
     Service(
         item='2',
         parameters={
             'discovered_oper_status': ['1'],
             'discovered_speed': 10000000000,
         },
     ),
 ],
 [
     (
         '1',
         {
Пример #4
0
    "params, expected_result",
    (
        pytest.param(
            {
                "states_discover": [
                    "Alert",
                    "Ignored",
                    "No Data",
                    "OK",
                    "Skipped",
                    "Unknown",
                    "Warn",
                ],
            },
            [
                Service(item="[Auto] Clock in sync with NTP"),
                Service(item="[SLO] Article Delta Update Device Delay"),
                Service(
                    item="staging | IDM Gateway Service | Import Error Rate"),
            ],
            id="no custom discovery params",
        ),
        pytest.param(
            {
                "states_discover": [],
            },
            [],
            id="custom discovery params",
        ),
    ),
)
Пример #5
0
        string_table)
    assert parsed_section == expected


@pytest.mark.parametrize("section, expected", [
    ({}, []),
    ({
        ITEM: {
            'dgstate': 'UNKNOW-DG-STATE'
        }
    }, []),
    ({
        ITEM: {
            'dgstate': 'MOUNTED'
        }
    }, [Service(item=ITEM)]),
    ({
        ITEM: {
            'dgstate': 'DISMOUNTED'
        }
    }, [Service(item=ITEM)]),
])
def test_discovery(section, expected):
    yielded_services = list(
        oracle_asm_diskgroup.discovery_oracle_asm_diskgroup(section))
    assert yielded_services == expected


@pytest.mark.parametrize(
    "section, params, expected",
    [
Пример #6
0
        Result(
            state=state.OK,
            notice='Operational state: up',
        ),
        Result(
            state=state.OK,
            notice=members,
        )
    ] + results[2:]


DEFAULT_DISCOVERY_PARAMS = type_defs.Parameters(interfaces.DISCOVERY_DEFAULT_PARAMETERS)

SINGLE_SERVICES = [
    Service(item='5', parameters={
        'discovered_oper_status': ['1'],
        'discovered_speed': 10000000
    }),
    Service(item='6', parameters={
        'discovered_oper_status': ['1'],
        'discovered_speed': 0
    }),
]


def test_discovery_ungrouped_all():
    assert list(interfaces.discover_interfaces(
        [DEFAULT_DISCOVERY_PARAMS],
        _create_interfaces(0),
    )) == SINGLE_SERVICES

Пример #7
0
def discover_single(section: Section) -> DiscoveryResult:
    yield Service()
Пример #8
0
    State,
)
from cmk.base.plugins.agent_based import phion_service


@pytest.mark.parametrize('string_table, result', [
    ([], {}),
    ([['BFW1_ACS', '1']], {'BFW1_ACS': 1}),
])
def test_parse_phion_service(string_table, result):
    assert phion_service.parse_phion_service(string_table) == result


@pytest.mark.parametrize('section, result', [
    ({}, []),
    ({'BFW1_ACS': 1}, [Service(item='BFW1_ACS')]),
])
def test_discovery_phion_service(section, result):
    assert list(phion_service.discovery_phion_service(section)) == result


@pytest.mark.parametrize('item, section, result', [
    (
        'FOO',
        {'BFW1_ACS': 1},
        []
    ),
    (
        'BFW1_ACS',
        {'BFW1_ACS': 1},
        [
Пример #9
0
def discovery_kube_cluster_info(section: ClusterInfo) -> DiscoveryResult:
    yield Service()
Пример #10
0
        "match": r"~/omd/sites/\w+/lib/cmc/checkhelper",
        "descr": "Checkhelpers Overall",
        "user": None,
    },
    {},
]

PS_DISCOVERED_ITEMS = [
    Service(
        item="emacs on",
        parameters={
            "cpu_average": 15,
            "cpu_rescale_max": True,
            "resident_levels_perc": (25.0, 50.0),
            "process": "emacs",
            "icon": "emacs.png",
            "user": "******",
            "process_info": "html",
            "virtual_levels": (1024**3, 2 * 1024**3),
            "resident_levels": (1024**3, 2 * 1024**3),
            "match_groups": (),
            "cgroup": (None, False),
        },
    ),
    Service(
        item="firefox is on fire",
        parameters={
            "process": "~.*(fire)fox",
            "process_info": "text",
            "user": None,
            "cpu_rescale_max": "cpu_rescale_max_unspecified",
            "match_groups": ("fire", ),
Пример #11
0
def test_subset_patterns():

    section_ps = ps_section.parse_ps(
        splitter("""(user,0,0,0.5) main
(user,0,0,0.4) main_dev
(user,0,0,0.1) main_dev
(user,0,0,0.5) main_test"""))

    # Boundary in match is necessary otherwise main instance accumulates all
    inv_params: List[Dict] = [
        {
            "default_params": {
                "cpu_rescale_max": True,
                "levels": (1, 1, 99999, 99999)
            },
            "match": "~(main.*)\\b",
            "descr": "%s",
        },
        {},
    ]

    discovered = [
        Service(
            item="main",
            parameters={
                "cpu_rescale_max": True,
                "levels": (1, 1, 99999, 99999),
                "process": "~(main.*)\\b",
                "match_groups": ("main", ),
                "user": None,
                "cgroup": (None, False),
            },
        ),
        Service(
            item="main_dev",
            parameters={
                "cpu_rescale_max": True,
                "levels": (1, 1, 99999, 99999),
                "process": "~(main.*)\\b",
                "match_groups": ("main_dev", ),
                "user": None,
                "cgroup": (None, False),
            },
        ),
        Service(
            item="main_test",
            parameters={
                "cpu_rescale_max": True,
                "levels": (1, 1, 99999, 99999),
                "process": "~(main.*)\\b",
                "match_groups": ("main_test", ),
                "user": None,
                "cgroup": (None, False),
            },
        ),
    ]

    test_discovered = ps_utils.discover_ps(inv_params, section_ps, None, None,
                                           None)  # type: ignore[arg-type]
    assert {s.item: s
            for s in test_discovered} == {s.item: s
                                          for s in discovered
                                          }  # type: ignore[attr-defined]

    for service, count in zip(discovered, [1, 2, 1]):
        assert isinstance(service.item, str)
        output = list(
            ps_utils.check_ps_common(
                label="Processes",
                item=service.item,
                params=service.parameters,  # type: ignore[arg-type]
                process_lines=[(None, psi, cmd_line)
                               for (psi, cmd_line) in section_ps[1]],
                cpu_cores=1,
                total_ram_map={},
            ))
        assert output[0] == Result(state=state.OK,
                                   summary="Processes: %s" % count)
def test_discover_docker_container_status_health():
    _test_discovery(
        docker.discover_docker_container_status_health,
        PARSED,
        [Service()],
    )
def test_discovery_docker_container_status():
    _test_discovery(
        docker.discover_docker_container_status,
        PARSED,
        [Service(item=None, parameters={}, labels=[])],
    )
def test_check_docker_container_status():
    expected_results = [Result(state=state.OK, summary="Container running")]
    assert list(docker.check_docker_container_status(PARSED)) == expected_results


@pytest.mark.parametrize(
    "section_uptime, expected_services",
    [
        (
            uptime.Section(123456789, None),
            [],
        ),
        (
            {},
            [
                Service(item=None, parameters={}, labels=[]),
            ],
        ),
    ],
)
def test_discovery_docker_container_status_uptime(section_uptime, expected_services):
    _test_discovery(
        lambda parsed: docker.discover_docker_container_status_uptime(parsed, section_uptime),
        PARSED,
        expected_services,
    )


@pytest.mark.parametrize(
    "params, expected_results",
    [
Пример #15
0
from cmk.base.plugins.agent_based.agent_based_api.v1 import Metric, Result, Service, State, TableRow
from cmk.base.plugins.agent_based.k8s_roles import inventory_k8s_roles
from cmk.base.plugins.agent_based.utils.k8s import parse_json

_AGENT_OUTPUT = [
    [
        '{"roles": [{"creation_timestamp": 1538034890.0, "namespace": "kube-public", "name": "kubeadm:bootstrap-signer-clusterinfo"}, {"creation_timestamp": 1538034889.0, "namespace": "kube-public", "name": "system:controller:bootstrap-signer"}, {"creation_timestamp": 1538034888.0, "namespace": "kube-system", "name": "extension-apiserver-authentication-reader"}, {"creation_timestamp": 1538034889.0, "namespace": "kube-system", "name": "system::leader-locking-kube-controller-manager"}, {"creation_timestamp": 1538034889.0, "namespace": "kube-system", "name": "system::leader-locking-kube-scheduler"}, {"creation_timestamp": 1538034888.0, "namespace": "kube-system", "name": "system:controller:bootstrap-signer"}, {"creation_timestamp": 1538034889.0, "namespace": "kube-system", "name": "system:controller:cloud-provider"}, {"creation_timestamp": 1538034889.0, "namespace": "kube-system", "name": "system:controller:token-cleaner"}], "cluster_roles": [{"creation_timestamp": 1538034887.0, "namespace": null, "name": "admin"}, {"creation_timestamp": 1539699586.0, "namespace": null, "name": "check-mk"}, {"creation_timestamp": 1538034883.0, "namespace": null, "name": "cluster-admin"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "edit"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:aggregate-to-admin"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:aggregate-to-edit"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:aggregate-to-view"}, {"creation_timestamp": 1544712904.0, "namespace": null, "name": "system:aggregated-metrics-reader"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:auth-delegator"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:aws-cloud-provider"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:basic-user"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:certificates.k8s.io:certificatesigningrequests:nodeclient"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:certificates.k8s.io:certificatesigningrequests:selfnodeclient"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:attachdetach-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:certificate-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:clusterrole-aggregation-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:cronjob-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:daemon-set-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:deployment-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:disruption-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:endpoint-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:generic-garbage-collector"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:horizontal-pod-autoscaler"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:job-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:namespace-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:node-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:persistent-volume-binder"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:pod-garbage-collector"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:pv-protection-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:pvc-protection-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:replicaset-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:replication-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:resourcequota-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:route-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:service-account-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:service-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:statefulset-controller"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:controller:ttl-controller"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:discovery"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:heapster"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:kube-aggregator"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:kube-controller-manager"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:kube-dns"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:kube-scheduler"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:kubelet-api-admin"}, {"creation_timestamp": 1544712904.0, "namespace": null, "name": "system:metrics-server"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:node"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:node-bootstrapper"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:node-problem-detector"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:node-proxier"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "system:persistent-volume-provisioner"}, {"creation_timestamp": 1538034888.0, "namespace": null, "name": "system:volume-scheduler"}, {"creation_timestamp": 1538034887.0, "namespace": null, "name": "view"}]}'
    ],
]


@pytest.mark.parametrize(
    "string_table, expected_result",
    [
        (_AGENT_OUTPUT, [Service()]),
    ],
)
def test_discover_k8s_roles(fix_register, string_table, expected_result):
    check_plugin = fix_register.check_plugins[CheckPluginName("k8s_roles")]
    section = parse_json(string_table)
    assert sorted(check_plugin.discovery_function(section)) == expected_result


@pytest.mark.parametrize(
    "string_table, expected_result",
    [
        (
            _AGENT_OUTPUT,
            [
                Result(state=State.OK, summary="Total: 61"),
Пример #16
0
        'Unit Operating State Reason': 'Reason Unknown',
    }),
])
def test_parse_liebert_system(string_table, result):
    parsed = parse_liebert_system(string_table)
    assert parsed == result


@pytest.mark.parametrize(
    'section, result',
    [({
        'System Model Number': 'Liebert CRV',
        'System Status': 'Normal Operation',
        'Unit Operating State': 'standby',
        'Unit Operating State Reason': 'Reason Unknown',
    }, [Service(item='Liebert CRV')]),
     (
         {
             'System Model Number': 'Liebert CRV',
             'System Status': 'Normal Operation',
             'Unit Operating State': 'on',
             'Unit Operating State Reason': 'Reason Unknown',
         },
         [Service(item='Liebert CRV')],
     )])
def test_discover_liebert_system(section, result):
    discovered = list(discover_liebert_system(section))
    assert discovered == result


@pytest.mark.parametrize('section, result', [
Пример #17
0
                    'rx_bytes': 6657123557,
                    'tx_bytes': 59168669231,
                    'rx_dropped': 0,
                    'tx_dropped': 0
                }]
            },
            'timestamp': 1550235205.3
        },
        id="1"),
])
def test_parse_k8s(string_table, expected_parsed_data):
    assert parse_k8s([[string_table]]) == expected_parsed_data


@pytest.mark.parametrize("section,expected_items", [
    (parsed_data, [Service(item="/dev/sda1")]),
])
def test_discover_k8s_stats_fs(section, expected_items):
    assert list(discover_k8s_stats_fs(section)) == expected_items


@pytest.mark.parametrize("section,expected_items", [
    (parsed_data, [Service(item='eth1'),
                   Service(item='eth0'),
                   Service(item='sit0')]),
])
def test_discover_k8s_stats_network(section, expected_items):
    assert list(discover_k8s_stats_network(section, None)) == expected_items


@pytest.mark.parametrize("section,expected_results", [(parsed_data, [
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import pytest  # type: ignore[import]
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
    Metric,
    Result,
    Service,
    State,
)
from cmk.base.plugins.agent_based import dell_storage_agent


@pytest.mark.parametrize('string_table, result', [
    ([], []),
    ([['FooBar']], [Service()]),
])
def test_discovery_dell_storage_agent(string_table, result):
    assert list(dell_storage_agent.discovery_dell_storage_agent(string_table)) == result


@pytest.mark.parametrize('string_table, result', [
    ([['0', 'provider', 'version', '23', '42', '']], Result(state=State.OK, summary='provider vversion')),
    ([['0', 'provider', 'version', '23', '42', '']], Metric('request', 42.0)),
    ([['0', 'provider', 'version', '23', '42', '']], Metric('time', 23)),
    ([['1', '', '', '23', '', 'Yolo']], Result(state=State.CRIT, summary='Exception: Yolo')),
])
def test_check_dell_storage_agent(string_table, result):
    assert result in list(dell_storage_agent.check_dell_storage_agent(string_table))
Пример #19
0
    assert data == expected_parsed


@pytest.mark.parametrize("info, expected_result", [(
    [[
        "https_t3test.tgic.de", "FRONTEND", "", "", "0", "0", "2000", "0", "0", "0", "0", "0", "0",
        "", "", "", "", "UP", "", "", "", "", "", "", "", "", "1", "2", "0", "", "", "", "0", "0",
        "0", "0", "", "", "", "0", "0", "0", "0", "0", "0", "", "0", "0", "0", "", ""
    ],
     [
         "t3test", "t3test", "0", "0", "0", "0", "", "0", "0", "0", "", "0", "", "0", "0", "0", "0",
         "UP", "1", "1", "0", "0", "0", "363417", "0", "", "1", "3", "1", "", "0", "", "2", "0", "",
         "0", "L4OK", "", "0", "0", "0", "0", "0", "0", "0", "0", "", "", "", "0", "0", "", "", "",
         "", "-1", "", "", "0", "0", "0", "0", ""
     ]],
    [Service(item="https_t3test.tgic.de")],
)])
def test_discover_haproxy_frontent(info, expected_result):
    data = parse_haproxy(info)
    result = discover_haproxy_frontend(data)
    assert list(result) == expected_result


@pytest.mark.parametrize("item, params, info, expected_result", [
    (
        "https_t3test.tgic.de",
        {
            "OPEN": 0
        },
        [[
            "# pxname", "svname", "qcur", "qmax", "scur", "smax", "slim", "stot", "bin", "bout",
def test_discovery_fast_lta_silent_cube_capacity(
        discover_fast_lta_silent_cubes_capacity) -> None:
    assert list(discover_fast_lta_silent_cubes_capacity(info)) == [
        Service(item="Total")
    ]
Пример #21
0
    ["MSSQL_SQL2005MT02", "config", "9.0.2000.5", "Standard Edition", ""],
    ["MSSQL_SQL2005MT02", "state", "1", ""],
    ["MSSQL_SQL2005MT02", "details", "9.0.4053.23", "RTM", "Standard Edition (64-bit)"],
    ["MSSQL_SQL2000MT02", "config", "8.0.2000.5", "Standard Edition", ""],
    ["MSSQL_SQL2000MT02", "state", "1", ""],
    ["MSSQL_SQL2000MT02", "details", "8.0.4053.23", "RTM", "Standard Edition (64-bit)"],
]


@pytest.mark.parametrize(
    "string_table, expected_result",
    [
        (
            _AGENT_OUTPUT_1,
            [
                Service(item="ABC"),
                Service(item="ABCDEV"),
                Service(item="MSSQLSERVER"),
            ],
        ),
        (
            _AGENT_OUTPUT_2,
            [
                Service(item="SQL2000MT02"),
                Service(item="SQL2005MT02"),
                Service(item="SQL2008MT02"),
                Service(item="SQL2008R2MT02"),
                Service(item="SQL2012MT02"),
                Service(item="SQL2014MT02"),
                Service(item="SQL2016MT02"),
                Service(item="SQL2017MT02"),
Пример #22
0
def discovery_cisco_asa_failover(section: Section) -> DiscoveryResult:
    yield Service()
Пример #23
0
        )) == results)


@pytest.mark.parametrize(
    "section_aws_route53_health_checks, section_aws_route53_cloudwatch, results",
    [
        (
            None,
            None,
            [],
        ),
        (
            SECTION_AWS_ROUTE53_HEALTH_CHECK,
            SECTION_AWS_ROUTE53_CLOUDWATCH,
            [
                Service(item="1756ee96-de4f-4137-b7c3-c9daab1c4a9f"),
                Service(item="4f101cb3-ee16-490b-a49d-a354957c315f"),
                Service(item="ad21015b-1502-4dfd-a48a-e9cd4d66bc3b"),
            ],
        ),
    ],
)
def test_discover_aws_route53(
    section_aws_route53_health_checks: Optional[Route53HealthCheckSection],
    section_aws_route53_cloudwatch: Optional[Route53CloudwatchSection],
    results: DiscoveryResult,
) -> None:
    assert (list(
        discover_aws_route53(
            section_aws_route53_health_checks,
            section_aws_route53_cloudwatch,
Пример #24
0
    ["[[[log4:cannotopen]]]"],
    ["[[[log5]]]"],
]


@pytest.mark.parametrize(
    "info, fwd_rule, expected_result",
    [
        (INFO1, [], []),
        (
            INFO1,
            [{
                "separate_checks": True
            }],
            [
                Service(item="log1",
                        parameters={"expected_logfiles": ["log1"]}),
                Service(item="log2",
                        parameters={"expected_logfiles": ["log2"]}),
                Service(item="log5",
                        parameters={"expected_logfiles": ["log5"]}),
            ],
        ),
        (INFO1, [{
            "restrict_logfiles": [".*"]
        }], []),
        (
            INFO1,
            [{
                "restrict_logfiles": [".*"],
                "separate_checks": True,
            }],
Пример #25
0
def discover_apache_status(section: Section) -> DiscoveryResult:
    for item in section:
        yield Service(item=item)
Пример #26
0
def discovery_kube_namespace_info(section: NamespaceInfo) -> DiscoveryResult:
    yield Service()
@pytest.mark.parametrize(
    "section_aws_lambda_summary, section_aws_lambda, section_aws_lambda_cloudwatch_insights, results",
    [
        (
            None,
            None,
            None,
            [],
        ),
        (
            SECTION_AWS_LAMBDA_SUMMARY,
            _SECTION_AWS_LAMBDA,
            SECTION_AWS_LAMBDA_CLOUDWATCH_INSIGHTS,
            [
                Service(item="eu-central-1 calling_other_lambda_concurrently"),
                Service(item="eu-central-1 my_python_test_function"),
                Service(item="eu-north-1 myLambdaTestFunction"),
            ],
        ),
    ],
)
def test_discover_aws_lambda(
    section_aws_lambda_summary: Optional[LambdaSummarySection],
    section_aws_lambda: Optional[LambdaCloudwatchSection],
    section_aws_lambda_cloudwatch_insights: Optional[CloudwatchInsightsSection],
    results: DiscoveryResult,
) -> None:
    assert (
        list(
            discover_aws_lambda(
Пример #28
0
    'sys-temp': ('working', 'SYS_TEMP: +34.00 C'),
    'cpu-usage': ('working', 'CPU Usage: 5%'),
    'swap-usage': ('working', '0% - System swap space usage is OK.'),
    'discovery-capacity': ('working', '0% - Discovery capacity usage is OK.'),
}


@pytest.mark.parametrize("string_table,expected_parsed_data", [
    (example_snmp_string_table, example_parsed_data),
])
def test_parse_infoblox_services(string_table, expected_parsed_data):
    assert parse_infoblox_services(string_table) == expected_parsed_data


@pytest.mark.parametrize("section,result", [
    (example_parsed_data, [Service(item=key) for key in example_parsed_data]),
])
def test_discovery_infoblox_services(section, result):
    assert list(discovery_infoblox_services(section)) == result


@pytest.mark.parametrize("item,section,result", [
    ("memory", example_parsed_data, [
        Result(state=state.OK,
               summary='Status: working (14% - System memory usage is OK.)')
    ]),
])
def test_check_infoblox_services(item, section, result):
    assert list(check_infoblox_services(item, section)) == result

Пример #29
0
def test_winperf_if_inventory_teaming():
    assert list(
        winperf_if.discover_winperf_if(
            [
                type_defs.Parameters({
                    **interfaces.DISCOVERY_DEFAULT_PARAMETERS,
                    'discovery_single': (
                        True,
                        {
                            'item_appearance': 'descr',
                            'pad_portnumbers': True,
                        },
                    ),
                })
            ],
            winperf_if.parse_winperf_if([
                [u'1542018413.59', u'510', u'2341040'],
                [
                    u'4',
                    u'instances:',
                    u'HPE_Ethernet_1Gb_4-port_331i_Adapter__3',
                    u'HPE_Ethernet_1Gb_4-port_331i_Adapter__4',
                    u'HPE_Ethernet_1Gb_4-port_331i_Adapter',
                    u'HPE_Ethernet_1Gb_4-port_331i_Adapter__2',
                ],
                [
                    u'-122', u'201612106', u'187232778', u'200985680546908',
                    u'969308895925', u'bulk_count'
                ],
                [
                    u'-110', u'2938459', u'2713782', u'141023109713',
                    u'7143818358', u'bulk_count'
                ],
                [
                    u'-244', u'2920458', u'2695781', u'133889346630',
                    u'9159143', u'bulk_count'
                ],
                [
                    u'-58', u'18001', u'18001', u'7133763083', u'7134659215',
                    u'bulk_count'
                ],
                [
                    u'10', u'1000000000', u'1000000000', u'1000000000',
                    u'1000000000', u'large_rawcount'
                ],
                [
                    u'-246', u'189182492', u'174803164', u'200050287945665',
                    u'730174911', u'bulk_count'
                ],
                [u'14', u'0', u'0', u'133879714188', u'131929', u'bulk_count'],
                [
                    u'16', u'2920458', u'2695781', u'8946694', u'9027210',
                    u'bulk_count'
                ],
                [u'18', u'0', u'0', u'685748', u'4', u'large_rawcount'],
                [u'20', u'0', u'0', u'0', u'0', u'large_rawcount'],
                [u'22', u'0', u'0', u'0', u'0', u'large_rawcount'],
                [
                    u'-4', u'12429614', u'12429614', u'935392601243',
                    u'968578721014', u'bulk_count'
                ],
                [
                    u'26', u'0', u'0', u'7133594582', u'7134655376',
                    u'bulk_count'
                ],
                [u'28', u'18001', u'18001', u'168501', u'3839', u'bulk_count'],
                [u'30', u'0', u'0', u'0', u'0', u'large_rawcount'],
                [u'32', u'0', u'0', u'0', u'0', u'large_rawcount'],
                [u'34', u'0', u'0', u'0', u'0', u'large_rawcount'],
                [u'1086', u'0', u'0', u'0', u'0', u'large_rawcount'],
                [u'1088', u'0', u'0', u'0', u'0', u'large_rawcount'],
                [u'1090', u'0', u'0', u'0', u'0', u'bulk_count'],
                [u'1092', u'0', u'0', u'0', u'0', u'bulk_count'],
                [u'1094', u'0', u'0', u'0', u'0', u'large_rawcount'],
                [u'[teaming_start]'],
                [
                    u'TeamName', u'TeamingMode', u'LoadBalancingAlgorithm',
                    u'MemberMACAddresses', u'MemberNames',
                    u'MemberDescriptions', u'Speed', u'GUID'
                ],
                [
                    u'LAN ', u'SwitchIndependent ', u'Dynamic ',
                    u'38:63:BB:44:D0:24;38:63:BB:44:D0:25', u'nic1;nic2',
                    u'HPE Ethernet 1Gb 4-port 331i Adapter;HPE Ethernet 1Gb 4-port 331i Adapter #2',
                    u'1000000000;1000000000',
                    u'{4DA62AA0-8163-459C-9ACE-95B1E729A7DD};{FEF2305A-57FD-4AEC-A817-C082565B6AA7}'
                ],
                [u'[teaming_end]'],
                [
                    u'Node', u'MACAddress', u'Name', u'NetConnectionID',
                    u'NetConnectionStatus', u'Speed', u'GUID'
                ],
                [
                    u'S5EXVM318 ', u' 38:63:BB:44:D0:26 ',
                    u' HPE Ethernet 1Gb 4-port 331i Adapter #3 ',
                    u' nic3-vl302 ', u' 2 ', u' 1000000000 ',
                    u' {5FBD3455-980D-4AD6-BDEE-79B42B7BBDBC}'
                ],
                [
                    u'S5EXVM318 ', u' 38:63:BB:44:D0:27 ',
                    u' HPE Ethernet 1Gb 4-port 331i Adapter #4 ',
                    u' nic4-vl303 ', u' 2 ', u' 1000000000 ',
                    u' {8A1D9DD0-DF30-46CD-87FC-ACB13A5AB2BA}'
                ],
                [
                    u'S5EXVM318 ', u' 38:63:BB:44:D0:24 ',
                    u' HPE Ethernet 1Gb 4-port 331i Adapter ', u' nic1 ',
                    u' 2 ', u'  ', u' {4DA62AA0-8163-459C-9ACE-95B1E729A7DD}'
                ],
                [
                    u'S5EXVM318 ', u' 38:63:BB:44:D0:25 ',
                    u' HPE Ethernet 1Gb 4-port 331i Adapter ', u' nic2 ',
                    u' 2 ', u'  ', u' {FEF2305A-57FD-4AEC-A817-C082565B6AA7}'
                ],
                [
                    u'S5EXVM318 ', u' 38:63:BB:44:D0:24 ',
                    u' Microsoft Network Adapter Multiplexor Driver ',
                    u' LAN ', u' 2 ', u' 2000000000 ',
                    u' {69DCC9F6-FD98-474C-87F8-DD1023C6117C}'
                ],
            ]),
        )) == [
            Service(
                item='HPE Ethernet 1Gb 4-port 331i Adapter 3',
                parameters={
                    'discovered_oper_status': ['1'],
                    'discovered_speed': 1000000000
                },
            ),
            Service(
                item='HPE Ethernet 1Gb 4-port 331i Adapter 4',
                parameters={
                    'discovered_oper_status': ['1'],
                    'discovered_speed': 1000000000
                },
            ),
            Service(
                item='HPE Ethernet 1Gb 4-port 331i Adapter',
                parameters={
                    'discovered_oper_status': ['1'],
                    'discovered_speed': 1000000000
                },
            ),
            Service(
                item='HPE Ethernet 1Gb 4-port 331i Adapter 2',
                parameters={
                    'discovered_oper_status': ['1'],
                    'discovered_speed': 1000000000
                },
            ),
            Service(
                item='LAN',
                parameters={
                    'aggregate': {
                        'member_appearance': 'descr'
                    },
                    'discovered_oper_status': ['1'],
                    'discovered_speed': 2000000000.0
                },
            ),
        ]
Пример #30
0
def discovery(section: PodConditions) -> DiscoveryResult:
    yield Service()