cacti监控apache和nginx的配置

一.监控apache
1.下载http://forums.cacti.net/about25227.html&highlight=apachestats
2.其中的ss_apache_stats.php是脚本文件,它是一个php的文件,放到你的cacti/scripts/下面
3.接下来在cacti界面导入cacti_host_template_webserver_-_apache.xml这个文件
4.在被监控主机上设置apache的mod_status
(1).编辑apache配置文件,去掉ExtendedStatus On前面的注释
(2).配置或取消以下文件的注释:
<Location /server-status>
   SetHandler server-status
   Order deny,allow
   Deny from all
   Allow from <IP>
</Location>

二.监控Nginx
1.首先nginx编译时允许http_stub_status_module,不然是监控不到nginx的运行状态的
2.编辑配置文件:
    # vi /etc/nginx/conf/nginx.conf  
     
    location /NginxStatus/ {  
     
    stub_status on;  
     
    access_log off;  
     
    allow 127.0.0.1;
     
    deny all;  
     
    }  
3.重启nginx
4.下载http://forums.cacti.net/download/file.php?id=12676
5.将get_nginx_clients_status.pl和get_nginx_socket_status.pl文件放入cacti的scripts文件夹下
6.检查是否工作:
get_nginx_clients_status.pl http://127.0.0.1/NginxStatus/
如果出现 no (LWP::UserAgent not found) 的错误
运行
yum -y install perl-libwww-perl

如果出现类似如下信息
nginx_accepts:113869 nginx_handled:113869 nginx_requests:122594

表明成功

7.在cacti中导入cacti_graph_template_nginx_clients_stat.xml 和 cacti_graph_template_nginx_sockets_stat.xml
8.增加图像到设备

原文地址:https://www.cnblogs.com/itfenqing/p/4442211.html