Zabbix Monitor the status of the website URL Discovery Real-time monitoring

Source: Internet
Author: User

Today we are going to talk about the low level discovery this feature, why should we use Loe level discovery this function?

Many times, when using Zabbix to monitor things, you need to add something like Itens, which has some common features,

If you say that certain parameters are variables, and the other settings are the same, for example: A program has multiple ports, requires multi-port monitoring and configuration of itmes, as well as disk partitioning, Nic name, etc.

Are uncertain, if we configure fixed items, there will be problems that cannot be generalized, so we need to look at the low-level discovery feature

The key return value of low level discovery is a JSON format (if it is custom, you can verify that the value obtained by the Web site is the correct number of JSON formats)

#自动发现特定的变量名称

#添加对变量的Itmes

Let's take a real-world case:

Business requirements:

Now the business with a look at the URL needs to monitor, form such as: http:www.xxx.com, request the URL status is not 200 alarm issued

Requirements Analysis:

URLs that have been looked at, and URLs change frequently, need to add URLs to complete monitoring

Solution: As mentioned above, URLs change frequently, but other states do not change, this is enough to be able to use the Zabbix low level discovery function to achieve this demand

Ideas:

1) Since there are a lot of URLs that need to be monitored, we can write the URL domain address into a configuration file to facilitate subsequent call monitoring

2) Zabbix There are no templates and monitoring items to monitor URLs, so you can only customize and write an Autodiscover script, which is in JSON format: A status code used primarily to invoke URLs and get URLs

3) test whether the key value (URL status code) is correctly obtained by zabbix_get on the server side

4) Add the discovery of the Web page, create monitoring templates, monitor items, trigger types and graphs, and monitor status codes and make corresponding alarms in real time.

"Zabbix-agent configuration File"

# grep-ve "(#|^$)"/usr/local/zabbix/etc/zabbix_agentd.conf

Logfile=/tmp/zabbix_agentd.log
Enableremotecommands=0 #启用远程命令
server=192.168.37.129
Startagents=8
serveractive=192.168.37.129
hostname=192.168.37.130
Timeout=8 #超时时间改为8即可 If the server-side Zabbix_get tests the prompt time-out when the key value is obtained, modify adjustments can be made
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/web_site_discovery.conf #子配置文件, there is also a way to directly in the agent.conf configuration file " Userparameter= "write the corresponding key value
Unsafeuserparameters=1

"Custom Low Level Discovery Auto Discovery Script"

Mkdir-p/usr/local/zabbix/etc/scripts/

vim/usr/local/zabbix/etc/scripts/Web.txt #网站URL存放文件, write the domain name of the monitor we need into the custom configuration file

http: // www.hexun.comhttp://www.baidu.comhttp://www.weibo.com

Vim/usr/local/zabbix/etc/scripts/web_site_code_status

#!/bin/bash
#Monitoring website domain name URL change script
#mail: [email protected]
#QQ : 1261813048
#/usr/bin/curl-o/dev/null-s-W%{http_code} http://$1/
Web_site_discovery () {
Web_SITE= ($ (cat /usr/local/zabbix/etc/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
/usr/bin/curl-i-M 10-o/dev/null-s-w%{http_code} "\ n" 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

# chmod 755/usr/local/zabbix/etc/scripts/web_site_code_status #脚本权限给予755

"Custom Key value Profile"

# vim/usr/local/zabbix/etc/zabbix_agentd.conf.d/web_site_discovery.conf #子配置文件, referenced in the Include in agent.conf configuration file

Userparameter=web.site.discovery,/usr/local/zabbix/etc/scripts/web_site_code_status Web_site_discovery
Userparameter=web.site.code[*],/usr/local/zabbix/etc/scripts/web_site_code_status Web_site_code $

Test:

On the server side • Can the test agent-side custom key value be obtained? Ok~ from See, can get to URL domain status code

"Web page Add low level Discory"

1) Creating a custom template

Configuration-----Templates (template)----Create Templates (Creating a template)

Create an Autodiscover rule

Create an app Set

"Create a monitoring item prototype based on the Autodiscover rule base"

Ps: The key value here must correspond with it

Create trigger types, set multi-gradient alarm detection,

Set different periodic alarms. 3,10,15 min Three different fault levels

"Create Image Prototypes"

So far, the entire template has been built to completion ~ as shown in

We will link this template to a host on the agent side, waiting for about 30s time, we will find that there is already a three of the added site graphics,

Zabbix Monitor the status of the website URL Discovery Real-time 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.