README.org

January 21, 2013 ยท View on GitHub

  • Nginx requests, memory usage and connections statistics with Munin

** Introduction

These three perl scripts are [[http://munin-monitoring.org][Munin]] plugins for monitoring the [[http://nginx.org][nginx]] HTTP server.

** nginx_status

Based on the one provided in the Debian [[http://packages.debian.org/squeeze/munin-node][munin-node]] package. Which is itself a modified version of the one available at the [[http://exchange.munin-monitoring.org][Munin Plugin Exchange]]. It shows the connection status for nginx.

Presents the values returned by nginx, using the [[wiki.nginx.org/NginxHttpStubStatusModule][http_stub_status]] module, are respectively, the number of:

/connections initiated/, /connections handled/, /requests served/

** TODO nginx_connection_request

Presents the number of requests served by connection handled by nginx. The requests-connection ratio handled by the server is the ratio:

requests served / connections handled

This is implemented as a RRDtool datasource of type =GAUGE=, the [[http://munin-monitoring.org/wiki/fieldname.type][default]] type for Munin.

** nginx_request

Based on the one provided in the Debian [[http://packages.debian.org/squeeze/munin-node][munin-node]] package. Which is itself a modified version of the one available at the [[http://exchange.munin-monitoring.org][Munin Plugin Exchange]].

It uses a derivative (technically a finite difference) to compute the connection rate value.

** nginx_memory

Based on a previous plugin by AkyRhO. It uses =ps= and =awk= to get the memory used by the master and worker processes of nginx.

** Installation & Configuration

  1. Copy all the scripts to =/etc/munin/plugins=.

  2. Restart the munin-node daemon: =/etc/init.d/munin-node restart=.

  3. Done. You should now start to see a new section nginx in your Munin pages with the corresponding graphs.

  4. All scripts have POD documentation. Issue =perldoc

** Environment Settings

Both =nginx_request= and =nginx_status= accept two environment variables:

  • URL: the URL of the nginx status data. The default value is:

    =http://hostname/nginx_status=

  • UA: the User Agent that the plugin sends in the HTTP header. Since most sites block the libwww-* user agent to get rid of bad bots and mostly up to no good scanners, the scripts send a different User Agent to get around that.

Both variables can be specified in the =/etc/munin/plugin-conf.d/munin-node= file.

Something like this for altering the URL:

[nginx_status] env.url=http://hostname:8888/nginx-status nginx_status

[nginx_connection_request] env.url=http://hostname:8888/nginx-status nginx_status

[nginx_request] env.url=http://hostname:8888/nginx-status nginx_status

Add =env.ua= for altering the User Agent.

Don't forget to restart the munin-node daemon as described in step 2 of the installation instructions above.

Note: the github handling of Org mode markup is broken. Therefore the =[nginx_status]= =[nginx_connection_request]= and =[nginx_request]= lines are separate from the lines specifying the environment variables.

It's not github's responsibility but rather a bug in [[http://orgmode.org/worg/org-tutorials/org-ruby.php][Org-Ruby]].