/ BLOG / Graphing Micromiser with Munin

I’ve been playing with Micromiser for a few days, and wanted to graph what it claims to be saving on one of the servers. Luckily this is pretty easy with Munin (which is already running on the box), since Micromiser logs into syslog occasionally. Below is the plugin I hacked together that looks at syslog and uses sed to extract the percentage saving. It’s not pretty, but it does work.

Perhaps this’ll save you a few minutes.

#!/bin/sh

# Plugin to graph the savings made by micromiser

if [ "$1" = "autoconf" ]; then echo yes exit 0 fi

if [ "$1" = "config" ]; then

    <span class="nb">echo</span> <span class="s1">&#39;graph_title Micromiser Savings (percentage)&#39;</span>
    <span class="nb">echo</span> <span class="s1">&#39;graph_args --upper-limit 100 -l 0&#39;</span>
    <span class="nb">echo</span> <span class="s1">&#39;graph_vlabel savings&#39;</span>
    <span class="nb">echo</span> <span class="s1">&#39;graph_category system&#39;</span>
    <span class="nb">echo</span> <span class="s1">&#39;savings.label savings&#39;</span>
<span class="nb">echo</span> <span class="s1">&#39;savings.draw AREA&#39;</span>
    <span class="nb">echo</span> <span class="s1">&#39;savings.min 0&#39;</span>
    <span class="nb">exit </span>0

fi

RES=</span>grep Estimated /var/log/syslog <span class="p">|</span> tail -1 <span class="p">|</span> sed <span class="s1">&#39;s/.*(\([0-9\.]*\)%)$/\1/&#39;</span><span class="sb"> echo -n "savings.value $RES"