Zabbix Web Monitoring

Source: Internet
Author: User
Tags http authentication response code ssl certificate

Web monitoring (monitoring) is a business monitoring that monitors the multifaceted availability of web sites and monitors the download speed, return codes, and response times of web sites. Zabbix is able to detect pre-defined strings contained in HTML, as well as simulate the action of a login site and mouse, and compare specific results, such as specific strings, return codes, and so on, to determine the usability of the site service. The Zabbix supports HTTP and HTTPS protocols, and the cookie is saved when each step of the simulated access is completed.

When you set up Web monitoring in Zabbix, you need to define a Web scenarios (scene), a webscenarios consisting of multiple HTTP requests (steps) that are executed in a predefined order. As with the definition of monitoring items, web scenarios can also be defined at the host or template level.

1. Web Monitoring items

There are two main types of Web monitoring items: Scenario items and Scenario step items. These monitoring items have a default history of 30 days and a trend save time of 90 days.

1.1 Scenario Items

When Web scenario is created, Zabbix automatically adds the following monitoring items and connects them to the selected app.

※download speed for scenario<scenario>: This monitoring item collects the average download rate data for the entire scenario, in units of bytes per second. The key for the monitoring entry is: web.test.in[scenario,,bps], and the type is: Numeric (float).

※failed step of Scenario<scenario>: This monitoring item will show the number of failed step in the entire scenario, if all step executes successfully returns 0. The key of the monitoring item is: Web.test.fail[scenario], and the type is: Numeric (unsigned).

※last error message of SCENARIO<SCENARIO>: The monitoring item returns the last error message text for scenario, and a new value is saved if there is a failed step in scenario. If all of the step is executed successfully, no new values are saved. The key of the monitoring item is: Web.test.error[scenario], the type is: Character.

Scenario items can also be used to create triggers and define notification conditions.

For example:

※ When creating a Web scenariofailed trigger, the trigger expression can be defined as: {host:web.test.fail[scenario].last ()}<>0

※ When creating a Web scenariofailed trigger, use the description of the problem in the trigger name. The trigger name can be defined as:

Web Scenario "Scenario" failed: {ITEM. VALUE}

Trigger expressions can be defined as:

{Host:web.test.error[scenario].strlen ()}>0 and{host:web.test.fail[scenario].min ()}>0

※ When creating a trigger for WebApplication is slow, the trigger expression can be defined as:

{host:web.test.in[scenario,,bps].last ()}<10000

In the real world, replace the scenario with the actual name of the scene you defined.

1.2 Scenario Step Items

After each step is created in scenario, Zabbix automatically adds the following monitoring items and connects them to the selected app.

※download speed for step<step> of scenario <scenario>: This monitoring item collects step-related average download rate data in Bytesper second. The key for the monitoring entry is: web.test.in[scenario,step,bps], and the type is: Numeric (float).

※response time for step<step> of scenario <scenario>: The monitoring item collects the data for step-related response times in seconds. The response time is timed from the request until all the information has been transferred. The key for the monitoring entry is: WEB.TEST.TIME[SCENARIO,STEP,RESP], and the type is: Numeric (float).

※response code for Step <step>of scenario <SCENARIO>: The monitoring item shows that the step return codes, such as 50x, 40x, etc. should be monitored in the real world. The key of the monitoring item is: Web.test.rspcode[scenario,step], and the type is: Numeric (unsigned).

You can also use these scenario step item when creating triggers. For example, when you create a trigger that Zabbixgui the login is too slow, the trigger expression can be defined as:

{Zabbix:web.test.time[zabbix gui,login,resp].last ()}>3

2. Using variables

When configuring Web monitoring, you can use variables (variable) at either the scenario or step level, which is actually a user-defined macro variable. Variables defined at the scenario level can be referenced in steps, such as URLs, post variables, and so on. Macro variables defined at the step level can be used in Get or post functions, and variables defined at the step level can override variables in the scenario level or variables defined in the previous step.

The format of the variable definition is:

{macro1}=value1

{macro2}=value2

{Macro3}=regex:<regular expression>.

For example {username}=alexei,{password}=kj3h5kj34bd,{sid}=regex:name= "Sid" Value= "([0-9a-z]{16})" and so on. If you start with a regex, it is followed by a regular expression that searches the Web page and, if found, saves the matching value to the variable. When you apply macros in step, such as {username}, {password}, {HostID}, and so on, Zabbix is automatically replaced with the actual value.

When you configure variables, you can also use HOST.* macro variables and user-defined macro variables. It is important to note that variables cannot be URL-encoded.

3. Configure Web Monitoring

In the Configure –> Host/Templates page, click the Web link in the host or template where you want to create Web monitoring, click the Create Web Scene button in the top right corner of the Web monitoring page to go to the Web Monitoring configuration page

The meanings of each configuration parameter in the Scene tab are as follows:

Name: Unique scene name

App set: Select a monitoring item group for a scene attribution

New app set: Enter the name of a new monitoring item group for a scene attribution

Data Update interval: time interval for execution

Number of attempts: the number of times the web scene step attempt was performed. Sometimes you can repeat the steps several times because of network problems (timeouts, lost connections, and so on) that affect every step in the scene. You can specify up to 10 times, with a default value of 1. It is important to note that Zabbix does not repeat steps because of an error response code or a required string mismatch

Client: Select a browser client that is useful when a Web site returns different content for different browsers. User-defined macro variables can also be used here

HTTP proxy: Specifies an HTTP proxy. The format used is: http://[username[:p assword]@]proxy.mycompany.com[:p ORT], port 1080 is used by default. If you specify proxy environment variables such as Http_proxy, Https_proxy, you will overwrite the environment variables associated with the proxy. It is important to note that the HTTP proxy only supports simple authentication. User-defined macro variables can also be used here

Variables: List of variables at the scene level

Header: The HTTP header will be sent when the request is executed. Headers is listed using the syntax of the HTTP protocol, which sets the Curl option Curlopt_httpheader. For example: Accept-charset:utf-8,accept-language:en-us,content-type:application/xml; Charset=utf-8. Here you can use host.* and user-defined macro variables

Enabled: Tick this to enable the web scene

The Step label Configuration page looks like this, and the parameters in the Step Configuration page have the following meanings

Name: The unique step name

URL: A URL that needs to be monitored to support HTTP or HTTPS protocols. The get parameter can be written directly in the URL, or you can use a macro variable that cannot exceed 2048 characters in length

Post:http the post variable in the request. For example Id=2345&userid={user}, if {user} is a macro variable defined in Web scenario, the corresponding value is automatically replaced when step executes. This variable is sent as-is without URL encoding

Variables: Variable list at step level

Header (Headers): HTTP Headers will be sent when the request is executed. Headers is listed using the syntax of the HTTP protocol. The headers defined at the step level overrides the headers at the scenario level. Here you can use host.* and user-defined macro variables. This sets the Curl option Curlopt_httpheader

Follow jump: Tick this to allow HTTP redirects (redirect). This sets the Curl option Curlopt_followlocation

Get header information only: tick this to receive HTTP response headers only. This sets the Curl option Curlopt_nobody

Timeout: Zabbix will no longer process URLs after setting the number of seconds. In fact, this parameter defines the maximum connection time and the maximum time to complete the HTTP request. Therefore, Zabbix does not exceed twice times the setup time in the steps to process the URL.

Required String: The required regular expression. Step execution fails unless the content in the received HTML matches the regular expression. If the field is empty, no detection is performed. It is important to note that you cannot reference a regular expression created in the Zabbix front-end page. Macro variables can also be used here

Required status code: Set the desired HTTP status code list, for example 200,201,202-229. If the status code collected by Zabbix is not in this list, then the step execution fails. If the field is empty, no detection is performed. Macro variables can also be used here

Configure the first step:

Configure a second step:

The Authentication label configuration page is as follows, and the parameters in the authentication label configuration page are as follows:

HTTP Authentication: Authentication option. Including:

None: No authentication is used.

Base: Use Basic authentication.

NTLM: NTLM (Windows NT LAN Manager) authentication is used.

When you select the underlying or NTLM page, an input field for the user name and password appears, and you can use the macro variable in the user name and password fields

SSL Authentication peer: Tick this to verify the SSL certificate for the Web server. The server certificate is automatically obtained from the storage location of the system ca. You can use the Zabbixserver or proxy server configuration file to set parameters Sslcalocation Save the certificate. This sets the Curl option Curlopt_ssl_verifypeer.

SSL Authentication Host: Tick this to verify that the Web server certificate matches the common name field or the Subject Alternate name field. This sets the Curl option Curlopt_ssl_verifyhost.

SSL certificate file: The name of the SSL certificate file used for client authentication. The certificate file must be in PEM1 format. If the certificate file also contains the private key, leave the SSL key file field blank. If the key is encrypted, specify the password in the SSL Key password field. You set the parameter Sslcalocation in Zabbixserver or proxy server's configuration file to save the certificate file. Here you can use host.* and user-defined macro variables. This sets the Curl option Curlopt_sslcert.

SSL secret key file: The name of the SSL private key file used for client authentication. The private key file must be in PEM1 format. Sslcalocation Save the certificate file by setting the parameters in the Zabbix server or proxy server configuration file. Here you can use host.* and user-defined macro variables. This sets the Curl option Curlopt_sslkey.

SSL secret key password: SSL private key file password. A user-defined macro variable can be used here. This sets the Curl option CURLOPT_KEYPASSWD.

Here's an example of choosing authentication without

When all the steps have been added, click the Add button to save all the configurations. Then go to the monitoring –> the latest data page to browse items in the data and graphics

Part of the content reference source: https://www.ixdba.net/archives/2018/04/1138.htm

Zabbix Web 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.