Perfdata (Performance Data)

This library was created to fit basic needs for parsing and creating Performance Data commonly used by check commands from monitoring engines like Icinga2 or Nagios.

I'm using this in close-to-production software, but would generally consider this library still in a pre-stable stage, since it's still evolving.

Usage

Usually you will want to create performance data in check commands called by monitoring engines, after executing the command from the data collected. ```rust // simple label with a value let perfdata = Perfdata::unit("label", 23);

// with warn, crit, min and max thresholds let withthresholds = Perfdata::unit("thresholds", 42) .withwarn(ThresholdRange::inside(33,50)) .withcrit(ThresholdRange::above(50)) .withmin(0) .with_max(100);

// check thresholds if withthresholds.iswarn() { println("{} in warning threshold", withthreshold.label()) } if withthresholds.iscrit() { println("{} in critical threshold", withthreshold.label()) }

```

Perfdata can be created with several units of measurements. And will be formatted to the spec of the Nagios Plugin Development Guidelines. ```rust // This will be formatted as 'seconds'=10s Perfdata::seconds("seconds", 10);

// This will be formatted as 'percent'=50% Perfdata::percent("seconds", 50);

// This will be formatted as 'bytes'=23b Perfdata::bytes("bytes", 23);

// This will be formatted as 'counter'=10c;@20:30;30;0;100 Perfdata::percent("counter", 10) .withwarn(ThresholdRange::inside(20,30)) .withcrit(ThresholdRange::abovepos(30)) .withmin(0) .with_max(100); ```

This library provides also a basic parser, for dealing with perfdata generated by one of the myriad of check commands for common monitoring engines. rust let input = "'some perfdata'=42;@75:80;80"; let perfdata = Perfdata::try_from(input).unwrap();

Usually more than one Performance Datapoint are generated in a space delimited list. These can be parsed using the Perfdata::parse_from_list() helper method into a Vec<Result<Perfdata,PerfdataParseError>>. rust let input = "'some perfdata'=42;66;75;0;100; 'foo'=23 bar=10" let perfdata = Perfdata::parse_from_list(input);

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.