当前位置:网站首页>Dynamically monitor disk i/o with ZABBIX
Dynamically monitor disk i/o with ZABBIX
2022-07-03 11:48:00 【Brother Xing plays with the clouds】
Recently in to see Linux I/O Subsystem related information , Need to monitor each The server Of disks I/O, especially MongoDB database The server Of disks I/O, Because each one The server The disk names of may be different , So you need to use Zabbix Of LLD Function to discover disks and monitor I/O
Reference article
http://www.programering.com/a/MDOwYDNwATc.html
1. Write the steps to discover disk
shell edition disk_discovery.sh
#!/bin/bash
diskarray=(`cat /proc/diskstats |grep -E "\bsd[a-z]\b|\bxvd[a-z]\b|\bvd[a-z]\b"|awk '{print $3}'|sort|uniq 2>/dev/null`)
length=${#diskarray[@]}
printf "{\n"
printf '\t'"\"data\":["
for ((i=0;i<$length;i++))
do
printf '\n\t\t{'
printf "\"{#DISK_NAME}\":\"
if [ i -lt [
printf ','
fi
done
printf "\n\t]\n"
printf "}\n"
$ sh disk_discovery.sh
{
"data":[
{"{#DISK_NAME}":"xvda"},
{"{#DISK_NAME}":"xvdb"}
]
}
Python edition disk_discovery.py
#/usr/bin/python
#This script is used to discovery disk on the server
import subprocess
import json
args="cat /proc/diskstats |grep -E '\ssd[a-z]\s|\sxvd[a-z]\s|\svd[a-z]\s'|awk '{print $3}'|sort|uniq 2>/dev/null"
t=subprocess.Popen(args,shell=True,stdout=subprocess.PIPE).communicate()[0]
disks=[]
for disk in t.split('\n'):
if len(disk) != 0:
disks.append({'{#DISK_NAME}':disk})
print json.dumps({'data':disks},indent=4,separators=(',',':'))
$ python disk_discovery.py
{
"data":[
{
"{#DISK_NAME}":"xvda"
},
{
"{#DISK_NAME}":"xvdb"
}
]
}
2. Write get disk I/O Script for information
Use iostat Collect disks I/O Information
#/bin/sh
device=$1
item=$2
/usr/bin/iostat -dxkt 1 5 > /tmp/iostat_output 2>/dev/null
case $item in
rrqm)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
wrqm)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
rps)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
wps)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
rKBps)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
wKBps)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
avgrq-sz)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
avgqu-sz)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
await)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
svctm)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
util)
/usr/bin/tail -n20 /tmp/iostat_output |grep "\b
;;
esac
3. modify Zabbix agent The configuration file
add to disk_status.conf
Timeout=10
### Option: UserParameter
# User-defined parameter to monitor. There can be several user-defined parameters.
# Format: UserParameter=<key>,<shell command>
# See 'zabbix_agentd' directory for examples.
#
# Mandatory: no
# Default:
# UserParameter=
UserParameter=disk.discovery,/usr/bin/python /usr/local/zabbix/bin/disk_discovery.py
UserParameter=disk.status[*],/usr/local/zabbix/bin/disk_status.sh 1 2
Here we need to pay attention to ,Zabbix agent default Timeout The value is 3 second , Because of the use of iostat -ydxkt 1 3, every other 1 Refresh every second , Refresh 3 Time , So if you get disk information Timeout If the setting time is short, it will appear ZBX_NOTSUPPORTED Such a mistake
Then reload zabbix agent
4. By means of zabbix server or zabbix proxy End use zabbix_get Get disk information
$ /usr/local/zabbix/bin/zabbix_get -s 192.168.1.190 -p 10055 -k "disk.discovery"
{
"data":[
{
"{#DISK_NAME}":"xvda"
},
{
"{#DISK_NAME}":"xvdb"
},
{
"{#DISK_NAME}":"xvdc"
}
]
}
$ /usr/local/zabbix/bin/zabbix_get -s 192.168.1.190 -p 10055 -k "disk.status[xvda,wps]"10.00
边栏推荐
- 解决msvcp120d.dll和msvcr120d.dll缺失
- Vulnhub narak
- Gut | Yu Jun group of the Chinese University of Hong Kong revealed that smoking changes intestinal flora and promotes colorectal cancer (do not smoke)
- Visual Studio 2022下载及配置OpenCV4.5.5
- Mmc5603nj geomagnetic sensor (Compass example)
- C language utf8toutf16 (UTF-8 characters are converted to hexadecimal encoding)
- DNS多点部署IP Anycast+BGP实战分析
- Excel quick cross table copy and paste
- 《剑指offer 03》数组中重复的数字
- How to get started embedded future development direction of embedded
猜你喜欢

2022 northeast four provinces match VP record / supplementary questions

Kibana - installation and configuration of kibana

Arctangent entropy: the latest SCI paper in July 2022

uniapp scroll view 解决高度自适应、弹框滚动穿透等问题。

Cuiyusong, CTO of youzan: the core goal of Jarvis is to make products smarter and more reliable

After watching the video, AI model learned to play my world: cutting trees, making boxes, making stone picks, everything is good

聊聊Flink框架中的状态管理机制

2022年湖南工学院ACM集训第二次周测题解

解决msvcp120d.dll和msvcr120d.dll缺失

rxjs Observable filter Operator 的实现原理介绍
随机推荐
After watching the video, AI model learned to play my world: cutting trees, making boxes, making stone picks, everything is good
. \vmware-vdiskmanager. exe -k “c:\\xxxxx.vmdk”
vulnhub之cereal
Kibana~Kibana的安装和配置
MCDF实验1
STL tutorial 10 container commonalities and usage scenarios
DS90UB949
Hongmeng third training (project training)
ASP. Net hotel management system
STL tutorial 8-map
Arctangent entropy: the latest SCI paper in July 2022
Slam mapping and autonomous navigation simulation based on turnlebot3
Double linked list of linear list
GCC compilation process and dynamic link library and static link library
鸿蒙第三次培训(项目实训)
Using onvif protocol to operate the device
Internet socket (non) blocking write/read n bytes
R language uses grid of gridextra package The array function combines multiple visual images of the lattice package horizontally, and the ncol parameter defines the number of columns of the combined g
机器学习 3.2 决策树模型 学习笔记(待补)
动态规划(区间dp)