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"
        }
    ]
}

转载于:https://www.cnblogs.com/metasequoia/p/5721321.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值