Zabbix LLD Discovery Disk Monitoring

Source: Internet
Author: User

First, the software version

Operating system: centos-6.5-x86_64

Zabbix version: 3.0.3

Second, script writing:

1. python version:

#!/usr/bin/env python

Import JSON

Import subprocess

Def get_disk ():

cmd = "" "Grep-e" (vd[a-z]$|sd[a-z]$) "/proc/partitions|awk ' {print $4} '" "

Disk_data = subprocess. Popen (cmd, shell=true, stdout=subprocess. PIPE, Stderr=subprocess. STDOUT)

Disk_total = []

Disktotal_dict = {"Data": None}

For Dev in Disk_data.stdout.readlines ():

Disk_dict = {}

disk_dict["{#DISKNAME}"]=dev.strip ("\ n"). Strip ()

Disk_total.append (disk_dict)

disktotal_dict["Data"]=disk_total

Jsonstr = Json.dumps (disktotal_dict, Sort_keys=true, indent=4)

Return JSONSTR

if __name__ = = "__main__":

Print Get_disk ()

2 , Shell script version:

#!/bin/bash

disk_array= (' grep-e ' (vd[a-z]$|sd[a-z]$) "/proc/partitions|awk ' {print $4} ')

length=${#disk_array [@]}

printf "{\ n"

printf ' \ t ' "\" data\ ": ["

For ((i=0;i< $length; i++))

Do

printf ' \n\t\t{'

printf "\" {#DISKNAME}\ ": \" ${disk_array[$i]}\ "}"

If [$i-lt $[$length-1]];then

printf ', '

Fi

Done

printf "\n\t]\n"

printf "}\n"

Third, Key's view resolution: The main/proc/diskstats file read:

1, read the specific file analysis:

[Email protected] ~]# Cat/proc/diskstats | grep SDA

8 0 SDA 844141 181483 43038400 10926021 147765030 3756991779 31237698668 4206792245 0 52927059 4217644644

# #每一项解读:

844141 181483 43038400 10926021 147765030 3756991779 31237698668 4206792245 0 52927059 4217644644

First zone: Number of reads completed-----read disk, total number of times the read was completed successfully.

Second zone: Merge read completed, 6th field: Number of merge writes completed. For efficiency, adjacent reads and writes may be merged. Thus two times 4K of reading before it is finally processed to disk may become a 8K read before it is counted (and queued), so there is only one I/O operation. This field lets you know how frequently such operations are done.

3rd field: Number of read sectors, total number of sectors successfully read.

4th domain: The number of milliseconds spent reading, which is the number of milliseconds spent on all read operations

5th zone: The number of write completion times----Write completed, the total number of successful write completed.

6th region: Number of merge writes-----merge write times.

7th field: Number of write sectors----write sector, total number of successful write sectors.

8th domain: The number of milliseconds the write operation spends---the number of milliseconds it takes to write, which is the number of milliseconds spent on all writes

9th domain: The number of input/output requests being processed---the current progress of I/O, only this domain should be 0. Decreases when the request is submitted to the appropriate request_queue_t and the request is completed.

10th domain: The number of milliseconds spent in an input/output operation----The number of milliseconds spent on I/O operations, and this field grows as long as field 9 is not 0.

11th domain: The weighted number of milliseconds that the input/output operation spends-----weighted, the milliseconds spent on I/O operations, and the domain increases at the beginning of each I/O, I/O, and I/O merges. This can provide a convenient measurement standard for I/O completion time and storage for those that can accumulate.

2, write several monitoring items of agnet key:

Userparameter=custom.vfs.dev.read.ops[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$4} ' # # #读磁盘完成的次数

Userparameter=custom.vfs.dev.read.ms[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$7} ' # # #读花费的毫秒数

Userparameter=custom.vfs.dev.write.ops[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$8} ' # # #写完成的次数

Userparameter=custom.vfs.dev.write.ms[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$11} ' # # #写操作花费的毫秒数

Userparameter=custom.vfs.dev.io.active[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$12} ' # # #当前的IO情况

Userparameter=custom.vfs.dev.io.ms[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$13} ' # # #花在I number of milliseconds on/O operations

Userparameter=custom.vfs.dev.read.sectors[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$6} ' # #读取扇区次数

Userparameter=custom.vfs.dev.write.sectors[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$10} ' # #写扇区次数

Zabbix LLD Discovery Disk Monitoring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.