tldr; Munin configuration key/value pairs are environment variables that are injected into a specific plugin's execution environment at runtime. They must be accessed from within the plugin's code like any other system environment variable.
Munin Plugin Execution
Each munin plugin is a standalone executable file. At runtime, Munin creates a separate environment for each plugin into which it injects variables that the plugin can reference. There are two groups of environment variables: munin core and plugin specific.
Tip: Use munin-run -d load_per_core
to see what environment variables are being injected into your plugin's environment.
How to Define Environment Variables
Plugin specific environment variables are declared per plugin using the syntax:
#/etc/munin/plugin-conf.d/zz-name_of_your_plugin
[name_of_your_plugin]
env.identifier value
Which in your case would be:
#/etc/munin/plugin-conf.d/zz-load_per_core
[load_per_core]
env.load_per_core.warning 0.2
This creates an env
ironment variable with identifier load_per_core.warning
that has a value of 0.2
and injects it into the execution environment of the plugin named load_per_core
.
Important: Restart munin-node
for your changes to take effect:
sudo service munin-node restart
Where to Define Environment Variables
Plugin variables are defined in the directory /etc/munin/plagin-conf.d
.
Munin creates a default config file at this location called munin-node
its not recommended to edit this file because munin can overwrite it.
Instead, create a new file for each plugin. Which in your case could be /etc/munin/plugin-conf.d/zz-load_per_core
. There are two things to think about when naming your plugin configuration file:
- The name is arbitrary in that it doesn't have to relate to your plugin name, it can be anything, but...
- Configuration files in this directory are evaluated in alphabetical order and definitions can overwrite each other. So enforce precedence for your configuration file by prefixing the name with zz to ensure it is evaluated after
munin-node
.
How to Access Environment Variables
Configuration environment variables can be accessed by your plugin's code like any other environment variable. The syntax for this depends on the language used by your plugin. for instance if your plugin was written in bash you could write:
#!/usr/bin/bash
#this would access and print the load_per_core.warning environment var
#i.e 0.2
echo $load_per_core.warning
or in Python:
#!/usr/bin/env python
import os
print os.environ.get('load_per_core.warning')
or in Perl, using the standard Munin library:
#!/usr/bin/perl
use Munin::Plugin;
print_thresholds('load_per_core');