设为首页 收藏本站
查看: 955|回复: 0

[经验分享] zabbix io mornitor

[复制链接]

尚未签到

发表于 2015-11-23 13:00:26 | 显示全部楼层 |阅读模式

Preface



ZABBIX was a small Internet Co [color=#1B8EDE!important]server
performance
monitor is the first choice, free, secondly, there is a special company and [color=#1B8EDE!important]community
development
and maintenance, so that the stability and function in continuously strengthen and improve. ZABBIX has a UI interface and grouping [color=#1B8EDE!important]strategies in
detail, agent is installed in the monitored server, without adding any control options, because ZABBIX comes with some necessary monitoring, such as agent.ping, ZABBIX drawing, this is dedicated to boss see, very important. It also supports user-defined control
options, which is very convenient, I want [color=#1B8EDE!important]to
say today is the disk monitoring, dynamic monitoring of the title, number recognition disk means intelligence, and generate the corresponding monitoring options, because each server disk may not be the same, so I was using ZABBIX discovery method.

Personally think that the UI interface is more complex, but after all, the more complex is the high-end. I used not options for all configure and administration tag (this is necessary), also graphs and screen, these two options are in [color=#1B8EDE!important]the
monitor
tag, and BOSS were most concerned about.



Automatically find the disk



In the final analysis, automatic judgment all artificially set all possibilities, then according to the actual situation to choose from, there are a lot of methods, see you specific requirements. Here, I want to disk monitoring, we should first find out what
disk, here the use of shell scripts. Because the ZABBIX discovery requires a fixed format, which can be reference here, the bottom part.


Scripts are as follows:




1 #!/bin/bash
2 #written by lenwood
3 #mail:
4 diskarray=(`cat /proc/diskstats |grep -E "\bsd[abcdefg]\b|\bxvd[abcdefg]\b"|grep -i "\b$1\b"|awk '{print $3}'|sort|uniq   2>/dev/null`)
5 length=${#diskarray[@]}
6 printf "{\n"
7 printf  '\t'"\"data\":["
8 for ((i=0;i<$length;i&#43;&#43;))
9 do
10         printf '\n\t\t{'
11         printf &quot;\&quot;{#DISK_NAME}\&quot;:\&quot;${diskarray[$i]}\&quot;}&quot;
12         if [ $i -lt $[$length-1] ];then
13                 printf ','
14         fi
15 done
16 printf  &quot;\n\t]\n&quot;
17 printf &quot;}\n&quot;



As above, here by reading the /proc/diskstats, select one of the disk, according to the actual situation, here I will find similar to SDA or xvda, because we are using a SATA interface hard disk and part of [color=#1B8EDE!important]the
cloud
server.


The script out similar results as follows




1 {
2     &quot;data&quot;:[
3         {&quot;{#DISK_NAME}&quot;:&quot;sda&quot;}
4         {&quot;{#DISK_NAME}&quot;:&quot;sdb&quot;}
5     ]
6 }



Then use the ZABBIX to run the script, so it will be written to zabbix_agentd.conf in, as follows




UserParameter=io.scandisk
  • ,/infra/zabbix/os/disk_scan.sh $1




    The iostat command



    For disk monitoring I use the iostat command, because it can give detailed information on disk, such as sector[color=#1B8EDE!important]literacy
    ,
    IO queue length, iowait, svctime etc.


    The following command:




    1 nohup iostat -m -x -d 30 >/tmp/iostat_output &



    By tail -f /tmp/iostat_output, iostat command available disk information collection, results similar to the following




    Device:         rrqm/s   wrqm/s   r/s   w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util
    hda               0.00     0.20  0.00  7.43     0.00     0.16    43.28     0.23   30.80   2.43   1.81
    hda1              0.00     0.20  0.00  7.43     0.00     0.16    43.28     0.23   30.80   2.43   1.81
    hda2              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
    xvdb              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
    xvdb1             0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
    hdc               0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00



    The detailed explanation of some parameters are as follows




    rrqm/S: merge number of read operations per second. Delta(rmerge)/s
    wrqm/S: per second [color=#1B8EDE!important]operation number and write merge. Delta(wmerge)/s
    r/Read the I/O device s: completion times per second. Delta(rio)/s
    w/S: finished writing I/O times per second. Delta(wio)/s
    rsec/S: read the number of sectors per second. Delta(rsect)/s
    wsec/S: write the number of sectors per second. Delta(wsect)/s
    rkB/S: read K bytes per second. Is rsect/Half of the s, because each sector size of 512 bytes. ([color=#1B8EDE!important]calculated)
    wkB/S: write K bytes per second. Is wsect/Half s. (calculated)
    avgrqAverage -sz: per I/O device data size (sector). delta(rsect&#43;wsect)/delta(rio&#43;wio)
    avgqu-sz: I/O average queue length. Delta(aveq)/s/1000 (because the aveq milliseconds).
    Average await: per device I/The [color=#1B8EDE!important]waiting [color=#1B8EDE!important]time of O operation (MS). Delta(ruse&#43;wuse)/delta(rio&#43;wio)
    Average svctm: per device I/The O operation business hours (MS). Delta(use)/delta(rio&#43;wio)
    %Util: a second what percentage of the time for the I/O operation, or a second time I/O queue is not empty. Delta(use)/s/1000 (because the use milliseconds)






    Combined with ZABBIX



    The beginning has been said, is the combination of ZABBIX discovery function, so to make the following settings on the ZABBIX.


    (1)The new discovery rules


    DSC0000.jpg


    (2)After the new discovery rule, you can start writing item prototypes, here is an example of the avgqu-sz (the average length of I/O queue).


    DSC0001.jpg


    After the establishment of item, zabbix_agentd.conf to write the corresponding UserParameters, as follows.




    1 UserParameter=io.scandisk
  • ,/infra/zabbix/os/disk_scan.sh $1
    2 UserParameter=io.rps
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot;|tail -1|awk '{print $$4}'
    3 UserParameter=io.wps
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot; |tail -1|awk '{print $$5}'
    4 UserParameter=io.rMBps
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot; |tail -1|awk '{print $$6}'
    5 UserParameter=io.wMBps
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot; |tail -1|awk '{print $$7}'
    6 UserParameter=io.avgrq-sz
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot; |tail -1|awk '{print $$8}'
    7 UserParameter=io.avgqu-sz
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot; |tail -1|awk '{print $$9}'
    8 UserParameter=io.await
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot; |tail -1|awk '{print $$10}'
    9 UserParameter=io.svctm
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot; |tail -1|awk '{print $$11}'
    10 UserParameter=io.util
  • ,/usr/bin/tail /tmp/iostat_output |grep &quot;\b$1\b&quot; |tail -1|awk '{print $$12}'



    Above, part of the actual monitoring has been completed. But also drawing, also is the new graph prototype, as shown below.


    DSC0002.jpg


    Finally, look at [color=#1B8EDE!important]the
    work
    successfully, so as to realize the automatic determine the number of the disk on the server ZABBIX, and then automatically monitoring and generate graphs correspond to disk.


    DSC0003.jpg

  • 运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
    2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
    3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
    4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
    5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
    6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
    7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
    8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

    所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-142642-1-1.html 上篇帖子: zabbix的安装和基本配置(centos5) 下篇帖子: yum和rpm安装zabbix 2.0.9 For centos 6
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    扫码加入运维网微信交流群X

    扫码加入运维网微信交流群

    扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

    扫描微信二维码查看详情

    客服E-mail:kefu@iyunv.com 客服QQ:1061981298


    QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


    提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


    本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



    合作伙伴: 青云cloud

    快速回复 返回顶部 返回列表