Zabbix Monitoring Nginx Status

Source: Internet
Author: User
Tags dashed line


Brief introduction:

How can I use Zabbix to monitor Nginx status?

1. Get Nginx State (HTTP Stub status)

Shell >/usr/local/nginx/sbin/nginx-vnginx version:nginx/1.8. 0  gcc4.4. 7 20120313 4.4. 7---prefix=/usr/local/nginx--with-http_stub_status_module--with-http_gzip_ Static_module

# # See if there is a status monitoring module at compile time, if there is no need to load separately

2, Configuration nginx.conf

Shell > vim/usr/local/nginx/conf/nginx.conf    ~/nginx_status {    stub_status on;    Access_log off;     127.0. 0.1 ;     121.142. 111.210 ;    Deny all;    }

# # Add the above configuration to the virtual host server {}, or you can define a separate virtual host for monitoring.
# # Deny all, deny access to this URL for all hosts except allow in the implementation process if you encounter 403, it is possible that you put your own test machine rejected!

3, Nginx Monitoring Item explanation

Shell > Curl http://127.0.0.1/nginx_status1server accepts handled requests 1 1 1  010

# # Active Connections: Number of active connections initiated on the backend
# # Server accepts handled Requests:nginx a total of 1 connections, successfully created 1 handshakes (no failures), processed 1 requests in total
# # Reading:nginx The number of Header messages read to the client
# # Writing:nginx The number of Header messages returned to the client
# # Waiting: When Keep-alive is turned on, this value equals active-(reading + writing), meaning that Nginx has finished processing and is waiting for the next request instruction to reside on the connection
# # In the case of high access efficiency, the request is processed quickly, the number of waiting is more normal. If the number of reading + writing is large, it indicates that the concurrent traffic is very high and is in process

4, write a script to get the above key value

Shell > Vim/script/nginx_status.SH#!/bin/Bash Case$1 inchActive) Curl-S http://127.0.0.1/nginx_status | awk '/active/{print $} ';;accepts) Curl-S http://127.0.0.1/nginx_status | awk ' nr==3 {print $} ';;handled) Curl-S http://127.0.0.1/nginx_status | awk ' nr==3 {print $} ';;requests) Curl-S http://127.0.0.1/nginx_status | awk ' nr==3 {print $} ';;reading) Curl-S http://127.0.0.1/nginx_status | awk '/reading/{print $} ';;writing) Curl-S http://127.0.0.1/nginx_status | awk '/writing/{print $4} ';;waiting) Curl-S http://127.0.0.1/nginx_status | awk '/waiting/{print $6} ';;*)Echo "Usage: $ {active | accepts | handled | requests | reading | writing | waiting}" ;;Esac

The # # script uses curl in conjunction with awk to get the value of key.
#-S silent mode, if the-s parameter is not added, the obtained result is incorrect.

chmod a+x/script/nginx_status. SH

5. Add a custom key configuration file

Shell > vim/usr/local/zabbix/etc/zabbix_agentd.conf.d/nginx_status.conf## Nginx_statususerparameter=nginx.active,/script/nginx_status.SHActiveuserparameter=nginx.accepts,/script/nginx_status.SHAcceptsuserparameter=nginx.handled,/script/nginx_status.SHHandleduserparameter=nginx.requests,/script/nginx_status.SHRequestsuserparameter=nginx.reading,/script/nginx_status.SHReadinguserparameter=nginx.writing,/script/nginx_status.SHWritinguserparameter=nginx.waiting,/script/nginx_status.SHWaiting

# # can also be added directly to the end of/usr/local/zabbix/etc/zabbix_agentd.conf

Shell > vim/usr/local/zabbix/etc/zabbix_agentd.confinclude=/usr/local/zabbix/etc/zabbix_ AGENTD.CONF.D/*Confunsafeuserparameters=1 # allow custom Key

# # Add the above configuration

5. Restart Zabbix_agentd

Shell > Service Zabbix_agentd Restart

Note that all of the above is on the monitored side

6, Zabbix service side test can get Key

123.57. 79.52 -k nginx.active1

# # can get the value to the key, indicating that there is no problem with the configuration
# # is monitored, remember to turn on port 10050

7, Zabbix monitoring Nginx status

# # Next is the Web interface, creating templates, adding monitoring items

> Create a template

# # Come along with me # # Create template, Templates, Configuration--

Template name:template App Nginx Service

Groups in Groups:templates

Update

> Create app Groupings

# # Now back to the template page, with me a starting point template App Nginx Service template behind applications-Create application

Name:nginx status

Update

> Creating a monitoring item

# # Now the location is the Applications page in the template App nginx Service templates, follow me and click on the Create item, following the Nginx status you just created

Name:nginx Active # # Monitoring Item Name

Type:zabbix Agent # # Monitor type, default passive mode

Key:nginx.active # # because it's a custom Key, write it yourself. If you use your own Key, click Select to choose it.

Type of Information:numeric (unsiqned) # # data is stored in the database after type conversion

Numeric (unsiqned): 64-bit unsigned integer
Numeric (float): floating-point type
Character: String type data, limited to 255B
LOG: Journal file, must use Key log[]
Text: literal, unlimited size

Data Type:decimal # # datatype is used to store numeric values obtained by Key in Items, stored in different tables such as history, HISTORY_STR, etc.

Boolean: Replace the original value with 0 when the data is stored or the 1,true store as 1, false to store as 0, all values are case-sensitive (any non-0 is TRUE, 0 is False)
Octal: Numeric format for octal numbers
Decimal: Numeric format for decimal numbers
Hexadecimal: Numeric format for hexadecimal numbers

# # Zabbix Automatic format conversion of data types

Units: Empty # # unit symbol, Zabbix automatically processes the received data and converts the data into a format that needs to be displayed

Use custom multiplier: Do not tick # # if turned on, the received data will be multiplied by integers or floating-point numbers. This option is used for unit conversions, KB, MBps for B, BPS, etc.

Update interval (in sec): 30 # # time interval How long is the data collected through Items, in seconds

Flexible intervals: # # is used to set different time periods to collect data at different intervals, if set, then this time period at this interval, the rest by the above parameter interval

New flexible interval interval (in sec): Period 1-7,00:00-24:00 Add: # # Add a new time period here

History storage period (in days): 90 # # Historical Data retention time

Trend storage period (in days): 365 # # Trend Data Retention time

Store Value:as is # # type when data is stored

As is: no pretreatment

Delta (speed per second): Shows the rate per second value (e.g. network card traffic)

Delta: Shows the difference between this value and the last value

Show Value:as is # # no preprocessing (data display type, Value mapping: Map the received value to a state without changing the original value, only changing the display result, such as mapping 1 to Nginx service states)

New application: Leave empty # # Create a new app grouping

Applications:nginx Status # # Select an existing app group

Populates host Inventory Field:none # # Assign this Item to an asset management group

Description: Leave blank # # description information for Item

Enabled: Tick # # to open this Item

Add

# # define Active Separately | Accepts | Handled | Requests | Reading | Writing | Waiting can

8. Apply the template to the host

> If you don't have a host, follow me. Create host, hosts, Configuration--

Host name:123.121.211.52 # # is monitored by the IP (here to write the value of Hostname in the monitored end zabbix_agentd.conf file)

Visible Name:shuma_1 # # defines an alias (the name to display)

Groups in Groups:shuma # # Select to join a host group

New group: Empty # # Customize a host group

Agent interfaces: # # Interface Protocol

IP address:123.121.211.52 # # IP on the monitored side

DNS Name: Empty # # Monitor the names that the host can resolve

Connect To:ip # # Choose what way

port:10050 # # is monitored to open this port

Description: Empty # # Description of the host

Monitored by Proxy:no Proxy # # do not use proxies

Enabled: Check # # to enable monitoring (monitored is available on behalf of the host, has been monitored; not monitored on behalf of the host is not available, not monitored)

Add # # On behalf of the host is added to complete (here is not the point, together with the template link) Select the current page Templates

> Now the location is in the Templates tab of the host page, follow me dot Select

After selecting the template App Nginx Service in the new page and returning to it, click Add to link the template successfully.

ADD # # Last time, you can.

9, look at the fruits of labor

> Follow me for a little bit. Configuration--Hosts

# # You will see the host just added, it has a applications, 7 items, see the link template, the status is enabled.

> Follow me, monitoring. Latest data

Hosts:select the host you just created, note: It's in a group, click Filter

# # Now, do you see 7 of the monitoring items and get the data yo

10. Add a Graph to the host

> Follow me. After you click on the Configuration--and hosts, you can create a chart by clicking on the Graphs behind the host you just created.

# # I've changed my mind, just go to the template to create better, so that you do not have to create for each host

> Follow me for a little bit. After Templates, click Create Graph, Graphs, behind the template you just created

Name:nginx Status # # chart name

width:900 # # Width

height:200 # # Height

Graph Type:normal # # chart type

Normal: Regular chart, values are represented by lines

Stacked: Stack diagram

Pie: Pie chart

Exploded: Decomposition pie chart

Show legend: Tick # # Show Chart description

Show working time: Tick # # not "working hours" in gray, not for pie charts and exploded pie charts.

Show triggers: Tick # # Trigger threshold will be displayed in red line, cannot be used for pie chart and exploded pie chart, only partial trigger function support, such as Min, Max

Percentile line (left): Do not tick the Y-axis to show percentages, only for regular charts

Percentile line: Do not tick # # the right Y-axis is used to display percentages only for regular charts

Y axix min value:calculated # # automatically calculates the Y-axis minimum value

Y axis Max value:calculated # # automatically calculates the y-axis maximum value

Items # # Click Add to include the previous 7 items in a single diagram

Name:item the name of the display data

Function: Which data is displayed when an Item has more than one value (all, min only, avg average only, Max Max value only)

Draw Style:line # # applies only to regular charts, applies to stacked fill areas

Line: Draw lines

Filled region: Painting filled area

Bold line: Draw thick lines

Dot: Draw Dots

Dashed line: Draw dashed lines

Y Axis side:left # # Y-Axis left-hand component

Colour: The color represented by each element

ADD # # Completed Graph creation, if in the host, can be viewed through the second tab Preview

11. View Graph

# # Because the template has been referenced before, the Graph is now automatically available in the host

> Follow me, monitoring. Graphs

Zabbix Monitoring Nginx Status

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.