码迷,mamicode.com
首页 > 其他好文 > 详细

ZABBIX之磁盘IO监控

时间:2016-06-02 00:49:36      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:

1,配置文件
cat /usr/local/zabbix/conf/zabbix_agentd/diskstats.conf
UserParameter=disk.discovery,python /usr/local/zabbix/bin/disk_discovery.py
UserParameter=diskstats[*],/usr/local/zabbix/bin/diskstats.sh $1 $2
2,DISK 自动发现脚本
cat /usr/local/zabbix/bin/disk_discovery.py
#!/usr/bin/env python
#This script is used to discovery disk on the server
import subprocess
import json
args="cat /proc/diskstats |grep -E ‘\ssd[a-z]\s|\sxvd[a-z]\s|\svd[a-z]\s‘|awk ‘{print $3}‘|sort|uniq 2>/dev/null"
t=subprocess.Popen(args,shell=True,stdout=subprocess.PIPE).communicate()[0]
disks=[]
for disk in t.split(\n):
    if len(disk) != 0:
      disks.append({{#DISK_NAME}:disk})
print json.dumps({data:disks},indent=4,separators=(,,:)) 
3,diskstats脚本
cat  /usr/local/zabbix/bin/diskstats.sh
#!/bin/sh
device=$1
item=$2
case $item in
        read.ops)
            cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk {print $4}
            ;;
        read.ms)
            cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk {print $7}
            ;;
        write.ops)
            cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk {print $8}
            ;;
        write.ms)
            cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk {print $11}
            ;;
        io.active)
            cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk {print $12}
            ;;
        io.ms)
            cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk {print $13}
            ;;
        read.sectors)
            cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk {print $6}
            ;;
        write.sectors)
            cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk {print $10}
            ;;
esac
4,配置权限
chmod +x  /usr/local/zabbix/bin/disk_discovery.py 
chmod +x  /usr/local/zabbix/bin/diskstats.sh
 
5,重启
killall zabbix_agentd
/usr/local/zabbix/sbin/zabbix_agentd
ps uax|grep zabbix
 
6,导入模版
到zabbix模板上做链接
 
 

ZABBIX之磁盘IO监控

标签:

原文地址:http://www.cnblogs.com/tankt101/p/5551519.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!