十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。

cacti监控nginx

上一篇 / 下一篇  2011-10-23 14:48:48 / 个人分类:性能测试

文章来源
  • 文章来源:【转载】

nginx编译时允许http_stub_status_module51Testing软件测试网1S4@l }r/aq

然后在 nginx.conf 中 添加如下(粗体字部分)51Testing软件测试网 B'rW;N0Ii"k

    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   /data/web_server/index;
            index  index.html index.htm;
        }

       location /NginxStatus {
         stub_status on;
         access_log off;
       }
51Testing软件测试网O/O Lk#Edg/z

}

@ rb tE'm:i `Y0

#killall -s HUP nginx  (令Nginx配置生效)
然后就通过 http://localhost/NginxStatus 来访问到Nginx的运行状态页面

&bk wg#Sk0


下载cacti for nginx 插件包: http://www.oschina.net/uploads/code/cacti-nginx.tar.gz51Testing软件测试网VT%H#P(eQw z+L

解压后一共有5个文件,首先把 get_nginx_socket_status.pl 以及 get_nginx_clients_status.pl 上传至服务器cacti 目录下scripts 并设置可执行权限跟755读写权限51Testing软件测试网)h,AO/o9x

检测插件(举例)

6LG.Y1`Ob0

# /data/cacti/scripts/get_nginx_clients_status.pl http://192.168.1.100/NginxStatus
显示的内容跟 NginxStatus 状态页内容相当即可。

4\J#dfq'[6?,o4G0

然后在cacti管理面板导入51Testing软件测试网;Gp"y x^bKo[ z"Wo+Q

导入的方式是 Import Templates  >  Import Template from Local File (浏览导入插件包另外2个文件)

;z8d%| G(E z6fd \0

cacti_graph_template_nginx_clients_stat.xml
cacti_graph_template_nginx_sockets_stat.xml51Testing软件测试网?$Q8nB]3s5y

但详细操作起来可能会有个麻烦!51Testing软件测试网5[|,gT^_n2u

导入 cacti_graph_template_nginx_clients_stat.xml 跟 cacti_graph_template_nginx_sockets_stat.xml  的时候,cacti 出现红字提醒:51Testing软件测试网kkG:X6OB

Error: XML: Hash version does not exist.51Testing软件测试网 C_}mrS

解决:因为你的 cacti 版本太旧了,去Cacti 下个最新版吧:http://www.cacti.net/download_cacti.php51Testing软件测试网I/YD"ax%O

导入成功后会显示:51Testing软件测试网R"wp{7yw-L

51Testing软件测试网/HE+BzR1O{7~h

Import Results

Cacti has imported the following items:51Testing软件测试网t"w*fN,d$~Rh

GPRINT Preset

K6[;g y.F K3PMV%b0[success] Normal [update]

Data Input Method51Testing软件测试网{CD s7j

[success] nginx clients stat [update]

Data Template51Testing软件测试网+L1}TC?

[success] Nginx Clients Stat [update]

Graph Template

;E3Vxm'H;W0[success] Nginx Clients Stat [update]

Q&@"o9Q|J'E0

然后你就能在 Graph Templates 中看到你刚所导入 Xml 后所产生的模板

'GF(}*FF0

pttH NUv+R0

接着进入New Graphs 选择任意一台已经创建好图标的监控服务器。

:S,s[2M&w`Y0

+N ^.Fy~0

呵...然后接下来的步骤不用说了吧? 就跟创建网卡,CPU等之类的图表方式一样。

0Qf h_i4X)d0

r1@EPw`V0

TAG: cacti nginx Nginx NGINX

 

评分:0

我来说两句

Open Toolbar