I am not a big fan of munin's default templates; so I wrote my own and usually uses that one (see http://monitor.thehumanjourney.net/munin/). Writing templates for munin is extremely easy, as munin uses the html template package from perl, libhtml-template-perl. The templates files are also located with the configuration files, in /etc/munin/templates; as these files are separated from the core of munin, they are not affected by upgrades.

Documentation about libhtml-template-perl is accessible via man HTML::Template. Basically, munin's template files are normal HTML files, with a couple of additional markup provided by HTML::Template enabling the use of conditional statements and loops, like <TMPL_IF> or <TMPL_LOOP> . This is for example the main loop in /etc/munin/munin-nodeview.tmpl, displaying the list of services:
<TMPL_LOOP NAME="CATEGORIES">
<tr><td class="graphbox" id="<TMPL_VAR ESCAPE="HTML" NAME="NAME">">
<table>
<!-- <a id="<TMPL_VAR ESCAPE="HTML" NAME="NAME">"> </a> -->
<tr><td colspan="2"><h3 class="nobottom"> <TMPL_VAR ESCAPE="HTML" NAME="NAME"></h3></td></tr>
<tr><td colspan="2"><hr class="ruler2" /></td></tr>
<TMPL_LOOP NAME="SERVICES">
<tr><td></td></tr>
<tr><td><div class="lighttext">:: <a <TMPL_IF NAME="STATE_WARNING">class="warn"</TMPL_IF> <TMPL_IF NAME="STATE_CRITICAL">class="crit"</TMPL_IF> href="<TMPL_VAR NAME="URL">"><TMPL_VAR ESCAPE="HTML" NAME="LABEL"></a></div></td></tr>
<tr>
<td><a href="<TMPL_VAR NAME="URL">"><img src="<TMPL_VAR NAME="IMGDAY">" alt="<TMPL_VAR ESCAPE="HTML" NAME="LABEL">" <TMPL_IF NAME="IMGDAYWIDTH">width="<TMPL_VAR NAME="IMGDAYWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGDAYHEIGHT">height="<TMPL_VAR NAME="IMGDAYHEIGHT">"</TMPL_IF>/></a></td>
<td><a href="<TMPL_VAR NAME="URL">"><img src="<TMPL_VAR NAME="IMGWEEK">" alt="<TMPL_VAR ESCAPE="HTML" NAME="LABEL">" <TMPL_IF NAME="IMGWEEKWIDTH">width="<TMPL_VAR NAME="IMGWEEKWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGWEEKHEIGHT">height="<TMPL_VAR NAME="IMGWEEKHEIGHT">"</TMPL_IF>/></a></td>
</tr>
</TMPL_LOOP>
</table>
</td></tr>
<tr><td></td></tr>
</TMPL_LOOP>
The HTML code is not the best ever... There is a lot to optimise there :) If you want to see which variables are available in each file, have a look at /usr/share/munin/munin-html, at the list of arguments given to template_name->param; here is the call for the nodeview:
$nodetemplate->param(NODE => $node,
DOMAIN => $domain,
DOMAINS => \@domainlist,
TIMESTAMP => $timestamp,
CATEGORIES => \@categories);
So for the node view, you will have the name of the current node, the name of the current domain, a list of all the domains, a timestamp corresponding to the time the page has been generated, and a list of the categories for that node; the list of the categories also contains the list of the services - but you have either to look higher in the code or in the current template to know that.
So, let your imagination act; I have never found other templates than the default one, and I would love this to change!
| Attachment | Size |
|---|---|
| Munin - Example of a custom template | 29.95 KB |