How does zabbix monitor linux disk performance
This article focuses on "how zabbix monitors linux disk performance". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how zabbix monitors the performance of linux disks.
Zabbix is an enterprise-level distributed open source monitoring solution, which can monitor the health and integrity of many network parameters and servers. It uses flexible alarm mechanism and allows users to configure email-based alarms for almost any event. This allows users to respond quickly to server problems.
Premise environment
Perl and python, as well as zabbix-agent are already available.
Indicators that need to be monitored
1: IO per second, i.e. iops or tps2: throughput 3: average IO size, avgrq-sz4:IO wait queue length, avgqu-sz5: percentage of disk activity time, util
Install iostat tools
Yum install sysstat-y # centos7 installs the iostat tool, which comes with centos6 before
Create a directory on the agent side to store the execution script and modify the permissions
Mkdir / usr/lib/zabbix/alertscripts/-pchown zabbix:zabbix / usr/lib/zabbix/-R
Create a disk discovery script in the / usr/lib/zabbix/alertscripts/ directory
Cd / usr/lib/zabbix/alertscripts/vim discoverables disk.plated prints; cd / usr/lib/zabbix/alertscripts/vim discoverables disk.plated prints; returns Proxmox VM namesub get_vmname_by_id {$vmname= `cat / etc/qemu-server/$_ [0] .conf | grep name | cut-d\:-f 2`; $vmname= ~ s / ^\ s hammer; # remove leading spaces $vmname= ~ s /\ s cards; # remove trailing spaces return $vmname} $first = 1 leading print "{\ n"; print "\ t\" data\ ": [\ n\ n" For (`disk; / proc/ diskstats`) {($major,$minor,$disk) = m / ^\ s * ([0-9] +)\ s + ([0-9] +)\ s + (\ S +)\ s.Splash; $dmnamefile = "/ sys/dev/block/$major:$minor/dm/name"; $vmid= ""; $vmname = ""; $dmname = $disk; $diskdev = "/ dev/$disk"; # DM name if (- e $dmnamefile) {$dmname = `cat $dmnamefile`; $dmname = ~ s /\ nhammer / # remove trailing\ n $diskdev = "/ dev/mapper/$dmname"; # VM name and ID if ($dmname = ~ m / ^. *-([0-9] +) -. * $/) {$vmid = $1; # $vmname = get_vmname_by_id ($vmid);} # print ("$major $minor $disk $diskdev $dmname $vmid $vmname\ n"); print "\ t,\ n" if not $first; $first = 0; print "\ t {\ n" Print "\ t\ t\" {# DISK}\ ":\" $disk\ ",\ n"; print "\ t\ t\" {# DMNAME}\ ":\" $dmname\ ",\ n"; print "\ t\ t\" {# VMNAME}\ ":\" $vmname\ ",\ n"; print "\ t\ t\" {# VMID}\ ":\" $vmid\ "\ n"; print "\ t}\ n";} print "\ n\ t]\ n"; print "}\ n"
Create the files needed to define key under the / usr/lib/zabbix/alertscripts/ directory to obtain the io monitoring values
Vim zbxflowers parseurs iostatstatuses values.shedding statuses binds pact bashdevaver cities 1typecompatible values 2 debug modedebug=0if [[- z "$dev"]]; then echo "error: wrong input value (device)" exit 1fiif [[- z "$type"]]; then echo "error: wrong input value (type)" exit 1ficolumns = `iostat-xN | egrep-o "^ Device.*" `columnsarray= ($columns) column_id=1for I in "${columnsarray [@]}" do # echo "column: $I" if [["$I" = "$type"]] Then if [[$debug-eq 1]] Then echo "right column (${I}) found...column_id: $column_id" fi id= "$" column_id_id=$id$column_id iostats= `iostat-xN | egrep-o "^ ${dev} [[: space:]] +. *" | awk "{print ${column_id_id}" `fi column_id=$ [column _ id + 1] doneif [- z "$iostats"] Then echo "error:\" device\ "or\" type\ "not found (${dev}, ${type})" exit 3fiiostatsprincipals = `wc-l "$iostats" `if [$iostats_lines-ne 1]; then echo "error: wrong output value (${iostats_lines})" exit 2fiecho $iostatsif [[$debug-eq 1]] Then echo "-" echo $columns iostats_debug= `iostat-xN | egrep-o "^ ${dev} [[: space:]] +. *" `echo $iostats_debug echo "- -" fiexit 0 "
Give execution permissions to the two files you just created
Chmod + x / usr/lib/zabbix/alertscripts/*
Add the following to the configuration file of zabbix-agent
Vim / etc/zabbix/zabbix_agentd.conf# diskio discoveryUserParameter=discovery.disks.iostats,/usr/lib/zabbix/alertscripts/discover_disk.plUserParameter=custom.vfs.dev.iostats.rrqm [*], / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "rrqm/s" UserParameter=custom.vfs.dev.iostats.wrqm [*], / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "wrqm/s" UserParameter=custom.vfs.dev.iostats.rps [*] / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "rgamma's" UserParameter=custom.vfs.dev.iostats.wps [*], / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "wgamble s" UserParameter=custom.vfs.dev.iostats.avgrq [*], / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "avgrq-sz" UserParameter=custom.vfs.dev.iostats.avgqu [*] Usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "avgqu-sz" UserParameter=custom.vfs.dev.iostats.await [*], / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "await" UserParameter=custom.vfs.dev.iostats.svctm [*], / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "svctm" UserParameter=custom.vfs.dev.iostats.util [*] / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "% util" UserParameter=custom.vfs.dev.iostats.rkB [*], / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "rkB/s" UserParameter=custom.vfs.dev.iostats.wkB [*], / usr/lib/zabbix/alertscripts/zbx_parse_iostat_values.sh $1 "wkB/s"
Restart the zabbix-agent side
Systemctl restart zabbix-agent.service
Download and import the zabbix template file for linux disk
Wget https://qiniu.wsfnk.com/Template_Linux_Disk_IO_Stats.xml
Import the template Template_Linux_Disk_IO_Stats.xml as required in the figure
Create a regular expression to discover the disk, which the template needs to use
# the name here must be it. It is recommended to copy and paste "Linux disks for autodiscovery".
Link the host to the template
View Drawin
At this point, I believe you have a deeper understanding of "how zabbix monitors linux disk performance". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!