Пример #1
0
def test_mutex_scan_registry_as_fallback():
    scan_registry = snmp_utils.MutexScanRegistry()

    @scan_registry.as_fallback
    def scan_parrot(oid):
        return bool(oid(".O.I.D"))

    assert scan_parrot(oid_kea)

    scan_registry.register(scan_kea)
    assert not scan_parrot(oid_kea)
Пример #2
0
# Management board checks
MGMT_ONLY = _check_api_utils.MGMT_ONLY  # Use host address/credentials when it's a SNMP HOST
HOST_PRECEDENCE = _check_api_utils.HOST_PRECEDENCE  # Check is only executed for mgmt board (e.g. Managegment Uptime)
HOST_ONLY = _check_api_utils.HOST_ONLY  # Check is only executed for real SNMP host (e.g. interfaces)

host_name = _check_api_utils.host_name
service_description = _check_api_utils.service_description
check_type = _check_api_utils.check_type

from cmk.base.discovered_labels import (  # pylint: disable=unused-import
    DiscoveredServiceLabels as ServiceLabels, ServiceLabel,
    DiscoveredHostLabels as HostLabels, HostLabel,
)
Service = _check_api_utils.Service

network_interface_scan_registry = _snmp_utils.MutexScanRegistry()


def saveint(i):
    # type: (Any) -> int
    """Tries to cast a string to an integer and return it. In case this
    fails, it returns 0.

    Advice: Please don't use this function in new code. It is understood as
    bad style these days, because in case you get 0 back from this function,
    you can not know whether it is really 0 or something went wrong."""
    try:
        return int(i)
    except (TypeError, ValueError):
        return 0
Пример #3
0
def test_mutex_scan_registry_register():
    scan_registry = snmp_utils.MutexScanRegistry()

    assert not scan_registry._is_specific(oid_kea)
    assert scan_kea is scan_registry.register(scan_kea)
    assert scan_registry._is_specific(oid_kea)