概述

zabbix获取/sys里面的磁盘信息并分析来监控disk performance

sysfs是Linux内核中设计较新的一种虚拟的基于内存的文件系统,它的作用与 proc 有些类似(默认挂载在/sys)

sysfs is a pseudo file system provided by the Linux kernel that exports information about various kernel subsystems, hardware devices, and associated device drives from the kernel's device model to user space through virtual files. In addition to providing information about various devices and kernel subsystems, exported virtual files are also used for their configuring. (维基百科的解释)

原理

查看磁盘,分区状态值的统计信息

/sys/block/<dev>/stat

[root@test ~]# cat /sys/class/block/sda/stat
                                       
Field   Name            units         description
----- ---- ----- -----------
read I/Os requests number of read I/Os processed
read merges requests number of read I/Os merged with in-queue I/O
read sectors sectors number of sectors read
read ticks milliseconds total wait time for read requests
write I/Os requests number of write I/Os processed
write merges requests number of write I/Os merged with in-queue I/O
write sectors sectors number of sectors written
write ticks milliseconds total wait time for write requests
in_flight requests number of I/Os currently in flight
io_ticks milliseconds total time this block device has been active
time_in_queue milliseconds total wait time for all requests

merge:读取/写请求有多少被Merge了(当系统调用需要读取/写数据的时候, VFS将请求发到各个分区, 如果分区发现不同的读取/写请求的是相同Block的数据,

FS会将这个请求合并Merge),所以磁盘读写吞吐量(throughput)= 读写扇区(field3,7)次数 * 扇区大小 / 时间s,而不是读写merge后的iops(field1,5)

ps: 除了Field 9其他的Field都是自上次系统启动后的累加值

配置

定义zabbix监控item的配置文件

# disk_discovery
UserParameter=custom.vfs.discover_disks,/m2odata/server/zabbix-agent/scripts/lld-disks.py
# disk_stats
UserParameter=custom.vfs.dev.read.ops[*],awk '{print $$1}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.read.merged[*],awk '{print $$2}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.read.sectors[*],awk '{print $$3}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.read.ms[*],awk '{print $$4}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.write.ops[*],awk '{print $$5}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.write.merged[*],awk '{print $$6}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.write.sectors[*],awk '{print $$7}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.write.ms[*],awk '{print $$8}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.io.active[*],awk '{print $$9}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.io.ms[*],awk '{print $$10}' /sys/class/block/$/stat
UserParameter=custom.vfs.dev.weight.io.ms[*],awk '{print $$11}' /sys/class/block/$/stat

磁盘自动发现规则

lld-disk.py

#!/usr/bin/env python

import os
import re
import json def Devices(diskdir, skippable):
raw_devices = (device for device in os.listdir(diskdir) if not any(ignore in device for ignore in skippable))
devices = (device for device in raw_devices if re.match(r'^\w{3}$', device)) # 保留整块磁盘 去掉分区, such as remove sda1 sdb2
data = [{"{#DEVICENAME}": device} for device in devices]
print(json.dumps({"data": data}, indent=4)) if __name__ == "__main__":
# Iterate over all block devices, but ignore them if they are in the skippable set
diskdir = "/sys/class/block"
skippable = ("sr", "loop", "ram", "dm")
Devices(diskdir, skippable)

重启zabbix_agentd使配置文件生效

服务器端  # 创建监控disk模板(Template Disk Performance)

Discovery rule

Item prototypes

创建Graph prototype(iops,throughput)

查看graph

zabbix后台 Monitoring->Graphs->对应的graph

参考:

/sys/block/<dev>/stat:  https://www.kernel.org/doc/Documentation/block/stat.txt

/proc/diskstats:  https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats

iostat:  https://www.kernel.org/doc/Documentation/iostats.txt

github:  https://github.com/grundic/zabbix-disk-performance

Zabbix监控disk performance的更多相关文章

  1. Zabbix监控mysql performance

    介绍 zabbix监控mysql性能,使用zabbix自带的mysql监控模板,可以监控以下内容OPS(增删改查).mysql慢查询数量.mysql请求\响应流量带宽 配置 新建mysql监控用户 G ...

  2. 使用percona-xtrabackup实现对线上zabbix监控系统数据库mariadb5.5.47的主从同步

    使用percona-xtrabackup实现对线上zabbix监控系统数据库的主从同步 业务背景: zabbix3.0.4是业务的主要监控,部署在一台单机中,为避免数据丢失先对其做数据主从同步,因主数 ...

  3. zabbix监控Oracle

    可监控项 使用zabbix监控oracle数据库需要借助第三方的插件,目前使用较多的是orabbix.目前维护到了1.2.3版本.关于oracle自带的监控项目有以下几个: DB Version (i ...

  4. zabbix监控Mysql中的QPS/TPS

    今天我们来了解一下如何通过zabbix监控来监控我们msyql数据库中的TPS和QPS,提到这两个概念,我们先来了解究竟什么是QPS,TPS呢?它们是如何计算得到的呢?我们来看一下 QPS(Quest ...

  5. contos7 使用zabbix监控物理磁盘状态实例

    一.系统环境: 物理机:dell R640 操作系统:centos7 二.安装MegaCli 监控主要是通过MegaCli 软件获取到物理主机的read及硬盘相关状态信息.然后通过zabbix的自定义 ...

  6. 【zabbix告警监控】配置zabbix监控nginx服务

    zabbix监控nginx,nginx需要添加--with-http_stub_status模块 使用zabbix监控nginx,首先nginx需要配置开启ngx_status.但是我这边nginx安 ...

  7. 01.Zabbix监控快速入门

    1.监控知识基本概述 1.为什么要使用监控 1.对系统不间断实时监控 2.实时反馈系统当前状态 3.保证服务可靠性安全性 4.保证业务持续稳定运行 2.如何进行监控,比如我们需要监控磁盘的使用率 1. ...

  8. zabbix监控添加学习笔记

    在实际生产环境中,除了CPU.内存等一些系统信息可以挂载zabbix的自带模板Template OS Linux:但是一些公司开发的定制服务需要自己写模板或者监控项去监控: 一.监控公司的java服务 ...

  9. 使用Zabbix监控Oracle数据库

    Orabbix介绍 监控Oracle数据库我们需要安装第三方提供的Zabbix插件,我们先测试比较有名的Orabbix,http://www.smartmarmot.com/product/orabb ...

随机推荐

  1. 在 ASP.NET MVC 中充分利用 WebGrid (microsoft 官方示例)

    在 ASP.NET MVC 中充分利用 WebGrid https://msdn.microsoft.com/zh-cn/magazine/hh288075.aspx Stuart Leeks 下载代 ...

  2. 开源代码:Http请求封装类库HttpLib介绍、使用说明

    今天介绍一个很好用的Http请求类库--Httplib.一直以来,我们都是为了一次web请求,单独写一段代码 有了这个类,我们就可以很方便的直接使用了. 项目介绍: http://www.suchso ...

  3. sql优化阶段性总结以及反思

    Sql优化思路阶段性心得: 这段时间的优化做了好几个案例,其实有很多的类似点,都是好几张大表的相互连接,然后执行长达好几个小时,甚至都跑不出来. 自己差不多的思路就是Parallel full tab ...

  4. .NET应用架构设计—面向查询的领域驱动设计实践(调整传统三层架构,外加维护型的业务开关)

    阅读目录: 1.背景介绍 2.在业务层中加入核心领域模型(引入DomainModel,让逻辑.数据有家可归,变成一个完整的业务对象) 3.统一协调层Application Layer(加入协调层来转换 ...

  5. openstack想说爱你不容易

    网上一牛人的博客专门写的是关于openstack的,看晕了.先收藏下.猛击下面的地址 http://www.cnblogs.com/popsuper1982/

  6. Java 对象初始化

      对象A的创建过程: 1. 构造器实际上是静态方法.当首次创建对象A 或者 A类的静态方法/静态域首次被访问时,Java解释器查找类路径,以定位     A.class文件.(当程序创建第一个对类的 ...

  7. 浏览器请求页面时Etag和cache的区别

    etag:简单的说就是服务器收到客户端的请求后,根据返回的内容计算出来一个etag值,返回给客户端,当客户端下次再请求相同路径的时候会带上之前的etag值,服务器端会根据这次请求应该返回的内容计算出新 ...

  8. Release Management 安装 之 集成TFS

    集成TFS时需要在TFS服务器执行 tfssecurity /g+ "Team Foundation Service Accounts" n:ALM\rmtfsint ALLOW ...

  9. 2.一个EJB的小Demo

    新建一个java普通项目即可 这里用到了Jboss,需要安装Jboss,然后进入jboss-4.2.3.GA\client目录,拷贝所有的jar包到本项目的lib下. 3个接口分别如下所示: publ ...

  10. 三种方法查看MySQL数据库的版本

    1.使用-V参数 首先我们想到的肯定就是查看版本号的参数命令,参数为-V(大写字母)或者--version 使用方法: D:\xampp\mysql\bin>mysql -V 或者 D:\xam ...