ZABBIX之磁盘IO监控
Posted Tank
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ZABBIX之磁盘IO监控相关的知识,希望对你有一定的参考价值。
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监控的主要内容,如果未能解决你的问题,请参考以下文章