Myluzh Blog

Zabbix通过"Nginx by Zabbix agent"模板,监控Nginx状态

发布时间: 2023-12-18 文章作者: myluzh 分类名称: Zabbix 朗读文章


0x01 Zabbix启用模板
1、Zabbix面板->“配置”->“主机”->"创建/编辑主机"->添加模板 “Nginx by Zabbix agent”
2、并且修改主机宏
描述
{$NGINX.PROCESS_NAME}
nginx

{$NGINX.STUB_STATUS.HOST}
127.0.0.1

{$NGINX.STUB_STATUS.PATH}
basic_status

{$NGINX.STUB_STATUS.PORT} 80

关于“Nginx by Zabbix agent”模板参数详细链接:https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/nginx_agent

0x02 Nginx主机配置
1、测试nginx模块“ http_stub_status_module可用性
root@nginx:/etc/nginx/conf.d# nginx -V 2>&1 | grep -o with-http_stub_status_module
with-http_stub_status_module
2、nginx配置文件
root@nginx:/etc/nginx/conf.d# cat status.conf 

server {
    listen 80;
    server_name 127.0.0.1;

    location /basic_status {
        stub_status on;
        #access_log off;
    }
}
3、测试
# curl测试下
root@nginx:/etc/nginx/conf.d# curl http://127.0.0.1:80/basic_status
Active connections: 1 
server accepts handled requests
 278459659 278458481 279256404 
Reading: 0 Writing: 1 Waiting: 0 
# 或者看下nginx的access日志
root@nginx:~# tail -f -n 2000 /var/log/nginx/access.log | grep basic_status
127.0.0.1 - - [18/Dec/2023:14:03:12 +0800] "GET /basic_status HTTP/1.1" 200 121 "-" "Zabbix 6.2.9" 

标签: zabbix nginx nginx_agent

发表评论