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§

A plugin’s capabilities. By default a plugin does nothing, but can advertise that it can configure itself and / or report values.

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

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.

Collectd is giving you reported values, do with them as you please. If writing values is expensive, prefer to buffer them in some way and register a flush callback to write.

Flush values to be written that are older than given duration. If an identifier is given, then only those buffered values should be flushed.

Implementors§