Zabbix I/O monitoring
Basic principle: monitors IO performance by analyzing the/proc/diskstats file. Explanation:
++'S explanation of/proc/diskstats ++ [root @ localhostbin] # cat/proc/diskstats | grep sda | head-18 0 sda 73840 10263 3178156 91219 1110085 4192562 42423152 0 1275861 447798 1366379
The first to third domains are the master device number, secondary device number, and device name.
4th domains:Number of reads completed ----- Number of reads to the disk, total number of successful reads.
(Number of issued reads. This is the total number of reads completed successfully .)
5th domains:Number of merge reads completed, 9th domains:Number of times of merge write completion. For efficiency, adjacent reads and writes may be merged. Therefore, two 4 K reads may become an 8 K read before being processed to the disk. Therefore, only one I/O operation is performed. This domain allows you to know how frequently such operations are performed.
(Number of reads merged)
6th domains: Number of read sectors, total number of successfully read sectors.
(Number of sectors read. This is the total number of sectors read successfully .)
7th fields: the number of milliseconds consumed by reading, which is the number of milliseconds consumed by all read Operations (measured by _ make_request () to 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 ()).)
8th domains:Number of completed writes-the number of completed writes and the total number of successful writes.
(Number of writes completed. This is the total number of writes completed successfully .)
9th domains:Number of merged writes ----- the number of merged writes.
(Number of writes merged Reads and writes which are adjacent to each other may be merged for efficiency. thus two 4 K reads may become one 8 K 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 .)
10th domains:Number of write sectors ---- Number of write sectors, total number of successful write sectors.
(Number of sectors written. This is the total number of sectors written successfully .)
11th domains:The number of milliseconds that a write operation takes-the number of milliseconds that a write operation takes (measured by _ make_request () to 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 ()).)
12th domains:Number of input/output requests being processed -- current progress of-I/O, only this field should be 0. When a request is handed over to the appropriate request_queue_t, the addition and request Completion Time are reduced.
(Number of I/OS currently in progress. The only field that shoshould go to zero. Incremented as requests are given to appropriate request_queue_t and decremented as they finish .)
13th fields: the number of milliseconds that an input/output operation takes-the number of milliseconds that an I/O operation takes. This field will increase as long as field 9 is not 0.
(Number of milliseconds spent doing I/OS. This field is increased so long as field 9 is nonzero .)
14th domains:Weighted millisecond count for input/output operations ----- weighted, millisecond count for I/O operations. Each time I/O starts, I/O ends, this field is added when I/O is merged. This provides a convenient measurement standard for I/O completion time and storage that can be accumulated.
(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 .)
++ ++ ++ ++
Next, perform operations in the configuration file of zabbix agent:
Vi/usr/local/zabbix/etc/zabbix_agentd.conf
UserParameter = custom. vfs. dev. read. ops [*], cat/proc/diskstats | grep $1 | head-1 | awk '{print $4}' // Number of disk reads UserParameter = custom. vfs. dev. read. ms [*], cat/proc/diskstats | grep $1 | head-1 | awk '{print $7}' // Number of disk reads in milliseconds UserParameter = custom. vfs. dev. write. ops [*], cat/proc/diskstats | grep $1 | head-1 | awk '{print $8}' // Number of disk writes UserParameter = custom. vfs. dev. write. ms [*], cat/proc/diskstats | grep $1 | head-1 | awk '{print $11}' // Number of disk writes in milliseconds 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}' // Number of milliseconds spent on IO operations UserParameter = custom. vfs. dev. read. sectors [*], cat/proc/diskstats | grep $1 | head-1 | awk '{print $6 }'//Number of times the slice is read (the value of one slice is B) UserParameter = custom. vfs. dev. write. sectors [*], cat/proc/diskstats | grep $1 | head-1 | awk '{print $10}' // writeNumber of slice (the number of slice equals B)
The test command is as follows:[Root @ localhostbin] #./zabbix_get-s 10.2.11.11-p 10050-k custom. vfs. dev. write. ops [sda]
111153
Add indicator: Train of Thought: First add template, then add item on template.
Metric details:
First metric Name: Disk: $1: Read: Bytes/sec Key: custom. vfs. dev. read. sectors [sda] Units: B/sec Store value: speed per second // The difference value is calculated. Use M multiplier 512 // The value is multiplied by 512 because it is a sector, convert to 512B
Similarly, for other metrics, add the following:
Second Metric: 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
Third Metric: Name: Disk: $1: Read: ops per second Key: custom. vfs. dev. read. ops [sda] Units: ops/second Store value: speed per second
Fourth Metric: Name: Disk: $1: Write: ops per second Key: custom. vfs. dev. write. ops [sda] Units: ops/second Store value: speed per second
5 metric: Name: Disk: $1: Read: ms Key: custom. vfs. dev. read. ms [sda] Units: ms Store value: speed per second
Sixth Metric: Name: Disk: $1: Write: ms Key: custom. vfs. dev. write. ms [sda] Units: ms Store value: speed per second