示例#1
0
 def __init__(
     self,
     hostname: HostName,
     ipaddress: Optional[HostAddress],
     *,
     mode: Mode,
 ):
     super().__init__(
         hostname,
         ipaddress,
         mode=mode,
         source_type=SourceType.MANAGEMENT,
         fetcher_type=FetcherType.IPMI,
         description=IPMIConfigurator._make_description(
             ipaddress,
             cast(
                 IPMICredentials,
                 HostConfig.make_host_config(
                     hostname).management_credentials),
         ),
         id_="mgmt_ipmi",
         cpu_tracking_id="mgmt_ipmi",
         main_data_source=False,
     )
     self.credentials: Final[IPMICredentials] = cast(
         IPMICredentials,
         HostConfig.make_host_config(hostname).management_credentials)
示例#2
0
文件: ipmi.py 项目: petrows/checkmk
 def __init__(self, hostname: HostName, ipaddress: Optional[HostAddress]) -> None:
     super().__init__(
         hostname,
         ipaddress,
         source_type=SourceType.MANAGEMENT,
         fetcher_type=FetcherType.IPMI,
         description=IPMISource._make_description(
             ipaddress,
             cast(IPMICredentials,
                  HostConfig.make_host_config(hostname).management_credentials),
         ),
         id_="mgmt_ipmi",
         main_data_source=False,
     )
     self.credentials: Final[IPMICredentials] = self.get_ipmi_credentials(
         HostConfig.make_host_config(hostname))
示例#3
0
    def __init__(
        self,
        hostname: HostName,
        ipaddress: Optional[HostAddress],
        *,
        source_type: SourceType,
        fetcher_type: FetcherType,
        description: str,
        default_raw_data: TRawData,
        default_host_sections: THostSections,
        id_: str,
        cache_dir: Optional[Path] = None,
        persisted_section_dir: Optional[Path] = None,
    ) -> None:
        self.hostname: Final[HostName] = hostname
        self.ipaddress: Final[Optional[str]] = ipaddress
        self.source_type: Final[SourceType] = source_type
        self.fetcher_type: Final[FetcherType] = fetcher_type
        self.description: Final[str] = description
        self.default_raw_data: Final = default_raw_data
        self.default_host_sections: Final[THostSections] = default_host_sections
        self.id: Final[str] = id_
        if not cache_dir:
            cache_dir = Path(cmk.utils.paths.data_source_cache_dir) / self.id
        if not persisted_section_dir:
            persisted_section_dir = Path(cmk.utils.paths.var_dir) / "persisted_sections" / self.id

        self.file_cache_base_path: Final[Path] = cache_dir
        self.file_cache_max_age: int = 0
        self.persisted_sections_file_path: Final[Path] = persisted_section_dir / self.hostname

        self.host_config: Final[HostConfig] = HostConfig.make_host_config(hostname)
        self._logger: Final[logging.Logger] = logging.getLogger("cmk.base.data_source.%s" % id_)

        self.exit_spec = self.host_config.exit_code_spec(id_)
示例#4
0
def make_cluster_sources(
    config_cache: config.ConfigCache,
    host_config: HostConfig,
) -> Sequence[Source]:
    """Abstract clusters/nodes/hosts"""
    assert host_config.nodes is not None

    return [
        source for host_name in host_config.nodes for source in make_sources(
            HostConfig.make_host_config(host_name),
            config.lookup_ip_address(config_cache.get_host_config(host_name)),
            force_snmp_cache_refresh=False,
        )
    ]
示例#5
0
    def __init__(
        self,
        hostname: HostName,
        ipaddress: Optional[HostAddress],
        *,
        mode: Mode,
        source_type: SourceType,
        fetcher_type: FetcherType,
        description: str,
        default_raw_data: TRawData,
        default_host_sections: THostSections,
        id_: str,
        cpu_tracking_id: str,
        cache_dir: Optional[Path] = None,
        persisted_section_dir: Optional[Path] = None,
    ) -> None:
        self.hostname: Final[str] = hostname
        self.ipaddress: Final[Optional[str]] = ipaddress
        self.mode: Final[Mode] = mode
        self.source_type: Final[SourceType] = source_type
        self.fetcher_type: Final[FetcherType] = fetcher_type
        self.description: Final[str] = description
        self.default_raw_data: Final = default_raw_data
        self.default_host_sections: Final[
            THostSections] = default_host_sections
        self.id: Final[str] = id_
        self.cpu_tracking_id: Final[str] = cpu_tracking_id
        if not cache_dir:
            cache_dir = Path(cmk.utils.paths.data_source_cache_dir) / self.id
        if not persisted_section_dir:
            persisted_section_dir = Path(
                cmk.utils.paths.var_dir) / "persisted_sections" / self.id

        self.file_cache = FileCacheConfigurator(
            cache_dir / self.hostname,
            self.fetcher_type,
            simulation=config.simulation_mode,
        )
        self.persisted_sections_file_path: Final[
            Path] = persisted_section_dir / self.hostname
        self.selected_raw_sections: Optional[SelectedRawSections] = None

        self.host_config: Final[HostConfig] = HostConfig.make_host_config(
            hostname)
        self._logger: Final[logging.Logger] = logging.getLogger(
            "cmk.base.data_source.%s" % id_)

        self.exit_code_spec = self.host_config.exit_code_spec(id_)
示例#6
0
def _make_piggyback_nodes(
        config_cache: config.ConfigCache,
        host_config: HostConfig) -> Iterable[Tuple[HostName, Optional[HostAddress], DataSources]]:
    """Abstract clusters/nodes/hosts"""
    assert host_config.nodes is not None

    nodes = []
    for hostname in host_config.nodes:
        node_config = config_cache.get_host_config(hostname)
        ipaddress = ip_lookup.lookup_ip_address(node_config)
        sources = make_sources(
            HostConfig.make_host_config(hostname),
            ipaddress,
        )
        nodes.append((hostname, ipaddress, sources))
    return nodes
示例#7
0
def _make_cluster_nodes(
    config_cache: config.ConfigCache,
    host_config: HostConfig,
) -> Sequence[Tuple[HostName, Optional[HostAddress], Sequence[Source]]]:
    """Abstract clusters/nodes/hosts"""
    assert host_config.nodes is not None

    nodes = []
    for hostname in host_config.nodes:
        node_config = config_cache.get_host_config(hostname)
        ipaddress = config.lookup_ip_address(node_config)
        sources = make_sources(
            HostConfig.make_host_config(hostname),
            ipaddress,
            force_snmp_cache_refresh=False,
        )
        nodes.append((hostname, ipaddress, sources))
    return nodes
示例#8
0
    def __init__(
        self,
        hostname: HostName,
        ipaddress: Optional[HostAddress],
        *,
        mode: Mode,
        source_type: SourceType,
        fetcher_type: FetcherType,
        description: str,
        default_raw_data: TRawData,
        default_host_sections: THostSections,
        preselected_sections: PreselectedSectionNames,
        id_: str,
        cache_dir: Optional[Path] = None,
        persisted_section_dir: Optional[Path] = None,
    ) -> None:
        self.hostname: Final[str] = hostname
        self.ipaddress: Final[Optional[str]] = ipaddress
        self.mode: Final[Mode] = mode
        self.source_type: Final[SourceType] = source_type
        self.fetcher_type: Final[FetcherType] = fetcher_type
        self.description: Final[str] = description
        self.default_raw_data: Final = default_raw_data
        self.default_host_sections: Final[THostSections] = default_host_sections
        # If preselected sections are given, we assume that we are interested in these
        # and only these sections, so we may omit others and in the SNMP case (TODO (mo))
        # must try to fetch them (regardles of detection).
        self.preselected_sections: Final[PreselectedSectionNames] = preselected_sections

        self.id: Final[str] = id_
        if not cache_dir:
            cache_dir = Path(cmk.utils.paths.data_source_cache_dir) / self.id
        if not persisted_section_dir:
            persisted_section_dir = Path(cmk.utils.paths.var_dir) / "persisted_sections" / self.id

        self.file_cache_path: Final[Path] = cache_dir / self.hostname
        self.file_cache_max_age: int = 0
        self.persisted_sections_file_path: Final[Path] = persisted_section_dir / self.hostname

        self.host_config: Final[HostConfig] = HostConfig.make_host_config(hostname)
        self._logger: Final[logging.Logger] = logging.getLogger("cmk.base.data_source.%s" % id_)

        self.exit_spec = self.host_config.exit_code_spec(id_)
示例#9
0
def _make_piggyback_nodes(
    mode: Mode,
    config_cache: config.ConfigCache,
    host_config: HostConfig,
) -> Sequence[Tuple[HostName, Optional[HostAddress], Sequence[Source]]]:
    """Abstract clusters/nodes/hosts"""
    assert host_config.nodes is not None

    nodes = []
    for hostname in host_config.nodes:
        node_config = config_cache.get_host_config(hostname)
        ipaddress = ip_lookup.lookup_ip_address(
            node_config,
            family=node_config.default_address_family,
        )
        sources = make_sources(
            HostConfig.make_host_config(hostname),
            ipaddress,
            mode=mode,
        )
        nodes.append((hostname, ipaddress, sources))
    return nodes
示例#10
0
文件: tcp.py 项目: LinuxHaus/checkmk
 def _make_description(hostname: HostName,
                       ipaddress: Optional[HostAddress]) -> str:
     return "TCP: %s:%d" % (
         ipaddress,
         HostConfig.make_host_config(hostname).agent_port,
     )