此方案需先开启Nginx状态监控,Cacti服务器安装数据获取脚本:
wget https://www.haiyun.me/download/cacti-nginx.tar.gz
tar zxvf cacti-nginx.tar.gz
cd cacti-nginx
cp get_nginx_clients_status.pl cactipath/scripts/
cp get_nginx_socket_status.pl cactipath/scripts/
chmod 0755 cactipath/scripts/get_nginx_socket_status.pl
chmod 0755 cactipath/scripts/get_nginx_clients_status.pl
测试数据获取:
perl get_nginx_clients_status.pl https://www.haiyun.me/nginx_status
nginx_active:2 nginx_reading:0 nginx_writing:1 nginx_waiting:1
如出现no (LWP::UserAgent not found)需安装perl组件:
yum -y install perl-libwww-perl
Cacti管理界面导入xml模板,相关主机添加Nginx Clients Stat、Nginx Sockets Stat模板。
Nginx监控效果图如下: