当前位置:   article > 正文

zabbix监控磁盘io

zabbix disk io util percent

1 监控指标

iops是每秒的input/output次数,就是磁盘每秒能处理的读或写操作的请求能力。是衡量磁盘性能的主要指标之一。

吞吐量是磁盘每秒rw的数据量,反应数据的传输速度。

2 配置监控

[root@iZbp1ezumclop9223l31okZ zabbix]# cat /app/zabbix/scripts/disk_discovery.sh 
#!/bin/bash

diskname_discovery () {
    HardDisk=($(grep '\b[a-z][a-z][a-z]\+\b'  /proc/diskstats|awk '{print $3}'))
    [ "${HardDisk[0]}" == "" ] && exit
    printf '{\n'
    printf '\t"data":[\n\n'
    for((i=0;i<${#HardDisk[@]};++i))
    {
        num=$(echo $((${#HardDisk[@]}-1)))
        if [ "$i" != ${num} ];
        then
           printf "\t{\t\"{#DISKNAME}\":\"${HardDisk[$i]}\"\t},\n"
        else
           printf "\t{\t\"{#DISKNAME}\":\"${HardDisk[$num]}\"\t}\n\n\t]\n}\n"
        fi
    }
}

case "$1" in
diskname_discovery)
    diskname_discovery
    ;;
*)
    echo "Usage: $0 {diskname_discovery}"
    ;;
esac
#磁盘发现脚本

  

[root@iZbp1ezumclop9223l31okZ zabbix]# cat /app/zabbix/scripts/disk_stat.sh 

#/bin/sh
Device=$1
DISK=$2
case $DISK in
        riops)
            grep "\b$Device\b" /proc/diskstats | head -1 | awk '{print $4}'
            ;;
        wiops)
            grep "\b$Device\b" /proc/diskstats | head -1 | awk '{print $8}'
            ;;
        rKBps)
            iostat | grep "\b$Device\b" | awk '{print $5}'
            ;;
        wKBps)
            iostat | grep "\b$Device\b" | awk '{print $6}'
            ;;
        await)
            iostat -dxkt |grep "\b$Device\b" |tail -1|awk '{print $10}'
            ;;
        svctm)
            iostat -dxkt |grep "\b$Device\b" |tail -1|awk '{print $11}'
            ;;
         util)
            iostat -dxkt |grep "\b$Device\b" |tail -1|awk '{print $12}'
            ;;
esac
#监控项获取脚本
#await,avctm,util暂未修改,不可用

  

[root@iZbp1ezumclop9223l31okZ zabbix]# cat /app/zabbix/etc/zabbix_agentd.conf.d/diskio.conf 
#discovery hard disk
UserParameter=custom.vfs.discovery.diskname,/app/zabbix/scripts/disk_discovery.sh diskname_discovery
#disk status
UserParameter=custom.vfs.dev.disk_stats.riops[*],/app/zabbix/scripts/disk_stat.sh $1 riops
UserParameter=custom.vfs.dev.disk_stats.wiops[*],/app/zabbix/scripts/disk_stat.sh $1 wiops
UserParameter=custom.vfs.dev.disk_stats.rKBps[*],/app/zabbix/scripts/disk_stat.sh $1 rKBps
UserParameter=custom.vfs.dev.disk_stats.wKBps[*],/app/zabbix/scripts/disk_stat.sh $1 wKBps
UserParameter=custom.vfs.dev.disk_stats.avgrq[*],/app/zabbix/scripts/disk_stat.sh $1 avgrq-sz
UserParameter=custom.vfs.dev.disk_stats.avgqu[*],/app/zabbix/scripts/disk_stat.sh $1 avgqu-sz
UserParameter=custom.vfs.dev.disk_stats.await[*],/app/zabbix/scripts/disk_stat.sh $1 await
UserParameter=custom.vfs.dev.disk_stats.svctm[*],/app/zabbix/scripts/disk_stat.sh $1 svctm
UserParameter=custom.vfs.dev.disk_stats.util[*],/app/zabbix/scripts/disk_stat.sh $1 util
#自定义监控项脚本

  

3 配置zabbix

在zabbix添加模板,然后添加自动发现规则,在自动发现规则里添加监控项原型(由于获取的数据是累计值,需要把监控项设定为每秒更改),添加图像原型

此为效果图

 

 

附上导出模板

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>3.4</version>
    <date>2018-08-20T01:34:49Z</date>
    <groups>
        <group>
            <name>Linux servers</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template disk io</template>
            <name>Template disk io</name>
            <description/>
            <groups>
                <group>
                    <name>Linux servers</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>diski io</name>
                </application>
            </applications>
            <items/>
            <discovery_rules>
                <discovery_rule>
                    <name>auto discovery.Disk</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>custom.vfs.discovery.diskname</key>
                    <delay>30s</delay>
                    <status>0</status>
                    <allowed_hosts/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <filter>
                        <evaltype>0</evaltype>
                        <formula/>
                        <conditions/>
                    </filter>
                    <lifetime>30d</lifetime>
                    <description/>
                    <item_prototypes>
                        <item_prototype>
                            <name>Disk {#DISKNAME} riops</name>
                            <type>0</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>custom.vfs.dev.disk_stats.riops[{#DISKNAME}]</key>
                            <delay>30s</delay>
                            <history>90d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>count/sec</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>diski io</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing>
                                <step>
                                    <type>10</type>
                                    <params/>
                                </step>
                            </preprocessing>
                            <jmx_endpoint/>
                            <application_prototypes/>
                            <master_item_prototype/>
                        </item_prototype>
                        <item_prototype>
                            <name>Disk {#DISKNAME} rps</name>
                            <type>0</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>custom.vfs.dev.disk_stats.rKBps[{#DISKNAME}]</key>
                            <delay>15s</delay>
                            <history>90d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>MB/s</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>diski io</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing>
                                <step>
                                    <type>10</type>
                                    <params/>
                                </step>
                                <step>
                                    <type>1</type>
                                    <params>0.001</params>
                                </step>
                            </preprocessing>
                            <jmx_endpoint/>
                            <application_prototypes/>
                            <master_item_prototype/>
                        </item_prototype>
                        <item_prototype>
                            <name>Disk {#DISKNAME} wiops</name>
                            <type>0</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>custom.vfs.dev.disk_stats.wiops[{#DISKNAME}]</key>
                            <delay>30s</delay>
                            <history>90d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>count/sec</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>diski io</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing>
                                <step>
                                    <type>10</type>
                                    <params/>
                                </step>
                            </preprocessing>
                            <jmx_endpoint/>
                            <application_prototypes/>
                            <master_item_prototype/>
                        </item_prototype>
                        <item_prototype>
                            <name>Disk {#DISKNAME} wps</name>
                            <type>0</type>
                            <snmp_community/>
                            <snmp_oid/>
                            <key>custom.vfs.dev.disk_stats.wKBps[{#DISKNAME}]</key>
                            <delay>15s</delay>
                            <history>90d</history>
                            <trends>365d</trends>
                            <status>0</status>
                            <value_type>0</value_type>
                            <allowed_hosts/>
                            <units>MB/s</units>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <params/>
                            <ipmi_sensor/>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>diski io</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                            <preprocessing>
                                <step>
                                    <type>10</type>
                                    <params/>
                                </step>
                                <step>
                                    <type>1</type>
                                    <params>0.001</params>
                                </step>
                            </preprocessing>
                            <jmx_endpoint/>
                            <application_prototypes/>
                            <master_item_prototype/>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes/>
                    <graph_prototypes>
                        <graph_prototype>
                            <name>磁盘 {#DISKNAME} IO</name>
                            <width>900</width>
                            <height>200</height>
                            <yaxismin>0.0000</yaxismin>
                            <yaxismax>100.0000</yaxismax>
                            <show_work_period>1</show_work_period>
                            <show_triggers>1</show_triggers>
                            <type>0</type>
                            <show_legend>1</show_legend>
                            <show_3d>0</show_3d>
                            <percent_left>0.0000</percent_left>
                            <percent_right>0.0000</percent_right>
                            <ymin_type_1>0</ymin_type_1>
                            <ymax_type_1>0</ymax_type_1>
                            <ymin_item_1>0</ymin_item_1>
                            <ymax_item_1>0</ymax_item_1>
                            <graph_items>
                                <graph_item>
                                    <sortorder>0</sortorder>
                                    <drawtype>0</drawtype>
                                    <color>00AA00</color>
                                    <yaxisside>0</yaxisside>
                                    <calc_fnc>2</calc_fnc>
                                    <type>0</type>
                                    <item>
                                        <host>Template disk io</host>
                                        <key>custom.vfs.dev.disk_stats.wKBps[{#DISKNAME}]</key>
                                    </item>
                                </graph_item>
                                <graph_item>
                                    <sortorder>1</sortorder>
                                    <drawtype>0</drawtype>
                                    <color>F63100</color>
                                    <yaxisside>0</yaxisside>
                                    <calc_fnc>2</calc_fnc>
                                    <type>0</type>
                                    <item>
                                        <host>Template disk io</host>
                                        <key>custom.vfs.dev.disk_stats.rKBps[{#DISKNAME}]</key>
                                    </item>
                                </graph_item>
                            </graph_items>
                        </graph_prototype>
                        <graph_prototype>
                            <name>磁盘 {#DISKNAME} IOPS</name>
                            <width>900</width>
                            <height>200</height>
                            <yaxismin>0.0000</yaxismin>
                            <yaxismax>100.0000</yaxismax>
                            <show_work_period>1</show_work_period>
                            <show_triggers>1</show_triggers>
                            <type>0</type>
                            <show_legend>1</show_legend>
                            <show_3d>0</show_3d>
                            <percent_left>0.0000</percent_left>
                            <percent_right>0.0000</percent_right>
                            <ymin_type_1>0</ymin_type_1>
                            <ymax_type_1>0</ymax_type_1>
                            <ymin_item_1>0</ymin_item_1>
                            <ymax_item_1>0</ymax_item_1>
                            <graph_items>
                                <graph_item>
                                    <sortorder>0</sortorder>
                                    <drawtype>0</drawtype>
                                    <color>1A7C11</color>
                                    <yaxisside>0</yaxisside>
                                    <calc_fnc>2</calc_fnc>
                                    <type>0</type>
                                    <item>
                                        <host>Template disk io</host>
                                        <key>custom.vfs.dev.disk_stats.riops[{#DISKNAME}]</key>
                                    </item>
                                </graph_item>
                                <graph_item>
                                    <sortorder>1</sortorder>
                                    <drawtype>0</drawtype>
                                    <color>F63100</color>
                                    <yaxisside>0</yaxisside>
                                    <calc_fnc>2</calc_fnc>
                                    <type>0</type>
                                    <item>
                                        <host>Template disk io</host>
                                        <key>custom.vfs.dev.disk_stats.wiops[{#DISKNAME}]</key>
                                    </item>
                                </graph_item>
                            </graph_items>
                        </graph_prototype>
                    </graph_prototypes>
                    <host_prototypes/>
                    <jmx_endpoint/>
                </discovery_rule>
            </discovery_rules>
            <httptests/>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
</zabbix_export>

  

 

转载于:https://www.cnblogs.com/jabbok/p/9456826.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/160998
推荐阅读
相关标签
  

闽ICP备14008679号