• zabbix添加磁盘IO监控


    1,定义获取值的 disk_stat.conf配置文件

     cat disk_stat.conf

    UserParameter=custom.vfs.discover_disks,/usr/local/zabbix_agents_3.2.7/scripts/disk_discovery.py
    UserParameter=custom.vfs.dev.read.ops[*],awk '{print $$1}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.read.merged[*],awk '{print $$2}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.read.sectors[*],awk '{print $$3}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.read.ms[*],awk '{print $$4}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.write.ops[*],awk '{print $$5}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.write.merged[*],awk '{print $$6}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.write.sectors[*],awk '{print $$7}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.write.ms[*],awk '{print $$8}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.io.active[*],awk '{print $$9}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.io.ms[*],awk '{print $$10}' /sys/class/block/$1/stat
    UserParameter=custom.vfs.dev.weight.io.ms[*],awk '{print $$11}' /sys/class/block/$1/stat

    2,添加python拉取值得python脚本

    disk_discovery.py

    #!/usr/bin/python
    import os
    import json

    if __name__ == "__main__":
    # Iterate over all block devices, but ignore them if they are in the
    # skippable set
    skippable = ("sr", "loop", "ram")
    devices = (device for device in os.listdir("/sys/class/block")
    if not any(ignore in device for ignore in skippable))
    data = [{"{#DEVICENAME}": device} for device in devices]
    print(json.dumps({"data": data}, indent=4))

    ,3,将Include=/usr/local/zabbix_agents_3.2.7/*.conf放入zabbix_agent.conf的最后一行

    4,重启zabbix

  • 相关阅读:
    MysQL使用一与Python交互
    WPF三大模板简介
    Java Servlet生成JSON格式数据并用jQuery显示
    JSP之应用Servlet过滤器进行身份验证
    Java调用SQL Server存储过程
    JSP之Cookie对象使用
    JSP之response对象使用
    JSP之静态include指令、动态Include指令
    JSP之使用useBean、setProperty、getProperty指令
    jspSmartUpload使用初步
  • 原文地址:https://www.cnblogs.com/wanganshi/p/10294541.html
Copyright © 2020-2023  润新知