The LLD function of Zabbix--low-level discovery

Source: Internet
Author: User

Feeling this theme is and a theme is a series, and more basic.

Ready to delve into ...

Related Documentation Preparation:

Https://www.zabbix.com/documentation/2.0/manual/discovery/low_level_discovery

http://itnihao.blog.51cto.com/1741976/1129725

Low-level discovery provides a-automatically create items, triggers, and graphs for different entities on a compute R. For instance, Zabbix can automatically start monitoring file systems or network interfaces on your machine, without the Need to create items for each file system or network interface manually. Additionally it is possible to configure Zabbix-remove unneeded entities automatically based on actual results of Perio Dically performed discovery.

In Zabbix 2.0, three types of item discovery is supported out of the box:

    • Discovery of file systems;
    • Discovery of the network interfaces;
    • Discovery of SNMP OIDs.

A user can define their own types of discovery, provided they follow a particular JSON protocol.

The general architecture of the discovery process is as follows.

First, a user creates a discovery rule in "Configuration" → "Templates" → "Discovery" column. A Discovery rule consists of (1) an item that discovers the necessary entities (for instance, file systems or network inte Rfaces) and (2) prototypes of items, triggers, and graphs that should being created based on the value of this item.

An item that discovers the necessary entities are like a regular item seen elsewhere:the server asks a Zabbix agent (or WH Atever the type of the item is set to) for a value of this item, the agent responds with a textual value. The difference is, the value the agent responds with should contain a list of discovered entities in a specific JSON f Ormat. While the details of this format was only important for implementers of custom discovery checks, it was necessary to know T Hat The returned value contains a list of macro→value pairs. For instance, item "Net.if.discovery" might return of pairs: "{#IFNAME}" → "lo" and "{#IFNAME}" → "eth0".

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Demand:

There are a lot of URLs that need to be monitored, in the form of http://itnihao.blog.51cto.com, which requires a URL state of 200.

Detailed Requirements Analysis:

A lot of URLs, and often change the URL, now monitoring with Zabbix, if manually add a template, will cause a lot of duplication of work, resulting in a waste of human and financial resources, resulting in a waste of rest time, not to lose, if the use of script +mail, can not be graphically rendered

Solution:

Zabbix has a discovery feature that makes it easy to solve this problem with this feature

Zabbix Client Configuration

    1. ######## #cat/etc/zabbix/zabbix_agentd.conf|grep-v "^#" |grep-v "^$" ##########

    2. # #此处省略N多信息,

    3. Include=/etc/zabbix/zabbix_agentd.conf.d/#配置文件路径

    4. unsafeuserparameters=1 #自定义key

  1. ########## #自动发现脚本编写

  2. ####################### #cat/etc/zabbix/scripts/web_site_code_status##############

  3. #!/bin/bash

  4. # function:monitor TCP Connect status from Zabbix

  5. # LICENSE:GPL

  6. # Mail:[email Protected]

  7. # version:1.0 date:2012-12-09

  8. SOURCE/ETC/BASHRC >/dev/null 2>&1

  9. Source/etc/profile >/dev/null 2>&1

  10. #/usr/bin/curl-o/dev/null-s-W%{http_code} http://$1/

  11. Web_site_discovery () {

  12. Web_site= ($ (Cat web1.txt|grep-v "^#"))

  13. printf ' {\ n '

  14. printf ' \ t ' data: [\ n '

  15. For ((i=0;i<${#WEB_SITE [@]};++i)]

  16. {

  17. Num=$ (Echo $ ((${#WEB_SITE [@]}-1))

  18. If ["$i"! = ${num}];

  19. Then

  20. printf "\t\t{\ n"

  21. printf "\t\t\t\" {#SITENAME}\ ": \" ${web_site[$i]}\ "},\n"

  22. Else

  23. printf "\t\t{\ n"

  24. printf "\t\t\t\" {#SITENAME}\ ": \" ${web_site[$num]}\ "}]}\n"

  25. Fi

  26. }

  27. }

  28. Web_site_code () {

  29. /usr/bin/curl-o/dev/null-s-W%{http_code} http://$1

  30. }

  31. Case "$" in

  32. Web_site_discovery)

  33. Web_site_discovery

  34. ;;

  35. Web_site_code)

  36. Web_site_code

  37. ;;

  38. *)

  39. echo "usage:$0 {Web_site_discovery|web_site_code [URL]}"

  40. ;;

  41. Esac

Client configuration file

    1. ######## #cat/etc/zabbix/zabbix_agentd.conf.d/web_site_discovery.conf ###########

    2. userparameter=web.site.discovery,/etc/zabbix/scripts/web_site_code_status web_site_discovery

    3. userparameter=web.site.code[*],/etc/zabbix/scripts/web_site_code_status Web_site_code $

Domain names are as follows

    1. ######### cat/etc/zabbix/scripts/web.txt###########

    2. Www.qq.com

    3. Www.baidu.com

    4. www.sina.com.cn

Test:

    1. Zabbix_get-s 127.0.0.1-k Web.site.discovery

    1. Zabbix_get-s 127.0.0.1-k web.site.code[www.qq.com]

This returns a status of 200

At this point, the script, client configuration file OK

Next is the addition of the Web

Alarm level setting: 3 Alarm Levels

Using the above method, even if it is 1000 URL monitoring, it is a minute thing

Summary: 工欲善其事, its prerequisite

Reference Document: Https://www.zabbix.com/documentation/2.0/manual/discovery/low_level_discovery

In addition, you can refer to the document I wrote: http://code.google.com/p/auto-task-pe/downloads/list Zabbix automatic discovery Monitoring HTTP port. pdf If you have a problem, read these 2 documents carefully. Additional template files are attached.

Welcome to the Exchange.

http://my.itwnik.com/2013/03/zabbix-low-level-discovery-rule-script-for-md-devices/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Apply a:

Zabbix implements the monitoring of the web in two ways, one is the self-brought web scenarios, the basic ability to achieve most of the web monitoring needs, but the convenience is much less convenient, the other is the use of script +lld, can implement any machine

All the URL monitoring on the device, we just need to manually add the URL to be monitored, plus the functionality of the Zabbix template, it can be easily applied to the required monitoring server.

First to sense the line Itnihao children's shoes provided this way, the blog address is http://itnihao.blog.51cto.com/1741976/1129725

1.zabbix Client Configuration

Vim/etc/zabbix/zabbix_agent.conf

Include=/etc/zabbix/zabbix_agentd.conf

Unsafeuserparameters=1

Allow users to pass with custom parameters

2. Scripts and Parameters

[Email protected] zabbix]# tree
.
├──monitor_scripts
│├──discovertcpport.sh
│├──web_site_code_status.sh
│└──web.txt
├──zabbix_agentd.conf
└──zabbix_agentd.d
├──userparameter_mysql.conf
└──web_site_discovery.conf

(1) Zabbix transfer parameters and configuration files

[email protected] zabbix]# cat zabbix_agentd.d/web_site_discovery.conf
Userparameter=web.site.discovery,/etc/zabbix/monitor_scripts/web_site_code_status.sh Web_site_discovery
Userparameter=web.site.code[*],/etc/zabbix/monitor_scripts/web_site_code_status.sh Web_site_code $

(2) Zabbix automatic monitoring script

[email protected] zabbix]# cat monitor_scripts/web_site_code_status.sh
#!/bin/bash
#function: Monitor Web site code status from Zabbix
Web_site_discovery () {
Web_site= ($ (cat/etc/zabbix/monitor_scripts/web.txt |grep-v "^#"))
printf ' {\ n '
printf ' \ t ' data: [\ n '
For ((i=0;i<${#WEB_SITE [@]};i++))
{
Num=$ (Echo $ ((${#WEB_SITE [@]}-1))
If ["$i"! = ${num}];then
printf "\t\t{\ n"
printf "\t\t\t\" {#SITENAME}\ ": \" ${web_site[$i]}\ "},\n"
Else
printf "\t\t{\ n"
printf "\t\t\t\" {#SITENAME}\ ": \" ${web_site[$num]}\ "}]}\n"
Fi
}
}
Web_site_code () {
/usr/bin/curl-o/dev/null-s-W%{http_code} http://$1
}
Case "$" in
Web_site_discovery)
Web_site_discovery
;;
Web_site_code)
Web_site_code
;;
*)
echo "usage:$0 {Web_site_discovery|web_site_code[url]}"
;;
Esac

(3) URLs that need to be monitored in WEB.TXT

[email protected] zabbix]# cat Monitor_scripts/web.txt
S1.xd.com/default.aspx
S2.xd.com/default.aspx

3. Monitoring test on Zabbix server

[Email protected] yum.repos.d]#/usr/bin/zabbix_get-s 192.168.1.211-p 10050-k web.site.code[s1.xd.com/default.aspx]
200

[Email protected] yum.repos.d]#/usr/bin/zabbix_get-s 192.168.1.211-p 10050-k web.site.discovery
{
"Data": [
{
"{#SITENAME}": "S1.xd.com/default.aspx"},
{
' {#SITENAME} ': ' S2.xd.com/default.aspx '}]}

Test success

4. Let's configure the next discovery template, and then apply it directly to the server.

(1) Create a template and apply it to a server that needs to be monitored

(2) Create a new app in the application of the new template Web monitor template

(3) Create a new rule in discovery rules in the new Template Web monitor template

(4) Create the item porototyoed in the new web.site.discovery

(5) Create the trigger Porotypes in the new Web.site.discovery, which is set to alarm when the status code is greater than 399.

OK, after the configuration, our web URL monitoring is complete.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The LLD function of Zabbix--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.