Zabbix simple use of custom keys

Source: Internet
Author: User

Zabbix version: zabbix-3.0.2


Zabbix Client Configuration:

Zabbix monitoring types are divided into server and server active (not sure which fits, can be selected)

In zabbix_agentd.conf hostname must be filled out, and can not be duplicated with other monitoring servers.


Before you can customize a key, you need to set the parameters first: Unsafeuserparameters=1

include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/# include=/usr/local/etc/zabbix_agentd.conf.d/*.conf####### user-defined monitored PARAMETERS ########## option:unsafeuserparameters# allow all characters to being passed in Argu ments to user-defined parameters.# 0-do not allow# 1-allow## mandatory:no# range:0-1# default:unsafeuser Parameters=1

Remove the comments from the previous include so that your custom key can be placed in the ZABBIX_AGENTD.CONF.D directory

[Email protected] zabbix_agentd.conf.d]# lsuserparameter_script.conf #名字自己随便取

You can customize the key under the userparameter_script.conf file

The following are flexible user-defined parameters

Userparameter=key[*],command

Parameters Description
Key Only. [*] indicates that multiple parameters can be passed inside
Command The script that needs to be executed, Key's [] inside parameter one by one corresponds to $9, altogether 9 parameters. $ A to indicate script commands

such as: Userparameter=get.os.type, Head-1/etc/issue

Restart ZABBIX_AGENTD When the above configuration is complete


If you define a key less than one or two, you can also add directly in the zabbix_agentd.conf

### 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=get.os.type, head -1 /etc/issueuserparameter= custom.vfs.dev.read.ops[*],cat /proc/diskstats | grep $1 | head -1 |  awk  ' {print $$4} ' userparameter=custom.vfs.dev.read.ms[*],cat /proc/diskstats |  grep $1 | head -1 | awk  ' {print $$7} ' userparameter= custom.vfs.dev.write.ops[*],cat /proc/diskstats | grep $1 | head -1 |  awk  ' {print $$8} ' Userparameter=custom.vfs.dev.write.ms[*],cat /proc/diskstats | grep $1 | head -1 |  awk  ' {print $$11} ' 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} ' userparameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats |  grep $1 | head -1 | awk  ' {print $$6} ' userparameter= Custom.vfs.dev.write.sectors[*],cat /proc/diskstats | grep $1 | head -1  | awk  ' {print $$10} '

Find Option:userparamete in the file can be found, add directly below, this is not to set the Unsafeuserparameters to 1, comments out can!

Userparameter=custom.vfs.dev.read.ops[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$4} '

Where the $ $ is in the execution key is required to add the parameter no person will error.

Verify that key can be used normally (the following command is checked on the Zabbix server)

[Email protected] opt]#/usr/local/zabbix-3.0.2/bin/zabbix_get-s 192.168.10.74-k Get.os.typeCentOS release 6.8 (Final )


Key with parameters

[Email protected] opt]#/usr/local/zabbix-3.0.2/bin/zabbix_get-s 192.168.10.74-k custom.vfs.dev.read.ops[sda1]681

Zabbix Service-side configuration

Configuration-Host-select host-Monitor item-Create monitoring item

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/82/B8/wKioL1dfdCLRnWK7AABg7JawqHE019.jpg "title=" 1.jpg " Width= "height=" 756 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:600px;height:756px; "alt=" Wkiol1dfdclrnwk7aabg7jawqhe019.jpg "/>

Once the above settings are complete, you can see if the data is available under the latest data

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/82/B9/wKiom1dfc4eCL9-ZAACwDWaGqzA585.jpg "style=" height : 571px; "title=" 2.jpg "width=" "height=" 571 "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiom1dfc4ecl9-zaacwdwagqza585.jpg "/>

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/82/B8/wKioL1dfdJmS95K6AACyoi7TfEA677.jpg "style=" height : 571px; "title=" 3.jpg "width=" "height=" 571 "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" Wkiol1dfdjms95k6aacyoi7tfea677.jpg "/>

Such a simple key is defined as complete. Of course, this key in the Zabbix comes with the key can also achieve this function, just for demonstration. Zabbix's own key is already very powerful and it has all the basic items that need to be monitored. You can go directly to the relevant documents!

Custom key scripts are not language-restricted, as long as the data can be returned!

such as: userparameter=free.disk,/usr/local/zabbix/bin/disk.py

Free.disk is the name of key,/usr/local/zabbix/bin/disk.py is the script that executes when the server side calls Free.disk this key, and the result is the return value of Free.disk. The script can be any scripting language that can be run


This article is from the "Tranquility Zhiyuan" blog, please be sure to keep this source http://irow10.blog.51cto.com/2425361/1789017

Zabbix simple use of custom keys

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.