Nginx
五、Nginx监控
## 1、 RRDTOOL+Perl脚本画图监控 先安装好rrdtool ,关于rrdtool本文不作介绍,具体安装请参照linuxtone监控版块. ```shell #cd /usr/local/sbnin #wget http://blog.kovyrin.net/files/mrtg/rrd_nginx.pl.txt #mv rrd_nginx.pl.txt rrd_nginx.pl #chmod a+x rrd_nginx.pl #vi rrd_nginx.pl //配置脚本文件设置好路径 #!/usr/bin/perl use RRDs; use LWP::UserAgent; # define location of rrdtool databases my $rrd = '/data/www/wwwroot/nginx/rrd'; # define location of images my $img = '/data/www/wwwroot/nginx/html'; # define your nginx stats URL my $URL = "http:// 219.32.205.13/nginx_status"; ………… ``` 【注】根据自己具体的状况修改相应的路径. ```shell #crontab –e //加入如下 * * * * * /usr/local/sbin/rrd_nginx.pl ``` 重启crond后,通过配置nginx虚拟主机指到/data/www/wwwroot/nginx/html目录,通过crond自动执行perl脚本会生成很多图片. http://xxx/connections-day.png即可看到服务器状态图。 ## 2、 官方Nginx-rrd 监控服务(多虚拟主机)(推荐) 网址:http://www.nginx.eu/nginx-rrd.html 此解决方案其实是基于上述监控方案的一个改进和增强,同样先安装好rrdtool这个画图工具和相应的perl模块再做如下操作: ```shell # yum install perl-HTML* 先建立好生成的库存和图片存放录 #mkdir -p /data/www/wwwroot/nginx/{rrd,html} #cd /usr/local/sbin #wget http://www.nginx.eu/nginx-rrd/nginx-rrd-0.1.4.tgz #tar zxvf nginx-rrd-0.1.4.tgz #cd nginx-rrd-0.1.4 #cd etc/ #cp nginx-rrd.conf /etc #cd etc/cron.d #cp nginx-rrd.cron /etc/cron.d #cd /usr/local/src/nginx-rrd-0.1.4/html # cp index.php /data/www/wwwroot/nginx/html/ #cd /usr/local/src/nginx-rrd-0.1.4/usr/sbin #cp * /usr/sbin/ #vi /etc/nginx-rrd.conf ##################################################### # # dir where rrd databases are stored RRD_DIR="/data/www/wwwroot/nginx/rrd"; # dir where png images are presented WWW_DIR="/data/www/wwwroot/nginx/html"; # process nice level NICE_LEVEL="-19"; # bin dir BIN_DIR="/usr/sbin"; # servers to test # server_utl;server_name SEVERS_URL = "http://domain1/nginx_status;domain1 http://domain2/nginx_status;domain2"//根据你的具体情况做调整. ``` - 这种格式监控多虚拟主机连接状态:重点启crond服务,仍后通过http://219.32.205.13/nginx/html/ 即可访问。配置过程很简单! ## 3、 CACTI模板监控Nginx 利用Nginx_status状态来画图实现CACTI监控 nginx编译时允许http_stub_status_module ```shell # vi /usr/local/nginx/conf/nginx.conf location /nginx_status { stub_status on; access_log off; allow 192.168.1.37; deny all; }# kill -HUP `cat /usr/local/nginx/logs/nginx.pid` # wget http://forums.cacti.net/download.php?id=12676 # tar xvfz cacti-nginx.tar.gz # cp cacti-nginx/get_nginx_socket_status.pl /data/cacti/scripts/ # cp cacti-nginx/get_nginx_clients_status.pl /data/cacti/scripts/ # chmod 755 /data/cacti/scripts/get_nginx* 检测插件 # /data/cacti/scripts/get_nginx_clients_status.pl http://192.168.1.37/nginx_status 在cacti管理面板导入 cacti_graph_template_nginx_clients_stat.xml cacti_graph_template_nginx_sockets_stat.xml ```
顶部
收展
底部
[TOC]
目录
一、 Nginx 基础知识
二、 Nginx 安装及调试
三、nginx php-fpm安装配置
四、常见错误处理
五、Nginx监控
六、Nginx 负载均衡
七、nginx反向代理配置
八、Nginx Rewrite
九、Nginx安全
十、nginx基本配置与参数说明
十一、Nginx Redirect、Location
十二、nginx 高并发配置参数
十三、Nginx 参数优化
十四、Nginx 虚拟主机配置例子
相关推荐
Apache