# zabbix监控磁盘IO

+关注继续查看

++++++++++++++++++++++++对/proc/diskstats的解释++++++++++++++++++++++++++++++

# cat /proc/diskstats |grep sda |head -1

8    0     sda 2280 1445 76478 11956 249 188 3490 932 0 9913 12805

（number of issued reads. This is the total number of reads completed successfully.）

（number of sectors read. This is the total number of sectors read successfully.）

（number of milliseconds spent reading. This is the total number of milliseconds spent by all reads (as measured from __make_request() to end_that_request_last()).）

（number of writes completed. This is the total number of writes completed successfully.）

（number of writes merged Reads and writes which are adjacent to each other may be merged for efficiency. Thus two 4K reads may become one 8K read before it is ultimately handed to the disk, and so it will be counted (and queued) as only one I/O. This field lets you know how often this was done.）

（number of sectors written. This is the total number of sectors written successfully.）

（number of milliseconds spent writing This is the total number of milliseconds spent by all writes (as measured from __make_request() to end_that_request_last()).）

（number of I/Os currently in progress. The only field that should go to zero. Incremented as requests are given to appropriate request_queue_t and decremented as they finish.）

（number of milliseconds spent doing I/Os. This field is increased so long as field 9 is nonzero.）

（number of milliseconds spent doing I/Os. This field is incremented at each I/O start, I/O completion, I/O merge, or read of these stats by the number of I/Os in progress (field 9) times the number of milliseconds spent doing I/O since the last update of this field. This can provide an easy measure of both I/O completion time and the backlog that may be accumulating.）

# vi /usr/local/zabbix-2.2.9/etc/zabbix_agentd.conf

 1 2 3 4 5 6 7 8 9 UnsafeUserParameters=1 UserParameter=custom.vfs.dev.read.ops[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$4}' //磁盘读的次数 UserParameter=custom.vfs.dev.read.ms[*],cat /proc/diskstats | grep 1 | head -1 | awk '{print$$7}' //磁盘读的毫秒数 UserParameter=custom.vfs.dev.write.ops[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$8}' //磁盘写的次数 UserParameter=custom.vfs.dev.write.ms[*],cat /proc/diskstats | grep 1 | head -1 | awk '{print$$11}'                  //磁盘写的毫秒数 UserParameter=custom.vfs.dev.io.active[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$12}' UserParameter=custom.vfs.dev.io.ms[*],cat /proc/diskstats | grep 1 | head -1 | awk '{print$$13}' //花费在IO操作上的毫秒数 UserParameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$6}' //读扇区的次数（一个扇区的等于512B） UserParameter=custom.vfs.dev.write.sectors[*],cat /proc/diskstats | grep 1 | head -1 | awk '{print$$10}'          //写扇区的次数（一个扇区的等于512B）

 1 2 3 4 5 6 # /usr/local/zabbix-2.2.9/bin/zabbix_get -s 192.168.20.100 -p 10050 -k 'custom.vfs.dev.read.ops[sda]' 2308 # /usr/local/zabbix-2.2.9/bin/zabbix_get -s 192.168.20.100 -p 10050 -k 'custom.vfs.dev.write.ms[sda]' 1509 # /usr/local/zabbix-2.2.9/bin/zabbix_get -s 192.168.20.100 -p 10050 -k 'custom.vfs.dev.write.ops[sda]' 386

zabbix web浏览器操作：

1、添加指标：思路：首先添加模板 ，然后在模板上添加item。

configuration——templates——右上角点create templates ，填写模板名称，并加入到一个组；

2、进入新创建的模板——items，右上角create items

Key:          custom.vfs.dev.write.sectors[sda]

Units:        B/sec

Store value: speed per second

Use custom multiplier     512

Key:          custom.vfs.dev.write.ops[sda]

Units:        ops/second

Store value: speed per second

Key:         custom.vfs.dev.write.ms[sda]

Units:      ms

Store value: speed per second

3、进入新创建的模板——graphs，右上角点create graphs，填写name，添加item项目，选择图形类型

4、拷贝创建好的items、graphs复制到需要监控的主机里

5、Monitoring——graps，选择Group，host，graph项目，监控出图；

zabbix监控磁盘IO到此为止，针对有多块硬盘的机器可以编写脚本，自动提取硬盘名称进行监控；

Java - IO输入输出流
Java - IO输入输出流
18 0
IO实战篇：数据排序处理深入 | 带你学《Java语言高级特性》之七十六

718 0
IO实战篇：奇偶数统计 | 带你学《Java语言高级特性》之七十七

942 0
Java基础17：Java IO流总结

1269 0
JAVA IO流 字节流 字符流 缓冲流的注意点和效率

1705 0
JAVA之旅（三十）——打印流PrintWriter，合并流，切割文件并且合并，对象的序列化Serializable，管道流，RandomAccessFile，IO其他类，字符编码
JAVA之旅（三十）——打印流PrintWriter，合并流，切割文件并且合并，对象的序列化Serializable，管道流，RandomAccessFile，IO其他类，字符编码 一.打印流PrintWriter 打印流有PrintWriter和PrintStream,他的特点可以直接操作输.
957 0
java io之管道流
一、java.io中存在一中流叫管道流，类似管道的功能。PipedOutputStream和PipedInputStream分别是管道输出流和管道输入流。这个两个流必须同时使用。 　　二、作用：进行两个线程间的通信。
970 0
Java中IO流，输入输出流概述与总结

1314 0
Java IO--管道流PipedOutputStream/PipedInputStream
<h1>管道流</h1> <div> <img src="http://img.blog.csdn.net/20131102090153781" alt=""><br> </div> <div> <pre name="code" class="java">import java.io.* ; class Send implements Runnable{ // 线程类 priva
1199 0
+关注
1338

0