Пример #1
0
def cache_oids(backend):
    # Cache OIDs to avoid actual SNMP I/O.
    snmp_cache.initialize_single_oid_cache(backend.config)
    snmp_cache.set_single_oid_cache(snmp_scan.OID_SYS_DESCR, "sys description")
    snmp_cache.set_single_oid_cache(snmp_scan.OID_SYS_OBJ, "sys object")
    yield
    snmp_cache._clear_other_hosts_oid_cache(backend.hostname)
Пример #2
0
def _snmp_scan(
    sections: Iterable[SNMPScanSection],
    on_error: str = "ignore",
    do_snmp_scan: bool = True,
    *,
    binary_host: bool,
    backend: ABCSNMPBackend,
) -> Set[SectionName]:
    snmp_cache.initialize_single_oid_cache(backend.config)
    console.vverbose("  SNMP scan:\n")
    _snmp_scan_cache_description(
        binary_host=binary_host,
        do_snmp_scan=do_snmp_scan,
        backend=backend,
    )

    found_sections = _snmp_scan_find_sections(
        sections,
        do_snmp_scan=do_snmp_scan,
        on_error=on_error,
        backend=backend,
    )
    _output_snmp_check_plugins("SNMP scan found", found_sections)
    snmp_cache.write_single_oid_cache(backend.config)
    return found_sections
Пример #3
0
def _snmp_scan(
    sections: Iterable[SNMPScanSection],
    on_error: str = "ignore",
    *,
    missing_sys_description: bool,
    backend: ABCSNMPBackend,
) -> Set[SectionName]:
    snmp_cache.initialize_single_oid_cache(backend.config)
    console.vverbose("  SNMP scan:\n")

    if missing_sys_description:
        _fake_description_object()
    else:
        _prefetch_description_object(backend=backend)

    found_sections = _find_sections(
        sections,
        on_error=on_error,
        backend=backend,
    )
    _output_snmp_check_plugins("SNMP scan found", found_sections)
    snmp_cache.write_single_oid_cache(backend.config)
    return found_sections