1. 确认你的nginx加载了http_stub_status_module模块,没有的话,重新编译。
查看Nginx版本:
1 | [root@hexuweb102 monitor]$ /usr/ local /nginx/sbin/nginx - v |
查看安装哪些模块:
1 | [root@hexuweb102 monitor]$ /usr/ local /nginx/sbin/nginx -V |
从上面看,我的已经安装,如果你的没有安装使用下方法重新编译安装即可:
01 | [root@hexuweb102 monitor]$ tar zxf nginx-1.0.4. tar .gz |
02 | [root@hexuweb102 monitor]$ cd nginx-1.0.4 |
03 | [root@hexuweb102 monitor]$./configure \ |
04 | --prefix=/usr/ local /nginx \ |
07 | --with-http_ssl_module \ |
08 | --with-http_stub_status_module \ |
09 | --with-http_gzip_static_module |
10 | [root@hexuweb102 monitor]$ make && make install |
2. 在Nginx Server (Vhost) 添加下面代码:
01 | [root@hexuweb102 monitor]$ vi /usr/ local /nginx/conf/nginx.conf |
04 | server_name localhost; |
05 | location /nginx_status { |
下载nginx plugin for munin,重命名为nginx_combined_
将文件拷贝(到你的munin插件库目录)并改名字:
1 | [root@hexuweb102 monitor]$ cp ./Nginx_Combined-v2 /opt/munin/lib/plugins/nginx_combined_ |
然后 ln 到(注意后面名字会显示在 munin):
1 | [root@hexuweb102 monitor]$ ln -s /opt/munin/lib/plugins/nginx_combined_ /etc/opt/munin/plugins/nginx_combined |
完成上面两步之后,重启munin-node即可,如果想马上看到就执行一下munin-cron:
1 | [root@hexuweb102 monitor]$ ps aux | grep munin |
2 | [root@hexuweb102 monitor]$ kill $muninId |
3 | [root@hexuweb102 monitor]$ kill $muninId |
4 | [root@hexuweb102 monitor]$ /opt/munin/sbin/munin-node |
5 | [root@hexuweb102 monitor]$ /opt/munin/bin/munin- cron |
nginx_combined 默认Title个人感觉整个不合配置,改下面内容即可:
3 | print "graph_title NGINX status combined\n" ; |
注意,如果所有操作完成后,为确保成功正常的运行,可以使用munin-run测试,下面使用munin自带的nginx_request测试
常见问题: munin监控nginx出现 no (LWP::UserAgent not found)
1 | [root@hexuweb102 monitor]$ /opt/munin/sbin/munin-run nginx_request |
发现有BUG了,是因为perl-libwww-perl没有安装,安装即可:
1 | [root@hexuweb102 monitor]$ yum -y install perl-libwww-perl |
然后再确认:
1 | [root@hexuweb102 monitor]$ /opt/munin/sbin/munin-run nginx_request |