Collectd gathers system and application metrics and stores the values in any manner. Since Collectd provides a plugin API, I created a repo that demonstrates how to create a Collectd plugin written in Rust that uses bindgen to generate the ffi functions. I’ve successfully used it as base for an internal Collectd plugin.
I recently migrated to use failure crate, so if anyone needed an example of usage (or correct my usage!).
There are four main ways to extend collectd:
- Write plugin against the C api:
- Write plugin for collectd-python
- Write plugin for collectd-java
- Write a cli for the exec plugin
And my thoughts:
- I’m not confident enough to write C without leaks and there isn’t a great package manager for C.
- Python and Java aren’t self contained, aren’t necessarily deployed on the server, are more heavy weight, and I suspect that maintenance plays second fiddle to the C api.
- The exec plugin is costly as it creates a new process for every collection
Rust’s combination of ecosystem, package manager, C ffi, single file, and optimized library made it seem like a natural choice.