munin plugin for nginx

Grant emailgrant at gmail.com
Tue Jun 18 15:08:06 UTC 2013


> Replace
>
> [nginx*]
> env.url http://localhost/nginx_status
>
> with
> [nginx_*]
> user root

Thanks!

- Grant


> my nginx default file
>
> egrep -v "(^$|^#)" /etc/nginx/sites-enabled/default
> server {
>         listen   80; ## listen for ipv4
>         listen   [::]:80 default ipv6only=on; ## listen for ipv6
>         server_name  localhost;
>         access_log  /var/log/nginx/localhost.access.log;
>         location / {
>                 root   /var/www;
>                 index  index.html index.htm;
>         }
>         location /doc {
>                 root   /usr/share;
>                 autoindex on;
>                 allow 127.0.0.1;
>                 deny all;
>         }
>         location /images {
>                 root   /usr/share;
>                 autoindex on;
>         }
>                 location /nginx_status {
>                 stub_status on;
>                 access_log   off;
>                 allow 127.0.0.1;
>                 deny all;
>         }
>
>         #error_page  404  /404.html;
>         # redirect server error pages to the static page /50x.html
>         #
>         #error_page   500 502 503 504  /50x.html;
>         #location = /50x.html {
>         #       root   /var/www/nginx-default;
>         #}
>         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
>         #
>         #location ~ \.php$ {
>                 #proxy_pass   http://127.0.0.1;
>         #}
>         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
>         #
>         #location ~ \.php$ {
>                 #fastcgi_pass   127.0.0.1:9000;
>                 #fastcgi_index  index.php;
>                 #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
>                 #includefastcgi_params;
>         #}
>         # deny access to .htaccess files, if Apache's document root
>         # concurs with nginx's one
>         #
>         #location ~ /\.ht {
>                 #deny  all;
>         #}
> }
>
>
>
> Am 18.06.2013 16:10, schrieb Grant:
>
>>> My config looks like:
>>>
>>> /etc/munin/plugin-conf.d/munin-node
>>>
>>> ...
>>> [nginx_*]
>>> user root
>>>
>>> /etc/nginx/sites-enabled/default
>> I don't have /etc/nginx/sites-enabled/ at all.  What kind of stuff is
>> in the default file?  I'm on Gentoo.
>>
>> - Grant
>>
>>
>>> ...
>>> ## munin nginx status (request/ connections handeled)
>>> location /nginx_status {
>>>    stub_status on;
>>>    access_log   off;
>>>    allow 127.0.0.1;
>>>    deny all;
>>> }
>>> ...
>>> This runs for me very well, so try to edit your
>>> /etc/munin/plugin-conf.d/munin-node.
>>> You can also Debug by
>>>
>>>  munin-configure --suggest
>>>
>>> Am 18.06.2013 15:42, schrieb Grant:
>>>>>>> I'm having some trouble getting the nginx plugin working for munin.
>>>>>>> I've added the following to nginx config and restarted:
>>>>>>>
>>>>>>> location /nginx_status {
>>>>>>> stub_status on;
>>>>>>> access_log off;
>>>>>>> allow 127.0.0.1;
>>>>>>> deny all;
>>>>>>> }
>>>>>>>
>>>>>>> I've added the following munin config:
>>>>>>>
>>>>>>> [nginx*]
>>>>>>> env.url http://localhost/nginx_status
>>>>>>>
>>>>>>> Unfortunately I still get:
>>>>>>>
>>>>>>> # munin-run nginx_request
>>>>>>> request.value U
>>>>>>> # munin-run nginx_status
>>>>>>> total.value U
>>>>>>> reading.value U
>>>>>>> writing.value U
>>>>>>> waiting.value U
>>>>>>>
>>>>>>> If I remove the allow/deny, I can browse to /nginx_status and I get:
>>>>>>>
>>>>>>> Active connections: 13
>>>>>>> server accepts handled requests
>>>>>>> 15 15 16
>>>>>>> Reading: 0 Writing: 1 Waiting: 12
>>>>>>>
>>>>>>> What could be the problem?
>>>>>> the munin plugin is broken or not getting the status information.
>>>>>>
>>>>>> Try stracing the munin-run, network capature or turning on the access logs on /nginx_status just to be sure.
>>>>>>
>>>>> Well, I run it all over the place with no problem. I usually set it up
>>>>> only on localhost
>>>>>
>>>>> server {
>>>>>         listen 127.0.0.1:80 default;
>>>>>         server_name localhost;
>>>>>         root   /var/www;
>>>>>
>>>>>         access_log  /var/log/nginx/localhost.access.log;
>>>>>         error_log  /var/log/nginx/localhost.error.log;
>>>>>
>>>>>         location ~ /nginx_status {
>>>>>                 stub_status on;
>>>>>                 access_log   off;
>>>>>                 allow 127.0.0.1;
>>>>>                 deny all;
>>>>>         }
>>>>> }
>>>>>
>>>>> ( in /etc/nginx/conf.d/stub, or /etc/nginx/sites-available/stub,
>>>>> symlinked to ../sites-enabled/stub depending on preference ) and restart
>>>>> nginx.
>>>>>
>>>>> Then test this bit works...
>>>>>
>>>>> $ wget -O - http://localhost/nginx_status 2> /dev/null
>>>>> Active connections: 1
>>>>> server accepts handled requests
>>>>>  67892 67892 70215
>>>>> Reading: 0 Writing: 1 Waiting: 0
>>>>>
>>>>> Some os's seem to like
>>>>>
>>>>> [nginx*]
>>>>> env.url http://localhost/nginx_status
>>>>>
>>>>> added to /etc/munin/plugin-conf.d/munin_node
>>>>>
>>>>> then
>>>>>
>>>>> munin-run nginx_status
>>>>>
>>>>> should run just fine.
>>>> You fixed it!  Reducing it to the simplest config that still works, I
>>>> found that the location /nginx_status block doesn't work with munin
>>>> inside of any other server block.  It only works inside its own server
>>>> block like so:
>>>>
>>>> server {
>>>>    location ~ ^/nginx_status$ {
>>>>       stub_status on;
>>>>       access_log off;
>>>>       allow 127.0.0.1;
>>>>       deny all;
>>>>    }
>>>> }
>>>>
>>>> Is this a munin bug?
>>>>
>>>> Thank you!
>>>>
>>>> - Grant



More information about the nginx mailing list