~ 3 min read
Monitoring Drupal with Munin
Munin is a lightweight server/agent monitoring tool.
Basically, it works by installing agents on machines you wish to monitor and they report status messages to a munin server, which is another component (ofcourse both the server and agent can run on the same machine). Munin saves those status messages in it’s own data store and is integrated with rrdtool to produce nice looking graphs which give you an overview of daily, weekly, monthly and yearly periodical reports.
Munin In Drupal
Using Munin to monitor some internal Drupal statistics goes a long way regarding insight gathering of what’s going on your web application in real-time. While there are some munin related plugins to use on drupal.org I find it to be yet another module on top of already installed that I have and doesn’t really serve my need. End users can easily build their scripts to get the information they care about and this doesn’t need to exist within the Drupal app at all.
I’ve forked the munin’s contrib project on github and you can find a few scripts to get some nice and information from Drupal 6 already:
- total files
- total forums and comments
- node distribution count
- users online (total, anonymous vs registered users)
- users total vs blocked users
And there’s nothing like an image to please the eye…
All the code is here: https://github.com/lirantal/contrib/tree/master/plugins/drupal
We won’t dwell into the ins and outs of munin or it’s installation, as you can easily find out all of this information and more on munin’s website and Google, but here’s a short guide on it anyway for CentOS or RedHat-based distributions.
If munin package isn’t available in your repository try adding using
rpmforge (the following uses the RHEL5 64bit repositor):
rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
On the machine that hosts the munin server (it also hosts the html web resources) you should install the munin package:
yum install munin
Edit /etc/munin/munin.conf and setup the local host if you’re hoping to monitor the munin server too:
[localhost] address 127.0.0.1 use_node_name
Set a contact for alerts:
contact.liran.command mail -s "Munin notification" firstname.lastname@example.org
We’ll need to symlink the munin directory from where it installed to to your web directory and then we can create an alias for it too:
# add an alias for apache in /etc/httpd/conf/httpd.conf Alias /munin /var/www/munin Options FollowSymLinks AllowOverride None Order allow,deny Allow from all
So far this was the munin server side of things. If the same machine needs to be monitored too or if you need to install the munin monitoring agent on another machine you need to install the munin-node package:
yum install munin-node perl-libwww-perl
On that machine you will then need to enable the plugins you wish to use to monitor services. This can be done by symlinking them to say
/etc/munin/plugins and making sure they are set executable so that munin can run them. It comes with a hefty set of plugins by default, located probably at /usr/share/munin/plugins and you may need to tune plugins configuration using the main munin configuration file for the node at etc/munin/munin-node.conf