Nginx生命活动监控

阅读:352 2019-03-19 15:01:19 来源:新网

nginx提供实时生命监控界面显示你的服务器设施的关键负载和性能指标。这些指标可以只在仪表盘或作为restfuljson界面代表和第三方监控工具连接。

指标包括来自http和tcpupstream服务器的数据和其它数据,包括:

nginx版本、uptime和标识符信息

总连接数和请求数

每个status_zone请求和响应计数

upstream服务器组中的每个服务器的请求和响应计数,加健康检查和uptime统计

每台服务器的统计,包括它的当前状态和总值(总失败数,等)

每个命名的缓存区域仪表盘

首先,你需要在nginx配置中启用收集统计。然后你能配置服务器区域、健康检查、缓存和其它出现在统计中的数据。

为了启用仪表盘和json界面,打开nginx配置文件并执行以下步骤:

在http上下文中,指定server块负责收集统计:

http{

server{

}

}

http{

server{

listen192.168.1.23:8080;

...

}

}

http{

server{

listen192.168.1.23:8080;

...

location/status{

status;

...

}

}

}

http{

server{

listen192.168.1.23:8080;

root/usr/share/nginx/html;

location/status{

status;

...

}

location=/status.html{

}

}

}

http{

server{

listen192.168.1.23:8080;

root/usr/share/nginx/html;

location/status{

status;

allow192.168.1.0/32;

denyall;

}

location=/status.html{

}

}

}

你能收集几乎所有的nginx统计数据,包括分开虚拟主机、upstream服务器组、缓存区域。在这种情况下,你需要执行一些额外的安装步骤。例如,收集虚拟主机和upstream组的统计信息需要共享内存区域存储配置和运行时状态信息:

为了使http和tcp服务器显示统计,指定status_zone指令。相同的区域名可以指定在多个server块中,因此这些主机的统计聚合在仪表盘中:

server{

...

status_zonestatus_page;

location/{

proxy_passhttp://backend;

}

}

upstreambackend{

zonebackend64k;

serverbackend1.example.com;

serverbackend2.example.com;

}

server{

...

status_zonestatus_page;

location/{

proxy_passhttp://backend;

health_check;

}

}

http{

...

proxy_cache_path/data/nginx/cachekeys_zone=one:10m;

}

server{

...

location/upstream_conf{

upstream_conf;

allow92.168.1.0/32;

denyall;

}

}

测试配置并重新加载nginx

sudonginx-t&&sudonginx-sreload

上一篇: Nginx反向代理
相关文章
{{ v.title }}
{{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
你可能感兴趣
推荐阅读 更多>
推荐商标

{{ v.name }}

{{ v.cls }}类

立即购买 联系客服