当前位置: 首页 > news >正文

zabbix监控磁盘IO

监控磁盘IO的基本原理:通过分析/proc/diskstats文件,来对IO的性能进行监控。

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

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

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

解释说明:

第一至第三个域,分别是主设备号,次设备号,设备名称

第4个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数。 

(number of issued reads. This is the total number of reads completed successfully.)

第5个域:合并读完成次数, 第9个域:合并写完成次数。为了效率可能会合并相邻的读和写。从而两次4K的读在它最终被处理到磁盘上之前可能会变成一次8K的读,才被计数(和排队),因此只有一次I/O操作。这个域使你知道这样的操作有多频繁。

(number of reads merged)

第6个域:读扇区的次数,成功读过的扇区总次数。 

(number of sectors read. This is the total number of sectors read successfully.)

第7个域:读花费的毫秒数,这是所有读操作所花费的毫秒数(用__make_request()到end_that_request_last()测量)。

(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()).)

第8个域:写完成次数 ----写完成的次数,成功写完成的总次数。

(number of writes completed. This is the total number of writes completed successfully.)

第9个域:合并写完成次数 -----合并写次数。

(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.)

第10个域:写扇区次数 ---- 写扇区的次数,成功写扇区总次数。

(number of sectors written. This is the total number of sectors written successfully.)

第11个域:写操作花费的毫秒数  ---  写花费的毫秒数,这是所有写操作所花费的毫秒数(用__make_request()到end_that_request_last()测量)。

(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()).)

第12个域:正在处理的输入/输出请求数 -- -I/O的当前进度,只有这个域应该是0。当请求被交给适当的request_queue_t时增加和请求完成时减小。

(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.)

第13个域:输入/输出操作花费的毫秒数  ----花在I/O操作上的毫秒数,这个域会增长只要field 9不为0。

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

第14个域:输入/输出操作花费的加权毫秒数 -----  加权, 花在I/O操作上的毫秒数,在每次I/O开始,I/O结束,I/O合并时这个域都会增加。这可以给I/O完成时间和存储那些可以累积的提供一个便利的测量标准。

(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.)


环境说明:CentOS6.6 32位系统、zabbix2.2.9

前提已经安装好zabbix服务端和客户端

客户端上操作(IP为:192.168.20.100):

修改客户端配置文件

# 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 ,填写模板名称,并加入到一个组;

spacer.gifwKiom1YCboSQQ2rsAANa7hbD7-Q986.jpg

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

spacer.gifwKioL1YCbvORpAgDAALKxQHOKxk071.jpg


指标细节:

第一个指标Name:      Disk:$1:Read:Bytes/sec

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

                  Units:        B/sec

                  Store value: speed per second    //差量每秒速率,会进行差值计算

                  Use custom multiplier     512      //会对值乘以512,因为这里是一个扇区,转换为字节为512B

spacer.gifwKiom1YCby2DqFESAAKVnLFeOAw492.jpg

同理,其他指标方式,添加如下: 

第二个指标:Name:      Disk:$1:Write:Bytes/sec

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

                  Units:        B/sec

                  Store value: speed per second

                  Use custom multiplier     512

第三个指标:Name:      Disk:$1:Read:ops per second

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

                  Units:        ops/second

                  Store value: speed per second

第四个指标:Name:      Disk:$1:Write:ops per second

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

                  Units:        ops/second

                  Store value: speed per second

第五个指标:Name:     Disk:$1:Read:ms

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

                  Units:      ms

                  Store value: speed per second

第六个指标:Name:     Disk:$1:Write:ms

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

                  Units:      ms

                  Store value: speed per second


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

spacer.gifwKioL1YCb32BBVVrAAJLaZLC76g322.jpg

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

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

wKiom1YCb7iD5KBJAAPHnwFW2gY058.jpg


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






本文转自 模范生 51CTO博客,原文链接:http://blog.51cto.com/mofansheng/1697548,如需转载请自行联系原作者

相关文章:

  • TimSort排序算法及一个问题分析
  • Linux平时常用命令_查看进程_监控日志等命令
  • 参观移动公司机房感想
  • linux head
  • RHCE学习13RHCS集群(RHCS+GFS2+ISCSI)
  • 【BZOJ】2733: [HNOI2012]永无乡
  • 网络通信原理及要素
  • python脚本采集服务器数据通过API提交到django web服务器,然后展示在页面上
  • Linux下搭建NFS服务器
  • shell整理(38)===凯撒加密和解密
  • 使用embulk从Oracle抽取数据到trafodion
  • dubbo 服务中间件 的使用
  • [zabbix/自动发现规则]
  • 项目管理:项目中什么叫完成,传统瀑布开发与敏捷开发的完成标准是什么??...
  • php如何发post请求
  • 230. Kth Smallest Element in a BST
  • CSS 三角实现
  • ES6 ...操作符
  • gitlab-ci配置详解(一)
  • GitUp, 你不可错过的秀外慧中的git工具
  • Java 11 发布计划来了,已确定 3个 新特性!!
  • Java多态
  • Nginx 通过 Lua + Redis 实现动态封禁 IP
  • Solarized Scheme
  • vagrant 添加本地 box 安装 laravel homestead
  • 初识MongoDB分片
  • 从setTimeout-setInterval看JS线程
  • 从地狱到天堂,Node 回调向 async/await 转变
  • 动手做个聊天室,前端工程师百无聊赖的人生
  • 工作踩坑系列——https访问遇到“已阻止载入混合活动内容”
  • 构造函数(constructor)与原型链(prototype)关系
  • 利用阿里云 OSS 搭建私有 Docker 仓库
  • 排序(1):冒泡排序
  • 前端面试总结(at, md)
  • 实习面试笔记
  • 智能合约开发环境搭建及Hello World合约
  • ​520就是要宠粉,你的心头书我买单
  • #Java第九次作业--输入输出流和文件操作
  • (06)金属布线——为半导体注入生命的连接
  • (2)STL算法之元素计数
  • (4)事件处理——(6)给.ready()回调函数传递一个参数(Passing an argument to the .ready() callback)...
  • (a /b)*c的值
  • (NO.00004)iOS实现打砖块游戏(九):游戏中小球与反弹棒的碰撞
  • (力扣)1314.矩阵区域和
  • (三)Honghu Cloud云架构一定时调度平台
  • (转)eclipse内存溢出设置 -Xms212m -Xmx804m -XX:PermSize=250M -XX:MaxPermSize=356m
  • .“空心村”成因分析及解决对策122344
  • .NET Core工程编译事件$(TargetDir)变量为空引发的思考
  • .net core控制台应用程序初识
  • .NET Core实战项目之CMS 第十二章 开发篇-Dapper封装CURD及仓储代码生成器实现
  • .NET MVC第三章、三种传值方式
  • /bin/rm: 参数列表过长"的解决办法
  • /proc/stat文件详解(翻译)
  • [.NET 即时通信SignalR] 认识SignalR (一)
  • [100天算法】-二叉树剪枝(day 48)