Trait munin_plugin::MuninPlugin
source · [−]pub trait MuninPlugin {
fn config<W: Write>(&self, handle: &mut BufWriter<W>) -> Result<()>;
fn run(&self);
fn daemonize(&self);
fn acquire(&self);
fn fetch(&self);
fn check_autoconf(&self) -> bool { ... }
fn autoconf(&self) { ... }
fn start(&self, config: Config) -> Result<bool> { ... }
}
Expand description
Defines a Munin Plugin and the needed functions
Required Methods
Write out a munin config, read the Developing plugins guide from munin for everything you can print out here.
Note that munin expects this to appear on stdout, so the plugin gives you a handle to write to, which is setup as a std::io::BufWriter to stdout. The std::io::BufWriter capacity defaults to 8192 bytes, but if you need more, its size can be set using Config::cfgsize. An example where this may be useful is a munin multigraph plugin that outputs config for a many graphs.
Example
fn config<W: Write>(&self, handle: &mut BufWriter<W>) -> Result<()> {
writeln!(handle, "graph_title Load average")?;
writeln!(handle, "graph_args --base 1000 -l 0")?;
writeln!(handle, "graph_vlabel load")?;
writeln!(handle, "graph_scale no")?;
writeln!(handle, "graph_category system")?;
writeln!(handle, "load.label load")?;
writeln!(handle, "load.warning 10")?;
writeln!(handle, "load.critical 120")?;
writeln!(handle, "graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run immediately.")?;
writeln!(handle, "load.info Average load for the five minutes.")?;
Ok(())
}
Fetch delivers actual data to munin. This is called whenever the plugin is called without an argument. If the config::Config::dirtyconfig setting is true (auto-detected from environment set by munin), this will also be called right after having called MuninPlugin::config.
For a simple plugin, this may gather data and just print it to stdout in a format that munin accepts. A plugin that daemonizes itself may just write out the cached data here.
Provided Methods
fn check_autoconf(&self) -> bool
fn check_autoconf(&self) -> bool
Check autoconf