Zabbix Customizing Auto-Discovery key! Low Level discovery

Source: Internet
Author: User

1 meaning and purpose, not discussed here, only discussion is the realization method

2 Learn the premise that you will write regular key! and understanding templates, item knowledge


System environment

Master side:

[Email protected] zabbix_agentd.conf.d]# ifconfig eth0| Sed-n ' S#.*inet addr:\ (. *\) B.*#\1#GP ' 192.168.100.10
Client side [[email protected] zabbix]# ifconfig eth0| Sed-n ' S#.*inet addr:\ (. *\) B.*#\1#GP ' 192.168.100.13


Two blocks, Zabbix-server web interface creation, and agent-side script implementation

[Email protected] ~]# grep-i "Include"/etc/zabbix/zabbix_agentd.conf | Egrep-v "^#|^$" Include=/etc/zabbix/zabbix_agentd.conf.d/[[email protected] ~]# CAT/ETC/ZABBIX/ZABBIX_AGENTD.CONF.D /web_site_discovery.conf #web Sitec codeuserparameter = web.site.discovery, Python/etc/zabbix/scripts/web_site_code_ Status.pyuserparameter = Test.test, sh/etc/zabbix/scripts/test.shuserparameter= web.site.code[*], sh/etc/zabbix/ scripts/check_web_code.sh $1[[email protected] ~]#


The first step, on the agent to see how to write automatic discovery of the Key,web.site.discovery script

[Email protected] ~]# cat/etc/zabbix/scripts/web_site_code_status.py#!/usr/bin/env Python#encoding=utf8import Osimport Jsonr = file ('/etc/zabbix/scripts/web.txt ') devices = []for f in R.readlines (): Devices.append ({"{#SITENAME}": F.strip ()}) print json.dumps ({' Data ': devices}, Sort_keys=true, indent=4)
[Email protected] ~]# Cat/etc/zabbix/scripts/web.txt www.baidu.comwww.sina.com.cnwww.pingan.com.cnwww.weibo.com

The return value of the key of the low level discovery in Zabbix is a JSON format. And the format must be as follows k/v

[[email protected] ~]# python /etc/zabbix/scripts/web_site_code_status.py{      "Data": [        {              "{#SITENAME}":  "www.baidu.com"          },         {              "{#SITENAME}":  "www.sina.com.cn"          },         {              "{#SITENAME}":  "www.pingan.com.cn"          },         {              "{#SITENAME}":  "www.weibo.com"          }   &nbSP;]} [[email protected] ~]#



Verify that using the Zabbix-get test on Master is valid for this key

[[email protected] zabbix_agentd.conf.d]# /usr/local/zabbix/bin/zabbix_get -s  192.168.100.13 -k web.site.discovery{     "Data": [         {             "{#SITENAME}" :  "Www.baidu.com"         },          {             "{#SITENAME}":   "www.sina.com.cn"         },          {             "{#SITENAME}":   "www.pingan.com.cn"         },          {             "{#SITENAME}" :  "Www.weibo.com"   &Nbsp;     }    ]} 


According to the above value, this key is already in effect!




Second, create an autodiscover on the master web-side interface (created on the template you need)


A.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/3F/wKioL1cXk9_BJNj2AABpgbAarUA790.png "title=" Zabbix _discovery_key.png "alt=" Wkiol1cxk9_bjnj2aabpgbaarua790.png "/>





B. Create an auto-discovery item (note to distinguish other normal item)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/42/wKiom1cXlHrjgpL-AABqVKJbces515.png "style=" float: none; "title=" Zabbi.png "alt=" Wkiom1cxlhrjgpl-aabqvkjbces515.png "/>



650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/42/wKiom1cXlHvw0FErAACMPMMuzAQ406.png "style=" float: none; "title=" Zabbix2.png "alt=" Wkiom1cxlhvw0feraacmpmmuzaq406.png "/>





Status of rendering:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/3F/wKioL1cXlhyhNJXIAABebkCfFxc352.png "title=" Za1.png "alt=" Wkiol1cxlhyhnjxiaabebkcffxc352.png "/>


The third step, the agent this host associated to this template (this you need to understand the operation)


This host will appear in the Itme


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/3F/wKioL1cXlaPBmLnGAABHWLxjyLY498.png "title=" Agent.png "alt=" Wkiol1cxlapbmlngaabhwlxjyly498.png "/>




This article is from the "Tridewah operation and maintenance work Road" blog, please be sure to keep this source http://cuidehua.blog.51cto.com/5449828/1766027

Zabbix Customizing Auto-Discovery key! Low Level discovery

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.