pub struct Config {
pub plugin_name: String,
pub plugin_statedir: PathBuf,
pub plugin_cache: PathBuf,
pub dirtyconfig: bool,
pub daemonize: bool,
pub pidfile: PathBuf,
pub config_size: usize,
pub fetch_size: usize,
}Expand description
Plugin configuration.
Fields§
§plugin_name: StringThe name of the plugin.
Default is “Simple munin plugin in Rust”
plugin_statedir: PathBufPlugins state directory
Fallback to /tmp if environment variable MUNIN_PLUGSTATE is not set.
plugin_cache: PathBufCachefile for the plugin
Plugins that daemonize and continuously fetch data need to
write them somewhere, so that the
MuninPlugin::fetch function can
output them. The default is a combination of
Config::plugin_statedir and a random string, with munin and
value added, in std::format! syntax: "{}.munin.{}.value", [Config::plugin_statedir], randomstring.
dirtyconfig: boolDoes munin support dirtyconfig? (Send data after sending config)
Checks MUNIN_CAP_DIRTYCONFIG environment variable, if set to 1, this is true, otherwise false.
daemonize: boolDoes this plugin need to run in background, continuously fetching data?
Default to false
pidfile: PathBufIf plugin uses daemonize, whats the pidfile name?
Defaults to Config::plugin_statedir plus “munin-plugin.pid”, using Config::new will set it to Config::plugin_statedir/Config::plugin_name.pid
config_size: usizeSize of buffer for BufWriter for MuninPlugin::config.
Defaults to 8192, but if the plugin outputs huge munin configuration (trivial with multigraph plugins), you may want to increase this.
fetch_size: usizeSize of buffer for BufWriter for MuninPlugin::fetch.
Defaults to 8192, but if the plugin outputs large datasets, it is useful to increase this.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(plugin_name: String) -> Self
pub fn new(plugin_name: String) -> Self
Create a new Config with defined plugin_name, also setting Config::pidfile and Config::plugin_cache to a sensible value using the Config::plugin_name.
§Examples
let config = Config::new(String::from("great-plugin"));
println!("My pidfile is {:?}", config.pidfile);Sourcepub fn new_daemon(plugin_name: String) -> Self
pub fn new_daemon(plugin_name: String) -> Self
Create a new Config for a streaming (daemonizing) plugin with defined plugin_name, also setting Config::pidfile and Config::plugin_cache to a sensible value using the Config::plugin_name.
§Examples
let config = Config::new_daemon(String::from("great-plugin"));
println!("My pidfile is {:?}", config.pidfile);Trait Implementations§
Source§impl Default for Config
Useful defaults, if possible based on munin environment.
impl Default for Config
Useful defaults, if possible based on munin environment.
Source§fn default() -> Self
fn default() -> Self
Set default values, try to read munin environment variables to fill Config::plugin_statedir and Config::dirtyconfig. Config::plugin_statedir falls back to /tmp if no munin environment variables are present.