This post originated from an RSS feed registered with Python Buzz
by Aaron Brady.
Original Post: Zoomable Munin Graphs
Feed Title: insom.me.uk
Feed URL: http://feeds2.feedburner.com/insommeuk
Feed Description: Posts related to using Python. Some tricks and tips, observations, hacks, and the Brand New Things.
While looking for a replacement for Cacti (which we find hard to automate) at work we decided that Munin appeared to have the features that we wanted - except for one. Neil (my boss) cannot live without zoomable graphs.
So, one day of Perl (Hi Perl, how have you been?), PHP and Javascript later, I’ve beaten Munin into doing what I want. Searching around it looks like this is an oft-requested feature, so I thought I’d share.
This is not the cleanest code ever (though I don’t think it’s too bad), and it expects you to have a pretty stock Munin install, as it comes from Ubuntu / Debian, but it should require very little tweaking to get it running on just about any install.
Installing Zoomable Munin Graphs
================================
You will need the patched munin-graph utility (which I've dubbed mug locally,
as I don't want to interfere with system files). The patch is included, but
an executable copy based on the Munin that ships with Ubuntu 8.04 is here
too.
I've placed mine in /usr/local/bin, and this is where the PHP expects it.
(This is specified in the defines at the top of the file).
The user that your web server runs as will also need to be able run as the
munin user, at least on Debian derived systems. In my setup, I've added the
following to /etc/sudoers:
www-data = (munin) NOPASSWD: /usr/local/bin/mug
Which lets www-data execute this command, and only this command, as the
munin user. See sudoers(5) for more details.
Next, copy zoom.js and zoom.php to your Munin folder (/var/www/munin on
Debian derived systems), and then edit your "munin-serviceview.tmpl" template,
adding a reference to zoom.js in the <head> tags:
<script src="/munin/zoom.js"></script>
The script will latch itself to any images which are 495px wide, handling
their onclick events.
You may need to run /usr/share/munin/munin-html to update your already
generated HTML files.
Using Zoomable Graphs
=====================
Once the above has been done, you will be able to click through to the detail
page of any service, and click to start selecting. Click again to make your
selection.
At the moment, you must select the left-most point first, then the right.
To cancel making your selection, you can press escape.
I’d appreciate any patches or improvements, but I’m equally eager for someone (with more Perl than me) to take this and turn it into something that could get accepted into Munin itself.