Mar 12
Free Software Munin is a great, really useful project for monitoring all sorts of things on servers over short and long term periods, and can help identify and even warn of undue server loads. It is also appropriately and poetically named for one of Odinn's crows (so I suppose I should have written this on a Wednesday).

We've been running Munin on one of our production servers at work for quite some time, and it gives us a lot of confidence that, to say the least, the server is running in its comfort zone around the clock. Among other bits and pieces, we run OPUS and the PDSystem on this box, two of our home grown projects that are available to the students. For some time now I've considered writing a plugin for OPUS to show logged in users, and I finally did this, albeit the counts are not nearly so reliable as I'd like for two reasons, but I'll probably discuss that in another post. Anyway, I arranged for OPUS to drop a simple text file which simply contains counts of online users with the syntax

student: 10
admin: 2
 
and so on, for each of the categories of users. Then I needed a plugin to deal with this. I decided to write it simple shell script, since its portable and I'm not much of a perl fan.

#!/bin/sh

#
# Munin plugin for OPUS showing online users
# Copyright Colin Turner
# GPL V2+
#

# Munin plugins, at their simplest, are run either with "config" or
# no parameters (I plan to add auto configuration later).
case $1 in
  config)
  # In config mode, we spout out details of the graphs we will have
  # I want one graph, with lots of stacked values. The first one is
  # an AREA, and the others are stacked above them. I also (-l 0)
  # make sure the graph shows everything down to zero.
        cat <<'EOM'
graph_title OPUS online users
graph_args -l 0
graph_vlabel online users
graph_info The number of online users on OPUS is shown.
student.label student
student.min 0
student.draw AREA
staff.label academic
staff.min 0
staff.draw STACK
company.label hr staff
company.min 0
company.draw STACK
supervisor.label supervisor
supervisor.min 0
supervisor.draw STACK
admin.label admin
admin.min 0
admin.draw STACK
root.label root
root.min 0
root.draw STACK
application.label application
application.min 0
application.draw STACK
EOM
        exit 0;;
esac

# Now the plugin is being run for data. Bail if the file is unavailable
if [ ! -r /var/lib/opus/online_users ] ; then
     echo Cannot read /var/lib/opus/online_users >&2
     exit -1
fi

# Otherwise, a quick sed converts the default format to what Munin needs
cat /var/lib/opus/online_users | sed -e "s/:/.value/"
 
The plugin has now been running for several days, and you can see its output here. There are problems with it, but that's more to do with PHP, Debian and user choice, and I'll comment on that another time. However, already it gives me a useful feel for a lot of user behaviour.

Writing Munin plugins is easy, and Munin does so much of the hard work of turning your creation into something useful.

Posted by Colin Turner

Defined tags for this entry: , , ,
Bookmark My first Munin plugin  at del.icio.us Digg My first Munin plugin Mixx My first Munin plugin Bloglines My first Munin plugin Technorati My first Munin plugin Fark this: My first Munin plugin Bookmark My first Munin plugin  at YahooMyWeb Bookmark My first Munin plugin  at Furl.net Bookmark My first Munin plugin  at reddit.com Bookmark My first Munin plugin  at blinklist.com Bookmark My first Munin plugin  at Spurl.net Bookmark My first Munin plugin  at NewsVine Bookmark My first Munin plugin  at Simpy.com Bookmark My first Munin plugin  at blogmarks Bookmark My first Munin plugin  with wists Bookmark My first Munin plugin  at Ma.gnolia.com wong it! Bookmark using any bookmark manager! Stumble It!

1 Trackbacks

  1. Proving the Obviously Untrue

    Garbage collecting sessions in PHP
    In PHP, sessions are by default stored in a file in a directory. Sessions can be specifically destroyed from within the code, for example when users logout explicitly, but frequently they do not. As a result session files tend to hang around, and cause th

2 Comments

Display comments as(Linear | Threaded)
  1. Joaquim Homrighausen says:

    How does Munin compare to for example OpenNMS and Zabbix?

  2. Colin Turner says:

    Hi Jack,

    I can't really say. I think the latter are better at managing coarse status lights on racks of machines. I can only say I find Munin useful for drilling down on the reasons for performance issues, as well as showing downtime.

    CT.

Add Comment



To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

BBCode format allowed
Standard emoticons like :-) and ;-) are converted to images.
You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.