A simple template for a munin plugin.
You want to adjust %CONFIG and the show_values() sub.
To run/test from the command line:
munin-run plugin_name [config]
If munin-run isn't installed you can use:
./plugin_name [config]
Unless you are using config variables, in which case:
env var_name=some_value ./plugin_name [config]
see http://sysmonblog.co.uk/?p=17 for more help.
This is for Debian / Ubuntu machines but other *nixs should be similar.
copy or symlink plugin in /etc/munin/plugins/
adjust /etc/munin/plugin-conf.d/munin-node if required
If you wanted to pass a variable called 'foo' with a value 'bar' to a plugin called 'baz':
[baz]
env.foo bar
then in the plugin where you define %CONFIG you would have:
foo => get_config('foo')
and within your show_values() sub you could use this value:
if ($config{foo} eq 'bar') { ... }
sudo /etc/init.d/munin-node restart
Have a cup of tea and visit our blog while munin updates.
Send us variations for other systems and we will include them.
Patches welcomed.
You can safely ignore this entire section unless you are curious or looking for extended/advanced features.
autoconf let's your plugin tell the munin installer whether this plugin can run on a given machine.
Say your plugin relies on a Linux only feature but you are also a sysadmin for some BSD machines. By supporting autoconf your plugin will get installed on the (Linux) machines that can run it and ignored on BSD machines that can't.
To add autoconf support create a sub called autoconf() and have it return 'yes' if the plugin can run where it's currently installed, else 'no'.
For example this returns yes only if the uptime command can be found. If uptime isn't available, the plugin cannot work and won't get installed.
sub autoconf {
my (%config) = @_;
return 'yes'
if -e '/bin/uptime';
or -e '/usr/bin/uptime';
return 'no';
}
Copyright 2008 blog@sysmonblog.co.uk
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.