标签:/etc/ 服务 0.00 sudo util img str bsp data
yum install sysstat
mkdir /etc/zabbix/scripts
cd /etc/zabbix/scripts/
vim disk_scan.sh #!/bin/bash diskarray=(`cat /proc/diskstats |grep -E "\bsd[abcdefg]\b|\bvd[abcdefg]\b"|grep -i "\b$1\b"|awk ‘{print $3}‘|sort|uniq 2>/dev/null`) length=${#diskarray[@]} printf "{\n" printf ‘\t‘"\"data\":[" for ((i=0;i<$length;i++)) do printf ‘\n\t\t{‘ printf "\"{#DISKNAME}\":\"${diskarray[$i]}\"}" if [ $i -lt $[$length-1] ];then printf ‘,‘ fi done printf "\n\t]\n" printf "}\n"
chown root:zabbix -R /etc/zabbix/scripts/ chmod 750 /etc/zabbix/scripts/
chmod 550 /etc/zabbix/scripts/iostat.sh
[root@agent scripts]# sudo -u zabbix /usr/bin/sh /etc/zabbix/scripts/disk_scan.sh { "data":[ {"{#DISKNAME}":"sda"} ] } [root@agent scripts]#
nohup iostat -m -x -d 30 >> /tmp/iostat_output 2>&1 &
UserParameter=io.scandisk[*],/etc/zabbix/scripts/disk_scan.sh $1 UserParameter=io.rrqm[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b"|tail -1|awk ‘{print $$2}‘ UserParameter=io.wrqm[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b"|tail -1|awk ‘{print $$3}‘ UserParameter=io.rps[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b"|tail -1|awk ‘{print $$4}‘ UserParameter=io.wps[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$5}‘ UserParameter=io.rMBps[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$6}‘ UserParameter=io.wMBps[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$7}‘ UserParameter=io.avgrq-sz[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$8}‘ UserParameter=io.avgqu-sz[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$9}‘ UserParameter=io.await[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$10}‘ UserParameter=io.r_await[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$11}‘ UserParameter=io.w_await[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$12}‘ UserParameter=io.svctm[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$13}‘ UserParameter=io.util[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk ‘{print $$14}‘
systemctl restart zabbix-agent.service
[root@zabbix-server zabbix]# zabbix_get -p 10050 -s 10.10.10.99 -k io.util[sda] 0.23 [root@zabbix-server zabbix]# zabbix_get -p 10050 -s 10.10.10.99 -k io.util[sda] 0.23 [root@zabbix-server zabbix]# zabbix_get -p 10050 -s 10.10.10.99 -k io.rps[sda] 0.00 [root@zabbix-server zabbix]# zabbix_get -p 10050 -s 10.10.10.99 -k io.rMBps[sda] 0.00
名称:Disk discovery 键值:io.scandisk
第一个监控项原型示例,其余规则据按照此模型创建即可!!!
创建好的模型如下:
标签:/etc/ 服务 0.00 sudo util img str bsp data
原文地址:https://www.cnblogs.com/huangyanqi/p/9073601.html