Munin plugins basically need to output variable names and values, and a little bit of config. They're tremendously easy to write.
- #! /bin/bash
- case $1 in
- cat < < EOF
- graph_category amusement
- graph_title Random numbers
- graph_vlabel value
- debian.label debian
- dilbert.label dilbert
- urandom.label /dev/urandom
- graph_scale no
- exit 0
- urandom=$(cat /dev/urandom | tr -dc '0-9' | head -c2)
- echo "urandom.value " $urandom
- echo "debian.value 4"
- echo "dilbert.value 9"
Munin's plugins live in /etc/munin/plugins/, most of which are symlinks to scripts in /usr/share/plugins/. On restart, munin-node rechecks the plugins directory and loads any new plugins.
For a plugin called foo, munin-node will run foo configure first to get the configuration of the graph (which is passed to munin-graph), and then foo. For information as to graph configuration, see here.
It takes about 15 mins of collection for it to start making a graph, and you'll get more data every 5mins thereafter.
The script itself is mostly self-explanatory, except for:
- The values and the labels are linked by what occurs before the dot. If you define foo.label in the config output, that is what will be used to label the number that comes after foo.value in the 'normal' output. The munin tutorial sort-of hints at this, but only uses one variable.
- Munin doesn't care what order the variables come out in, it uses the labels to determine who's who. Similarly, it doesn't seem particularly fussed as to which flavour of horizontal whitespace is used.