Trait collectd_plugin::Plugin
source · pub trait Plugin: Send + Sync + UnwindSafe + RefUnwindSafe {
fn capabilities(&self) -> PluginCapabilities { ... }
fn log(&self, _lvl: LogLevel, _msg: &str) -> Result<(), Box<dyn Error>> { ... }
fn read_values(&self) -> Result<(), Box<dyn Error>> { ... }
fn write_values(&self, _list: ValueList<'_>) -> Result<(), Box<dyn Error>> { ... }
fn flush(
&self,
_timeout: Option<Duration>,
_identifier: Option<&str>
) -> Result<(), Box<dyn Error>> { ... }
}
Expand description
An individual plugin that is capable of reporting values to collectd, receiving values from
other plugins, or logging messages. A plugin must implement Sync + Send
as collectd could be sending
values to be written or logged concurrently. The Rust compiler will ensure that everything
not thread safe is wrapped in a Mutex (or another compatible datastructure)
Provided Methods§
sourcefn capabilities(&self) -> PluginCapabilities
fn capabilities(&self) -> PluginCapabilities
A plugin’s capabilities. By default a plugin does nothing, but can advertise that it can configure itself and / or report values.
sourcefn log(&self, _lvl: LogLevel, _msg: &str) -> Result<(), Box<dyn Error>>
fn log(&self, _lvl: LogLevel, _msg: &str) -> Result<(), Box<dyn Error>>
Customizes how a message of a given level is logged. If the message isn’t valid UTF-8, an allocation is done to replace all invalid characters with the UTF-8 replacement character
sourcefn read_values(&self) -> Result<(), Box<dyn Error>>
fn read_values(&self) -> Result<(), Box<dyn Error>>
This function is called when collectd expects the plugin to report values, which will occur
at the Interval
defined in the global config (but can be overridden). Implementations
that expect to report values need to have at least have a capability of READ
. An error in
reporting values will cause collectd to backoff exponentially until a delay of a day is
reached.