zoukankan      html  css  js  c++  java
  • Zabbix监控Linux磁盘I/O

    东西都上传到这里了:
     

    需要用到的东西:

     
    1、修改agent配置
    我的agent安装位置是/usr/local/zabbixagent/
    vi /usr/local/zabbixagent/conf/zabbix_agentd.conf
    Include=/usr/local/zabbixagent/conf/zabbix_agentd
    :wq
     
    2、建立配置文件
    此文件位置在/usr/local/zabbixagent/conf/zabbix_agentd/sysio.conf
    # required sysstat
    # required iostat running backgroud
    ##################################################
    # nohup iostat -k -x -d 30 > /usr/local/zabbixagent/tmp/iostats &
    # chown zabbix:zabbix /usr/local/zabbixagent/tmp/iostats
    # cronteb -e
    # Zabbix Agent's task for disk I/O
    # 59 23 * * * iostat -k -x -d 30 2 > /usr/local/zabbixagent/tmp/iostats &
    ##################################################
    # command for test.
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.rps[sda]'
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.wps[sda]'
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.rkbps[sda]'
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.wkbps[sda]'
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.avgrq-sz[sda]'
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.avgqu-sz[sda]'
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.await[sda]'
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.svctm[sda]'
    #/usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.util[sda]'
    ##################################################
    UserParameter=io.scandisk[*],/usr/local/zabbixagent/scripts/discovery-linux.py /proc/diskstats 3
    UserParameter=io.rps[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$4}'
    UserParameter=io.wps[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$5}'
    UserParameter=io.rkbps[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$6}'
    UserParameter=io.wkbps[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$7}'
    UserParameter=io.avgrq-sz[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$8}'
    UserParameter=io.avgqu-sz[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$9}'
    UserParameter=io.await[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$10}'
    UserParameter=io.svctm[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$11}'
    UserParameter=io.util[*],grep -a "$1" /usr/local/zabbixagent/tmp/iostats | tail -1 |awk '{print $$12}'
     
    3、misc
    cd /usr/local/zabbixagent/
    mkdir tmp scripts
    chmod 775 tmp scripts
    touch tmp/iostats
    chmod 644 tmp/iostats
    touch scripts/discovery-linux.py
    chmod 754 scripts/discovery-linux.py
    chown zabbix:zabbix ./* -R
     
    4、运行
    nohup iostat -k -x -d 30 > /usr/local/zabbixagent/tmp/iostats &
    sudo service zabbix_agentd restart
     
    5、测试
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.rps[sda]'
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.wps[sda]'
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.rkbps[sda]'
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.wkbps[sda]'
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.avgrq-sz[sda]'
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.avgqu-sz[sda]'
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.await[sda]'
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.svctm[sda]'
    /usr/local/zabbixagent/bin/zabbix_get -s 10.0.0.1 -k 'io.util[sda]'
    6、添加清理脚本
    crontab -e
    59 8 * * * iostat -k -x -d 30 2 > /usr/local/zabbixagent/tmp/iostats &
    7、添加配置
    blablabla,这里我就不说了。
  • 相关阅读:
    XMPP serverejabberd-14.12本地搭建
    uva 699 The Falling Leaves(建二叉树同一时候求和)
    ORA-22828 输入样式或替换參数超过了32k限制大小
    Timus 1149. Sinus Dances 打印复杂公式
    POJ2226
    3149 爱改名的小融 2
    1169 传纸条 2008年NOIP全国联赛提高组 个人博客:attack.cf
    1019 集合论与图论
    1215 迷宫
    1020 孪生蜘蛛
  • 原文地址:https://www.cnblogs.com/rexkang/p/zabbix-monitor-disk-io-of-linux.html
Copyright © 2011-2022 走看看