Пример #1
0
 def store(self):
     return SNMPPluginStore({
         SectionName("section0"): SNMPPluginStoreItem(
             [
                 BackendSNMPTree(base=".1.2.3",
                                 oids=[
                                     BackendOIDSpec("4.5", "string", False),
                                     BackendOIDSpec("9.7", "string", False)
                                 ]),
                 BackendSNMPTree(base=".8.9.0",
                                 oids=[
                                     BackendOIDSpec("1.2", "string", False),
                                     BackendOIDSpec("3.4", "string", False)
                                 ]),
             ],
             SNMPDetectSpec([[
                 ("oid0", "regex0", True),
                 ("oid1", "regex1", True),
                 ("oid2", "regex2", False),
             ]]),
         ),
         SectionName("section1"): SNMPPluginStoreItem(
             [
                 BackendSNMPTree(base=".1.2.3",
                                 oids=[
                                     BackendOIDSpec("4.5", "string", False),
                                     BackendOIDSpec("6.7.8", "string", False)
                                 ])
             ],
             SNMPDetectSpec([[
                 ("oid3", "regex3", True),
                 ("oid4", "regex4", False),
             ]]),
         ),
     })
Пример #2
0
 def fetcher_fixture(self, file_cache):
     SNMPFetcher.snmp_plugin_store = SNMPPluginStore({
         SectionName("pim"): SNMPPluginStoreItem(
             trees=[
                 BackendSNMPTree(base=".1.1.1",
                                 oids=[
                                     BackendOIDSpec("1.2", "string", False),
                                     BackendOIDSpec("3.4", "string", False)
                                 ])
             ],
             detect_spec=SNMPDetectSpec([[("1.2.3.4", "pim device", True)]]),
         ),
         SectionName("pam"): SNMPPluginStoreItem(
             trees=[
                 BackendSNMPTree(
                     base=".1.2.3",
                     oids=[
                         BackendOIDSpec("4.5", "string", False),
                         BackendOIDSpec("6.7", "string", False),
                         BackendOIDSpec("8.9", "string", False)
                     ],
                 ),
             ],
             detect_spec=SNMPDetectSpec([[("1.2.3.4", "pam device", True)]]),
         ),
         SectionName("pum"): SNMPPluginStoreItem(
             trees=[
                 BackendSNMPTree(base=".2.2.2", oids=[BackendOIDSpec("2.2", "string", False)]),
                 BackendSNMPTree(base=".3.3.3", oids=[BackendOIDSpec("2.2", "string", False)]),
             ],
             detect_spec=SNMPDetectSpec([[]]),
         ),
     })
     return SNMPFetcher(
         file_cache,
         disabled_sections=set(),
         configured_snmp_sections=set(),
         inventory_snmp_sections=set(),
         on_error="raise",
         missing_sys_description=False,
         use_snmpwalk_cache=False,
         do_status_data_inventory=False,
         snmp_config=SNMPHostConfig(
             is_ipv6_primary=False,
             hostname="bob",
             ipaddress="1.2.3.4",
             credentials="public",
             port=42,
             is_bulkwalk_host=False,
             is_snmpv2or3_without_bulkwalk_host=False,
             bulk_walk_size_of=0,
             timing={},
             oid_range_limits=[],
             snmpv3_contexts=[],
             character_encoding=None,
             is_usewalk_host=False,
             snmp_backend=SNMPBackend.classic,
         ),
     )
Пример #3
0
 def _make_snmp_plugin_store() -> SNMPPluginStore:
     return SNMPPluginStore({
         s.name: SNMPPluginStoreItem(
             [BackendSNMPTree.from_frontend(base=t.base, oids=t.oids) for t in s.trees],
             SNMPDetectSpec(s.detect_spec))
         for s in agent_based_register.iter_all_snmp_sections()
     })
Пример #4
0
 def snmp_plugin_fixture(self):
     SNMPFetcher.plugin_store = SNMPPluginStore({
         SectionName("pim"):
         SNMPPluginStoreItem(
             trees=[
                 BackendSNMPTree(base=".1.1.1",
                                 oids=[
                                     BackendOIDSpec("1.2", "string", False),
                                     BackendOIDSpec("3.4", "string", False)
                                 ])
             ],
             detect_spec=SNMPDetectSpec([[("1.2.3.4", "pim device", True)]
                                         ]),
             inventory=False,
         ),
         SectionName("pam"):
         SNMPPluginStoreItem(
             trees=[
                 BackendSNMPTree(
                     base=".1.2.3",
                     oids=[
                         BackendOIDSpec("4.5", "string", False),
                         BackendOIDSpec("6.7", "string", False),
                         BackendOIDSpec("8.9", "string", False)
                     ],
                 ),
             ],
             detect_spec=SNMPDetectSpec([[("1.2.3.4", "pam device", True)]
                                         ]),
             inventory=False,
         ),
         SectionName("pum"):
         SNMPPluginStoreItem(
             trees=[
                 BackendSNMPTree(
                     base=".2.2.2",
                     oids=[BackendOIDSpec("2.2", "string", False)]),
                 BackendSNMPTree(
                     base=".3.3.3",
                     oids=[BackendOIDSpec("2.2", "string", False)]),
             ],
             detect_spec=SNMPDetectSpec([[]]),
             inventory=False,
         ),
     })
Пример #5
0
 def _make_fetcher(self) -> SNMPFetcher:
     return SNMPFetcher(
         self._make_file_cache(),
         snmp_plugin_store=SNMPPluginStore({
             s.name: SNMPPluginStoreItem(s.trees, s.detect_spec)
             for s in agent_based_register.iter_all_snmp_sections()
         }),
         disabled_sections=self.host_config.disabled_snmp_sections(),
         configured_snmp_sections=self._make_configured_snmp_sections(),
         inventory_snmp_sections=self._make_inventory_snmp_sections(),
         on_error=self.on_snmp_scan_error,
         missing_sys_description=config.get_config_cache().
         in_binary_hostlist(
             self.snmp_config.hostname,
             config.snmp_without_sys_descr,
         ),
         use_snmpwalk_cache=self.use_snmpwalk_cache,
         do_status_data_inventory=self.host_config.do_status_data_inventory,
         snmp_config=self.snmp_config,
     )