Zabbix监控kubernetes

  sre

5ff814e83ec108255.png_fo742.png

获取k8s的api地址

cat /etc/kubernetes/kubelet.conf |grep server 

在K8S 的Master主机执行命令,生成令牌:

kubectl -n kube-system describe secret (kubectl -n kube-system get secret | grep admin-user | awk '{print1}')

get_k8s.py

#!/usr/bin/python3
import json
import datetime
import sys
import os
import math
import urllib3
import requests
import re
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

zabbix_sender = "/usr/local/zabbix/bin/zabbix_sender"
zabbix_server = "192.168.1.233"
clientname = "k8s_master"


#k8s的api地址
url = "https://192.168.1.140:6443"

#k8s的token
token = "e11111111-k8s-token-111111w"

def get_result(api_name):
   headers = {"Authorization":"Bearer "+token}
   json_data = requests.get(url+api_name,headers=headers,verify=False)
   return json_data.json()

#时间转换,把所有服务的创建时间变成运行时间
def Trantime(time_data):
    time = re.match(r"(\d+)-(\d+)-(\d+).*?(\d+):(\d+):(\d+)",time_data)
    total_send = round((datetime.datetime.now()-datetime.datetime(int(time.group(1)),int(time.group(2)),int(time.group(3)),int(time.group(4)),int(time.group(5)),int(time.group(6)))).total_seconds())
    return str(math.floor(total_send/86400)).split(".")[0]+"d"+str(math.floor((total_send%86400)/3600)).split(".")[0]+"h"   

#把所有的单位转换成b
def Tranunit(unit_data):
    unit = re.match(r"(\d+)(.*)",unit_data)
    value = int(unit.group(1))
    if unit.group(2) == "K":
       return value*1000
    elif unit.group(2) == "Ki":
       return value*1024
    elif unit.group(2) == "M":
       return value*1000*1000
    elif unit.group(2) == "Mi":
       return value*1024*1024
    elif unit.group(2) == "G":
       return value*1000*1000*1000
    elif unit.group(2) == "Gi":
        return value*1024*1024*1024
    elif unit.group(2) == "n":
        return math.ceil(value/1000/1000)
    elif unit.group(2) == "m":
        return value
    else:
        return value

#对数据进行zabbix_sender发送
def send_data(data,dis_key,key):
    result = json.dumps({"data":data},sort_keys=True,ensure_ascii=False)
    cmd = "{0} -z {1} -s {2} -k {3} -o '{4}'>/dev/null".format(zabbix_sender,zabbix_server,clientname,dis_key,result)
    os.system(cmd)
    for i in data:
        for value in i.keys():
         if value !="{#NAME}":
           cmd = "{0} -z {1} -s {2} -k {3}[{4}.{5}] -o '{6}'>/dev/null".format(zabbix_sender,zabbix_server,clientname,key,i["{#NAME}"],i[value][0],i[value][1])
           os.system(cmd)
           print(cmd)     
#获取所有k8s节点的信息
def get_node():
    get_nodes = []
    node_result = get_result("/api/v1/nodes")
    node_use_result = get_result("/apis/metrics.k8s.io/v1beta1/nodes")
    for j in node_use_result.get("items"):
          for i in node_result.get("items"):
            if i.get("metadata").get("name") == j.get("metadata").get("name"):
              data={"{#NAME}": i.get("metadata").get("name"),
                               "{#STATUS}": ["status",i.get("status").get("conditions")[-1].get("type") if i.get("status").get("conditions")[-1].get("status") == "True" else "NotReady"],
                                "{#IP}": ["ip",i.get("status").get("addresses")[0].get("address")],
                                "{#KUBELET_VERSION}": ["version",i.get("status").get("nodeInfo").get("kubeletVersion")],
                                "{#OS_IMAGE}": ["os_image",i.get("status").get("nodeInfo").get("osImage")],
                                 "{#CPU}": ["cpu",i.get("status").get("capacity").get("cpu")],
                                 "{#MEMORY}": ["memory",Tranunit(i.get("status").get("capacity").get("memory"))],
                                 "{#LIMIT_STORAGE}": ["storage",Tranunit(i.get("status").get("capacity").get("ephemeral-storage"))],
                                 "{#RUNTIME}":["runtime",Trantime(i.get("metadata").get("creationTimestamp"))],
                                 "{#USECPU}":["usecpu",Tranunit(j.get("usage").get("cpu"))],
                                 "{#USEMEMORY}":["usememory",Tranunit(j.get("usage").get("memory"))]
                                 }

          get_nodes.append(data)
    send_data(get_nodes,"getnode","node")

#获取k8s组件的健康信息
def get_health():
    get_healths = []
    health_result = get_result("/api/v1/componentstatuses") 
    for i in health_result.get("items"):
        data = {} 
        data = {"{#NAME}": i.get("metadata").get("name"),
                "{#STATUS}": ["status",i.get("conditions")[0].get("type")],
                "{#MESSAGE}":["message",i.get("conditions")[0].get("message")]                 
                }
        get_healths.append(data)
    send_data(get_healths,"gethealth","health")

#获取k8s的所有pod
def get_pod(): 
    get_pods = []
    pod_result = get_result("/api/v1/pods")
    for i in pod_result.get("items"):
           data = {"{#NAME}":i.get("metadata").get("name"),
                   "{#RUNTIME}":["runtime",Trantime(i.get("metadata").get("creationTimestamp"))],  
                   "{#STATUS}":["status",i.get("status").get("phase")],
                   "{#RESTARTCOUNT}":["restartcount",i.get("status").get("containerStatuses")[0].get("restartCount")]
                      }

           get_pods.append(data)
    send_data(get_pods,"getpod","pod")

if __name__ == "__main__":
   cmd = "{0}()".format(sys.argv[1])
   eval(cmd)
   print("采集完成")

调用:

#!/usr/bin/bash
/usr/bin/python3 get_k8s.py get_pod
/usr/bin/python3 get_k8s.py get_health
/usr/bin/python3 get_k8s.py get_node

xml模板

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>4.2</version>
    <date>2020-06-12T08:42:43Z</date>
    <groups>
        <group>
            <name>中间件模板</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>k8sTemplate</template>
            <name>k8s监控模板</name>
            <description/>
            <groups>
                <group>
                    <name>中间件模板</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>component</name>
                </application>
                <application>
                    <name>health</name>
                </application>
                <application>
                    <name>k8s</name>
                </application>
                <application>
                    <name>node</name>
                </application>
                <application>
                    <name>pod</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>获取k8s的脚本</name>
                    <type>10</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>get_k8s</key>
                    <delay>180s</delay>
                    <history>90d</history>
                    <trends>0</trends>
                    <status>0</status>
                    <value_type>1</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>k8s</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <timeout>3s</timeout>
                    <url/>
                    <query_fields/>
                    <posts/>
                    <status_codes>200</status_codes>
                    <follow_redirects>1</follow_redirects>
                    <post_type>0</post_type>
                    <http_proxy/>
                    <headers/>
                    <retrieve_mode>0</retrieve_mode>
                    <request_method>0</request_method>
                    <output_format>0</output_format>
                    <allow_traps>0</allow_traps>
                    <ssl_cert_file/>
                    <ssl_key_file/>
                    <ssl_key_password/>
                    <verify_peer>0</verify_peer>
                    <verify_host>0</verify_host>
                    <master_item/>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>获取k8s的健康信息</name>
                    <type>2</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>gethealth</key>
                    <delay>0</delay>
                    <status>0</status>
                    <allowed_hosts/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <filter>
                        <evaltype>0</evaltype>
                        <formula/>
                        <conditions/>
                    </filter>
                    <lifetime>30d</lifetime>
                    <description/>
                    <item_prototypes>
                        <item_prototype>
                            <name>{#NAME}的健康信息</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>health[{#NAME}.message]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>health</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>{#NAME}的状态</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>health[{#NAME}.status]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>health</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{k8sTemplate:health[{#NAME}.status].diff(Healthy)}=1</expression>
                            <recovery_mode>0</recovery_mode>
                            <recovery_expression/>
                            <name>{#NAME}监控状态异常</name>
                            <correlation_mode>0</correlation_mode>
                            <correlation_tag/>
                            <url/>
                            <status>0</status>
                            <priority>3</priority>
                            <description/>
                            <type>0</type>
                            <manual_close>1</manual_close>
                            <dependencies/>
                            <tags/>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <graph_prototypes/>
                    <host_prototypes/>
                    <jmx_endpoint/>
                    <timeout>3s</timeout>
                    <url/>
                    <query_fields/>
                    <posts/>
                    <status_codes>200</status_codes>
                    <follow_redirects>1</follow_redirects>
                    <post_type>0</post_type>
                    <http_proxy/>
                    <headers/>
                    <retrieve_mode>0</retrieve_mode>
                    <request_method>0</request_method>
                    <allow_traps>0</allow_traps>
                    <ssl_cert_file/>
                    <ssl_key_file/>
                    <ssl_key_password/>
                    <verify_peer>0</verify_peer>
                    <verify_host>0</verify_host>
                    <lld_macro_paths/>
                    <preprocessing/>
                    <master_item/>
                </discovery_rule>
                <discovery_rule>
                    <name>获取所有NODE节点信息</name>
                    <type>2</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>getnode</key>
                    <delay>0</delay>
                    <status>0</status>
                    <allowed_hosts/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <filter>
                        <evaltype>0</evaltype>
                        <formula/>
                        <conditions/>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description/>
                    <item_prototypes>
                        <item_prototype>
                            <name>节点{#NAME}的CPU个数</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.cpu]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}的IP</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.ip]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}的内存</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.memory]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>B</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}的操作系统</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.os_image]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}运行时间</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.runtime]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}的状态</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.status]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}的硬盘大小</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.storage]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>B</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}的已使用CPU数</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.usecpu]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>m</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description>1000m等于1个CPU数,1000n*1000n的等于1m</description>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}已使用内存</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.usememory]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>B</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>节点{#NAME}的kubectl版本</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>node[{#NAME}.version]</key>
                            <delay>0</delay>
                            <history>7d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>{#NAME}的CPU使用率</name>
                            <type>15</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>usecpu[{#NAME}]</key>
                            <delay>60s</delay>
                            <history>90d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>%</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params>last("node[{#NAME}.usecpu]")/(last("node[{#NAME}.cpu]")*1000)*100</params>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>{#NAME}的内存使用率</name>
                            <type>15</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>usememory[{#NAME}]</key>
                            <delay>60s</delay>
                            <history>90d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>%</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params>last("node[{#NAME}.usememory]")/last("node[{#NAME}.memory]")*100</params>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>node</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{k8sTemplate:node[{#NAME}.status].diff(Ready)}=1</expression>
                            <recovery_mode>0</recovery_mode>
                            <recovery_expression/>
                            <name>节点{#NODENAME}状态异常</name>
                            <correlation_mode>0</correlation_mode>
                            <correlation_tag/>
                            <url/>
                            <status>0</status>
                            <priority>2</priority>
                            <description/>
                            <type>0</type>
                            <manual_close>1</manual_close>
                            <dependencies/>
                            <tags/>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <graph_prototypes/>
                    <host_prototypes/>
                    <jmx_endpoint/>
                    <timeout>3s</timeout>
                    <url/>
                    <query_fields/>
                    <posts/>
                    <status_codes>200</status_codes>
                    <follow_redirects>1</follow_redirects>
                    <post_type>0</post_type>
                    <http_proxy/>
                    <headers/>
                    <retrieve_mode>0</retrieve_mode>
                    <request_method>0</request_method>
                    <allow_traps>0</allow_traps>
                    <ssl_cert_file/>
                    <ssl_key_file/>
                    <ssl_key_password/>
                    <verify_peer>0</verify_peer>
                    <verify_host>0</verify_host>
                    <lld_macro_paths/>
                    <preprocessing/>
                    <master_item/>
                </discovery_rule>
                <discovery_rule>
                    <name>获取所有pod信息</name>
                    <type>2</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>getpod</key>
                    <delay>0</delay>
                    <status>0</status>
                    <allowed_hosts/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <filter>
                        <evaltype>0</evaltype>
                        <formula/>
                        <conditions/>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description/>
                    <item_prototypes>
                        <item_prototype>
                            <name>pod_{#NAME}的重启次数</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>pod[{#NAME}.restartcount]</key>
                            <delay>0</delay>
                            <history>90d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>pod</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>pod_{#NAME}的运行时间</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>pod[{#NAME}.runtime]</key>
                            <delay>0</delay>
                            <history>90d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>pod</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                        <item_prototype>
                            <name>pod_{#NAME}的状态</name>
                            <type>2</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>pod[{#NAME}.status]</key>
                            <delay>0</delay>
                            <history>90d</history>
                            <trends>0</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>pod</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing/>
                            <jmx_endpoint/>
                            <timeout>3s</timeout>
                            <url/>
                            <query_fields/>
                            <posts/>
                            <status_codes>200</status_codes>
                            <follow_redirects>1</follow_redirects>
                            <post_type>0</post_type>
                            <http_proxy/>
                            <headers/>
                            <retrieve_mode>0</retrieve_mode>
                            <request_method>0</request_method>
                            <output_format>0</output_format>
                            <allow_traps>0</allow_traps>
                            <ssl_cert_file/>
                            <ssl_key_file/>
                            <ssl_key_password/>
                            <verify_peer>0</verify_peer>
                            <verify_host>0</verify_host>
                            <application_prototypes/>
                            <master_item/>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{k8sTemplate:pod[{#NAME}.status].diff(Running)}=1</expression>
                            <recovery_mode>0</recovery_mode>
                            <recovery_expression/>
                            <name>pod节点{#NAME}状态异常</name>
                            <correlation_mode>0</correlation_mode>
                            <correlation_tag/>
                            <url/>
                            <status>0</status>
                            <priority>4</priority>
                            <description/>
                            <type>0</type>
                            <manual_close>1</manual_close>
                            <dependencies/>
                            <tags/>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <graph_prototypes/>
                    <host_prototypes/>
                    <jmx_endpoint/>
                    <timeout>3s</timeout>
                    <url/>
                    <query_fields/>
                    <posts/>
                    <status_codes>200</status_codes>
                    <follow_redirects>1</follow_redirects>
                    <post_type>0</post_type>
                    <http_proxy/>
                    <headers/>
                    <retrieve_mode>0</retrieve_mode>
                    <request_method>0</request_method>
                    <allow_traps>0</allow_traps>
                    <ssl_cert_file/>
                    <ssl_key_file/>
                    <ssl_key_password/>
                    <verify_peer>0</verify_peer>
                    <verify_host>0</verify_host>
                    <lld_macro_paths/>
                    <preprocessing/>
                    <master_item/>
                </discovery_rule>
            </discovery_rules>
            <httptests/>
            <macros/>
            <templates/>
            <screens/>
            <tags/>
        </template>
    </templates>
</zabbix_export>

LEAVE A COMMENT

Captcha Code