1、在被监控主机安装部署Nginx服务,并开启状态监控模块
- 源码包
$ yum -y install gcc pcre-devel zlib-devel
$ wget http://nginx.org/download/nginx-1.22.1.tar.gz
$ tar -xf nginx-1.22.1.tar.gz
$ cd nginx-1.22.1/
$ ./configure --prefix=/usr/local/nginx --with-http_stub_status_module && make && make install
#完成Nginx的安装及统计模块的安装
$ vim /usr/local/nginx/conf/nginx.conf
server {
... ...
location /tongji {
stub_status on;
access_log off;
}
}
ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
$ nginx
#启动nginx,并通过浏览器测试统计模块是否生效:http://ip/tongji
- rpm包
2、在zabbix agent中添加Nginx数据采集脚本实现流量数据收集,并添加到自定义监控中
可下载脚本使用: