예제 #1
0
        return
    selector = section_kube_deployment_info.selector
    yield Attributes(
        path=["software", "applications", "kube", "deployment"],
        inventory_attributes={
            "name":
            section_kube_deployment_info.name,
            "namespace":
            section_kube_deployment_info.namespace,
            "strategy":
            strategy_text(section_kube_deployment_strategy.strategy),
            "match_labels":
            match_labels_to_str(selector.match_labels),
            "match_expressions":
            match_expressions_to_str(selector.match_expressions),
        },
    )
    for label in section_kube_deployment_info.labels.values():
        yield TableRow(
            path=["software", "applications", "kube", "labels"],
            key_columns={"label_name": label.name},
            inventory_columns={"label_value": label.value},
        )


register.inventory_plugin(
    name="kube_deployment",
    sections=["kube_deployment_info", "kube_deployment_strategy"],
    inventory_function=inventory_kube_deployment,
)
예제 #2
0
                    "ready": "yes" if container_status.ready else "no",
                    "restart_count": container_status.restart_count,
                    "image": container_status.image,
                    "image_id": container_status.image_id,
                    "container_id": container_status.container_id,
                },
            )
    else:
        for name, container_spec in container_specs.containers.items():
            yield TableRow(
                path=["software", "applications", "kube", "containers"],
                key_columns={"name": name},
                inventory_columns={
                    "image_pull_policy": container_spec.image_pull_policy,
                    "ready": "no",
                },
            )


register.inventory_plugin(
    name="kube_pod",
    sections=[
        "kube_pod_info",
        "kube_pod_containers",
        "kube_pod_init_containers",
        "kube_pod_container_specs",
        "kube_pod_init_container_specs",
    ],
    inventory_function=inventory_kube_pod,
)
예제 #3
0
from cmk.base.plugins.agent_based.agent_based_api.v1 import Attributes, register
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import InventoryResult
from cmk.base.plugins.agent_based.utils.kube import ClusterInfo


def inventory_kube_cluster(
    section: ClusterInfo,
) -> InventoryResult:
    yield Attributes(
        path=["software", "applications", "kube", "metadata"],
        inventory_attributes={
            "object": "cluster",
            "name": section.name,
        },
    )

    yield Attributes(
        path=["software", "applications", "kube", "cluster"],
        inventory_attributes={
            "version": section.version,
        },
    )


register.inventory_plugin(
    name="kube_cluster",
    sections=["kube_cluster_info"],
    inventory_function=inventory_kube_cluster,
)
예제 #4
0
    section_kube_statefulset_info: Optional[StatefulSetInfo],
    section_kube_update_strategy: Optional[UpdateStrategy],
) -> InventoryResult:
    if section_kube_statefulset_info is None or section_kube_update_strategy is None:
        return
    yield Attributes(
        path=["software", "applications", "kube", "metadata"],
        inventory_attributes={
            "object": "StatefulSet",
            "name": section_kube_statefulset_info.name,
            "namespace": section_kube_statefulset_info.namespace,
        },
    )
    selector = section_kube_statefulset_info.selector
    yield Attributes(
        path=["software", "applications", "kube", "statefulset"],
        inventory_attributes={
            "strategy": strategy_text(section_kube_update_strategy.strategy),
            "match_labels": match_labels_to_str(selector.match_labels),
            "match_expressions": match_expressions_to_str(selector.match_expressions),
        },
    )
    yield from labels_to_table(section_kube_statefulset_info.labels)


register.inventory_plugin(
    name="kube_statefulset",
    sections=["kube_statefulset_info", "kube_update_strategy"],
    inventory_function=inventory_kube_statefulset,
)
예제 #5
0
        },
    )

    yield Attributes(
        path=["software", "applications", "kube", "node"],
        inventory_attributes={
            "operating_system": section_kube_node_info.operating_system,
            "os_image": section_kube_node_info.os_image,
            "kernel_version": section_kube_node_info.kernel_version,
            "architecture": section_kube_node_info.architecture,
            "container_runtime_version":
            section_kube_node_info.container_runtime_version,
            "kubelet_version": section_kube_node_kubelet.version,
            "kube_proxy_version": section_kube_node_kubelet.proxy_version,
        },
    )
    for address in section_kube_node_info.addresses:
        yield TableRow(
            path=["software", "applications", "kube", "network"],
            key_columns={"ip": address.address},
            inventory_columns={"address_type": address.type_},
        )
    yield from labels_to_table(section_kube_node_info.labels)


register.inventory_plugin(
    name="kube_node",
    sections=["kube_node_info", "kube_node_kubelet"],
    inventory_function=inventory_kube_node,
)
예제 #6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2021 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

from cmk.base.plugins.agent_based.agent_based_api.v1 import Attributes, register
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import InventoryResult
from cmk.base.plugins.agent_based.utils.kube import NamespaceInfo


def inventory_kube_namespace(
    section: NamespaceInfo,
) -> InventoryResult:
    yield Attributes(
        path=["software", "applications", "kube", "metadata"],
        inventory_attributes={
            "object": "Namespace",
            "name": section.name,
            "namespace": section.name,
        },
    )


register.inventory_plugin(
    name="kube_namespace",
    sections=["kube_namespace_info"],
    inventory_function=inventory_kube_namespace,
)
예제 #7
0
    return section


register.agent_section(
    name="win_bios",
    parse_function=parse_win_bios,
)


def inventory_win_bios(section: Mapping[str, Union[str, int]]):

    attr = {
        k: section[k]
        for k in ("date", "model", "vendor", "version") if k in section
    }
    with suppress(KeyError):
        attr[
            "version"] = f"{section['smbios_version']} {section['major_version']}.{section['minor_version']}"

    yield Attributes(
        path=["software", "bios"],
        inventory_attributes=attr,
    )


register.inventory_plugin(
    name="win_bios",
    inventory_function=inventory_win_bios,
)
    # aparrently this was not clear when designing the sections output
    section: Section = {}
    for datacenter_name, key, cluster_name, *values in string_table:
        section.setdefault(cluster_name, {"datacenter": datacenter_name})[key] = ", ".join(values)
    return section


def inventory_esx_vsphere_clusters(section: Section) -> InventoryResult:
    for cluster_name, cluster_data in section.items():
        yield TableRow(
            path=["software", "applications", "vmwareesx"],
            key_columns={
                "cluster": cluster_name,
                "datacenter": cluster_data["datacenter"],
                "hostsystems": cluster_data["hostsystems"],
                "vms": cluster_data["vms"],
            },
        )


register.agent_section(
    name="esx_vsphere_clusters",
    parse_function=parse_esx_vsphere_clusters,
)

register.inventory_plugin(
    name="inventory_esx_vsphere_clusters",
    sections=["esx_vsphere_clusters"],
    inventory_function=inventory_esx_vsphere_clusters,
)
예제 #9
0
def inventory_kube_daemonset(
    section_kube_daemonset_info: Optional[DaemonSetInfo],
    section_kube_daemonset_strategy: Optional[DaemonSetStrategy],
) -> InventoryResult:
    if section_kube_daemonset_info is None or section_kube_daemonset_strategy is None:
        return
    selector = section_kube_daemonset_info.selector
    yield Attributes(
        path=["software", "applications", "kube", "daemonset"],
        inventory_attributes={
            "name":
            section_kube_daemonset_info.name,
            "namespace":
            section_kube_daemonset_info.namespace,
            "strategy":
            strategy_text(section_kube_daemonset_strategy.strategy),
            "match_labels":
            match_labels_to_str(selector.match_labels),
            "match_expressions":
            match_expressions_to_str(selector.match_expressions),
        },
    )
    yield from labels_to_table(section_kube_daemonset_info.labels)


register.inventory_plugin(
    name="kube_daemonset",
    sections=["kube_daemonset_info", "kube_daemonset_strategy"],
    inventory_function=inventory_kube_daemonset,
)