kuyjhtgrf 发表于 2017-1-11 09:48:46

使用iostat和LLD实现zabbix监控IO性能

最近有一个需求是对系统的IO进行监控,最后决定从iostat获取数据。


1
iostat -x -d -m 1 3




参数简单解析:
-x   Displayextended statistics
-d   Display the device utilization report
-m   Display statistics in megabytes per second instead of blocks or kilobytes per second

那么为什么要 1 3呢?
我们用

1
iostat -x -d -m 1




多次测试,会发现第一次输出的值变动不大,第二次,第三次输出的值会有一定的变化,因此我更偏向与取第二次,第三次的值做平均
命令的输出格式如下:

1
Device:         rrqm/s   wrqm/s   r/s   w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   awaitsvctm%util




可以较好地满足我们的监控需求


接下来,我们就用zabbix的LLD来自动发现当前系统的Device值
cat /etc/zabbix/scripts/io_discovery.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/env python
import os
import commands
(status,output) = commands.getstatusoutput("iostat -x -d -m| sed -n '4,$p' | grep -v ^$|awk '{print $1}'")
DISKS = output.split()
print '{'
print '\t"data":['
count = 1
for key in DISKS:
    print '\t{'
    if count < len(DISKS):
      print '\t\t"{#DISK}":"%s"},' % key
    else:
      print '\t\t"{#DISK}":"%s"}' % key
    count += 1
print '\t]'
print '}'



页: [1]
查看完整版本: 使用iostat和LLD实现zabbix监控IO性能