客户端配置
配置参数
[root@ora19c zabbix]# pwd
/usr/local/zabbix/etc/
[root@ora19c zabbix]# vim zabbix_agentd.conf
UnsafeUserParameters=1
配置UI监控conf文件
[root@ora19c zabbix_agentd.d]# pwd
/usr/local/zabbix/etc/zabbix_agentd.d/
[root@ora19c zabbix_agentd.d]# ls
disk_status.conf userparameter_mysql.conf
[root@ora19c zabbix_agentd.d]# more disk_status.conf
UserParameter=disk.discovery[*],/etc/zabbix/scripts/disk_discovery.sh
UserParameter=disk.io.status[*],/etc/zabbix/scripts/disk_status.sh $1 $2
自动发现脚本
[root@ora19c scripts]# pwd
/usr/local/zabbix/scripts
[root@ora19c scripts]# more disk_discovery.sh
#!/bin/bash
disk_array=(`grep -E "(vd[a-z]$|sd[a-z]$)" /proc/partitions | awk '{print $4}'`)
length=${#disk_array[@]}
printf "{\n"
printf '\t'"\"data\":["
for ((i=0;i<$length;i++))
do
printf '\n\t\t{'
printf "\"{#DISK_NAME}\":\"${disk_array[$i]}\"}"
if [ $i -lt $[$length-1] ];then
printf ','
fi
done
printf "\n\t]\n"
printf "}\n"
IO状态脚本
[root@ora19c scripts]# more disk_status.sh
#/bin/bash
Device=$1
ITEM=$2
case $ITEM in
rrqm)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $2}' | sed 's/[[:space:]]//g'
;;
wrqm)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $3}' | sed 's/[[:space:]]//g'
;;
rps)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $4}' | sed 's/[[:space:]]//g'
;;
wps)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $5}' | sed 's/[[:space:]]//g'
;;
rKB)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $6}' | sed 's/[[:space:]]//g'
;;
wKB)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $7}' | sed 's/[[:space:]]//g'
;;
avgrq-sz)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $8}' | sed 's/[[:space:]]//g'
;;
avgqu-sz)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $9}' | sed 's/[[:space:]]//g'
;;
await)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $10}' | sed 's/[[:space:]]//g'
;;
svctm)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $11}' | sed 's/[[:space:]]//g'
;;
util)
iostat -dxkt -y 1 1|grep "$Device" | awk '{print $12}' | sed 's/[[:space:]]//g'
;;
esac
服务端配置
配置自动发现
配置监控项原型
模板
disk_status.yaml
https://www.aliyundrive.com/s/Mp155jTE92t
点击链接保存,或者复制本段内容,打开「阿里云盘」APP ,无需下载极速在线查看,视频原画倍速播放。