Munin Monitoring on Ubuntu

Munin is a wonderful tool that creates easy-to-read graphs of (just about) everything you need to know to keep your servers humming along. Setup is very simple, but it isn’t something I do often enough to remember all the steps off the top of my head. Although there are plenty of great tutorials out there, none of them QUITE fit my setup perfectly. so…

On the Master Node (aka the server that you want to do the monitoring from…typically your app server since you’ll need apache or another web server):

  1. install munin (don’t worry, this tutorial gets better!)
  2. sudo apt-get update (always smart)
  3. sudo apt-get install munin munin-node munin-plugins-extra
  4. sudo nano /etc/munin/munin.conf
  5. uncomment (#) the htmldir line and change it to “/var/www/munin”
  6. set up the “host tree”. For now, just change the name of the server from “localhost.localdomain” to something more descriptive. Important: no spaces, underscores or special characters in the server name.
    # a simple host tree
    [servername]
    address 127.0.0.1
    use_node_name yes
  7. sudo nano /etc/munin/munin-node.conf
  8. change the bind address from “host *” to “host 127.0.0.1″.
  9. create folder and set ownership: sudo mkdir /var/www/munin & sudo chown -R munin:munin /var/www/munin
  10. Add apache directory for munin:
    sudo nano /etc/apache2/sites-available/default
    Alias /munin “/var/www/munin/”
    <Directory “/var/www/munin/”>
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from localhost
    </Directory>
  11. turn apache extended status on:
    sudo nano /etc/apache2/mods-available/status.conf
    ExtendedStatus On
    <Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost ip6-localhost 127.0.0.1
    Allow from yourdomain.com
    Allow from xx.xx.xxx.xxx
    </Location>
  12. symlink any extra plugins you want.
    cd /etc/munin/plugins
    sudo ln -s /usr/share/munin/plugins/memcached_ memcached_rates
    (for plugins like memcached_  the underscore indicates that there are multiple plugins included. Link to each as shown above. Memcached_ includes _rates, _bytes, and _counters.)
    note - for memcached you have to also be sure you are running:
    sudo apt-get install libcache-memcached-perl
    for mysql:
    sudo apt-get install libcache-cache-perl libipc-sharelite-perl
  13. Restart munin and apache:
    sudo /etc/init.d/munin-node restart
    sudo /etc/init.d/apache2 restart
  14. Run Munin manually (if you’re too lazy to wait 5 minutes for the cron job to run)
    sudo -u munin munin-cron
  15. Troubleshooting: sudo /usr/sbin/munin-node-configure –suggest
    will generate a very helpful list.
  16. for http_loadtime plugin: sudo apt-get install wget time

Drupal Users: don’t forget to add “RewriteCond %{REQUEST_URI} !=/server-status” to your .htaccess file.

On other nodes:

  1. sudo apt-get update
  2. sudo apt-get install munin-node munin-plugins-extra
  3. sudo nano /etc/munin/munin-node.conf
    host_name <nodename>
    allow <ip of master node> (ip format: ^127\.0\.0\.1$)
    set bind address to local node’s ip (rackspace: use internal ip)
  4. add plugins (see step 12 above).
  5. note: varnish_ contains:
    varnish_backend_traffic
    varnish_hit_rate
    varnish_memory_usage
    varnish_objects
    varnish_request_rate
    varnish_threads
    varnish_transfer_rates
    varnish_uptime

Adding nodes to main node:

  1. sudo nano /etc/munin/munin.conf
  2. add new node to the host tree. “newnode” = node’s hostname
    # a simple host tree
    [newnode]
    address xxx.xxx.xx.x (rackspace: use internal ip)
    use_node_name yes

This entry was posted in Programming and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>