zoukankan      html  css  js  c++  java
  • Zabbix low-level discovery

    Version: zabbix 3.0.1

    概述

    Low-Level discovery 可以自动创建items,triggers,graphs为不同的实体对象。

    例如:zabbix能自动监控服务器上的所有文件系统,网路接口。而不用手动在每个文件系统,网络接口上创建items。

    除此之外,也可以根据discovery返回的结果,配置zabbix移除不需要的实体对象

    zabbix支持六种不同的discovery items

      discovery of file systems;
      discovery of network interfaces;
      discovery of CPUs and CPU cores;
      discovery of SNMP OIDs;
      discovery using ODBC SQL queries;
      discovery of Windows services.


    用户也可以自定义discovery,通过独有的JSON协议

      1、用户定义discovery脚本

        返回宏变量  例如:{#DEVICENAME} -> sda,{#DEVICENAME} -> sdb

      2、创建prototypes

        例如:custom.vfs.dev.io.active[{#DEVICENAME}]

    以下是一般的自定义discovery处理结构

      首先,创建discovery rule在”Configuration” → “Templates” → “Discovery“列

      (discovery rule的组成(1)发现实体对象(列如:文件系统,网络接口) (2)prototypes:在之前发现的实体对象上创建items,triggers,graphs)

    (1)

    属性说明

    Discovery rule

      Keep lost resources period (in days)  # 数据保留的天数

    Filter

      对返回的数据进行过滤筛选,支持regexp

    (2)

    lld-disks.py;chmod +x lld-disks.py

    #!/usr/bin/env python
    
    '''
        zabbix disks Low-Level discovery
    '''
    
    import os
    import re
    import json
    
    def Devices(diskdir, skippable):
    
        raw_devices = (device for device in os.listdir(diskdir) if not any(ignore in device for ignore in skippable))
        devices = (device for device in raw_devices if re.match(r'^w{3}$', device))  # 保留整块磁盘 去掉分区, such as remove sda1 sdb2
        data = [{"{#DEVICENAME}": device} for device in devices]
        print(json.dumps({"data": data}, indent=4))
    
    if __name__ == "__main__":
        # Iterate over all block devices, but ignore them if they are in the skippable set
        diskdir = "/sys/class/block"
        skippable = ("sr", "loop", "ram", "dm")
        Devices(diskdir, skippable)

    response  # json格式

    {
        "data": [
            {
                "{#DEVICENAME}": "sdb"
            },
            {
                "{#DEVICENAME}": "sda"
            }
        ]
    }
  • 相关阅读:
    android界面基本属性
    iOS请求webservice
    图片在鼠标经过时变大
    控制字体大小,em与px的区别与应用
    IE的另类CSS hack,条件注释
    几种流行的AJAX框架jQuery,Mootools,Dojo,Ext JS的对比
    CSS实现文字压在边线上的效果,fieldset与legend
    每个.NET 开发人员应该下载的十个必备工具
    css做出丰富的Tooltips
    .NET牛人应该知道些什么?
  • 原文地址:https://www.cnblogs.com/metasequoia/p/5721321.html
Copyright © 2011-2022 走看看