Setting up Munin with Nginx and Ubuntu 12.10 (Quantal Quetzal)

A few years ago, I posted about our over-architected setup here at Codebetter. I had fun working with Rackspace cloud slices, and getting this all to run on ridiculously cheap, 256 M linux hosts.   One of the tools I’ve come to depend on for monitoring is Munin.

Munin is a networked resource monitoring tool that can help analyze resource trends and “what just happened to kill our performance?” problems. It is designed to be very plug and play. A default installation provides a lot of graphs with almost no work.

Here’s the graph of CPU usage since yesterday. Munin let’s you drill down into almost any aspect of your system, with plugins to allow you to monitor almost any service you may be running, and even support for monitoring Windows boxes.

Munin CPU monitoring

Check out this graph from Codebetter’s main app server’s CPU. How nice is that?

I’ve recently migrated to new servers yet again, and I ran into a few gotcha’s for Ubuntu 12.10 users that I’d like to post here.    It seems that most apps (WordPress for example) are much easier to configure under Apache than Nginx, and Munin is no different. If you crave the performance and configurability that Nginx brings, you’ll probably be used to taking a few extra steps to get applications to run properly.  This page from the Munin docs has some good starting points for setting up under Nginx, but even so I got stuck.  There’s one sentence that says the following:

Note: Depending on your installation method, the “munin-*-graph” programs may be in another directory. Check Makefile.config if you installed from source, or your package manager if you used that to install.

This may be obvious to some, but I ran into all sorts of problems until I understood what changes I had to make for everything to work.

1) Correct the path to the munin-cgi-graph and munin-cgi-script perl files, when you create your fast-cgi sockets

2) Correct NGINX configuration, here’s mine. Notice the location /muni-cgi/ changes to /cgi-bin/. Also notice that I’m running Munin at /, not /munin/ on my web server.

That’s it!  Happy monitoring!

About Brendan Tompkins

Brendan runs CodeBetter.Com. He was twice awarded MVP for Microsoft .NET, and is a founder and the CTO of Quick180.Com More about Brendan at https://www.linkedin.com/codebetter
This entry was posted in Monitoring, Munin, Nginx, Ubuntu. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.58bits.com Anthony Bouch
  • http://www.58bits.com Anthony Bouch

    Thanks for this. Where do you call the spawn-fcgi commands from? Are they scripted for server restarts?

  • KamalN7

    Thanks so much for this. The wiki should be updated.

  • http://codebetter.com Brendan Tompkins

    Updated the Gist.. Thanks!

  • Antonio

    Found a typo here, the command:

    spawn-fcgi -s /var/run/munin/fastcgi-html.sock -U www-data
     -u
    munin -g munin /usr/lib/cgi-bin/munin-html-graph

    should be

    spawn-fcgi -s
    /var/run/munin/fastcgi-html.sock -U www-data
     -u munin -g munin
    /usr/lib/cgi-bin/munin-cgi-html

  • Antonio

    Found a typo here, the command:

    spawn-fcgi -s /var/run/munin/fastcgi-html.sock -U www-data -u munin -g munin /usr/lib/cgi-bin/munin-html-graphshould be spawn-fcgi -s /var/run/munin/fastcgi-html.sock -U www-data -u munin -g munin /usr/lib/cgi-bin/munin-cgi-html