Sep 30, 2010

Posted by in Linux | 2 Comments

Munin under Nginx controll

Munin under Nginx controll

Are you using Nginx on your own server? I will show you, how to integrate the Munin monitoring tool with you webserver.

Munin is “networked resource monitoring tool” which can be used to automatic observation of your OS procs.

The default setup provide following graphs:

  • Disk usage
  • Inode usage
  • MySQL throughput
  • MySQL queries
  • MySQL slow queries
  • MySQL threads
  • venet0 traffic
  • Fork rate
  • Number of Processes
  • VMstat
  • Sendmail queued mails
  • Sendmail email traffic
  • Sendmail email volumes
  • CPU usage
  • Available entropy
  • Interrupts & context switches
  • Load average
  • Memory usage
  • File table usage
  • Inode table usage
  • Swap in/out

Installation

If your OS is Debian then installation is very easy:

1. Download and install Nginx:

cd /tmp
wget http://nginx.org/download/nginx-0.8.52.tar.gz
tar zxvf nginx-0.8.52.tar.gz
cd nginx-0.8.52
./configure --with-http_ssl_module --with-http_stub_status_module
make && make install
cd ..
rm -fr nginx-0.8.52*

2. Install munin from apt.

apt-get install munin munin-node

Configuration

All configuration files are store in the /etc/munin directory. Default settings are OK but we want to add Munin plugin to observe our Nginx http server.

1. Create Nginx vhost configuration. Add this, to /usr/local/nginx/conf/nginx.conf (http section):

server {
    listen   80;
    server_name  localhost;

    location / {
        root                    /var/www/munin/;
        index                   index.html;
        auth_basic              "Restricted";
        auth_basic_user_file    /var/www/munin/htpasswd;
    }

    location /nginx_status {
        stub_status             on;
        access_log              off;
        allow                   127.0.0.1;
        deny                    all;
    }
}

2. Protect Munin access (default statistics are available for all users):

mkdir /var/www/munin -p
cd /var/www/munin
htpasswd -b htpasswd YourLogin YourPassword

3. Download plugins nginx_status and nginx_request:

cd /etc/munin/plugins
wget http://exchange.munin-monitoring.org/plugins/nginx_status/version/3/download -O nginx_status
wget http://exchange.munin-monitoring.org/plugins/nginx_request/version/2/download -O nginx_request
chmod +x nginx_*

4. Configure plugins in Munin`s node:

In the /etc/munin/plugin-conf.d/munin-node file add this two lines:

[nginx*]
env.url http://localhost/nginx_status

5. Restart munin-node and nginx

/etc/init.d/munin-node restart
/etc/init.d/nginx restart
  1. Love your site man keep up the good work

  2. Awesome! Thanks man!

Trackbacks/Pingbacks

  1. Munin monitoring | Andrew Berezovskiy notes - [...] http://artursmolarek.com/2010/09/30/munin-under-nginx-controll/ Запись опубликована в рубрике administration, debian, hosting, nginx, ubuntu с метками munin, rrdtool. Добавьте в ...

Leave a Reply