Zabbix Monitoring Nginx_status Optimized Edition

Source: Internet
Author: User

Set Nginx Status page, if not, you may need to compile the installation, use Nginx-v to view the compilation parameters

server {
Listen 81;
server_name localhost;
Location/nginx_status
{
Stub_status on;
Access_log off;
}
Location/php-fpm_status
{
#fastcgi_pass 127.0.0.1:9000;
Fastcgi_pass Unix:/dev/shm/php-cgi.sock;
Fastcgi_param script_filename $fastcgi _script_name;
Include Fastcgi_params;
}
}
Nginx Script:

#!/bin/bash

# -------------------------------------------------------------------------------
# Notice
# Apply Zabbix version 2.4.x to 3.0.3
# Nginx Need to open Nginx status modules
#################################################################################
Port= "81"
clu= "/usr/bin/curl http://127.0.0.1: $PORT/nginx_status"
#FILE =/tmp/nginx_status.txt
if [[$# = 1]]; Then
Case is in
#当前处于打开状态的连接数
Active)
output= ' $CLU 2>/dev/null |awk '/active/{print $} ' 2>/dev/null
Echo $output
;;
#共处理的链接, already accepted links
Server
output= ' $CLU 2>/dev/null |awk ' nr==3{print $} ' 2>/dev/null
Echo $output
;;
#成功创建握手, links that have been processed
Accepts)
output= ' $CLU 2>/dev/null |awk ' nr==3{print $} ' 2>/dev/null
Echo $output
;;
#已经处理的链接, a total of requests for processing
Handled
output= ' $CLU 2>/dev/null |awk ' nr==3{print $} ' 2>/dev/null
Echo $output
;;
#读取客户端的连接数, the number of connections that are in the receiving request state
Reading
output= ' $CLU 2>/dev/null |awk ' nr==4{print $} ' 2>/dev/null
Echo $output
;;
#相应数据到客户端的数量, the number of connections in the process of processing a request or sending a response that the request has accepted to complete
Writing)
output= ' $CLU 2>/dev/null |awk ' nr==4{print $} ' 2>/dev/null
Echo $output
;;
#开启keep-alive, this value is equal to active-(reading+writing), meaning that Nginx has finished processing the resident link waiting for the next request instruction
#保持链接模式, and the number of active connections
Waiting)
output= ' $CLU 2>/dev/null |awk ' nr==4{print $} ' 2>/dev/null
Echo $output
;;
*)
echo "Usage:$0{active|server|accepts|handled|reading| Writing| Waiting} "
;;
Esac
Fi

#nginx

Userparameter=nginx.status[*],/usr/local/zabbix/scripts/nginx_status.sh $ $

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.