[][src]Struct nagiosplugin::PartialOrdMetric

pub struct PartialOrdMetric<T> where
    T: PartialOrd + ToPerfString + Clone
{ /* fields omitted */ }

A PartialOrdMetric is a metric which will automatically calculate the State based on the given value and warning and/or critical value.

It doesn't matter if you provide warning or critical or both of none of these. Even though you should choose SimpleMetric if you aren't providing any warning or critical value.

The state function of the implemented Metric trait will always be one of: Ok, Warning, Critical

let metric = PartialOrdMetric::new("test", 15, Some(15), Some(30), None, None, false);
assert_eq!(metric.state(), Some(State::Warning));
assert_eq!(metric.value(), 15);

Methods

impl<T> PartialOrdMetric<T> where
    T: PartialOrd + ToPerfString + Clone
[src]

pub fn new(
    name: &str,
    value: T,
    warning: Option<T>,
    critical: Option<T>,
    min: Option<T>,
    max: Option<T>,
    lower_is_critical: bool
) -> Self
[src]

Creates a new PartialOrdMetric from the given values.

In debug builds this will panic if you pass incorrect values for warning and critical.

pub fn set_unit_of_measurement(&mut self, unit_of_measurement: Unit)[src]

Trait Implementations

impl<T> Metric for PartialOrdMetric<T> where
    T: PartialOrd + ToPerfString + Clone
[src]

type Output = T

Auto Trait Implementations

impl<T> Send for PartialOrdMetric<T> where
    T: Send

impl<T> Unpin for PartialOrdMetric<T> where
    T: Unpin

impl<T> Sync for PartialOrdMetric<T> where
    T: Sync

impl<T> UnwindSafe for PartialOrdMetric<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for PartialOrdMetric<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T, O> ResourceMetric for T where
    O: ToPerfString,
    T: Metric<Output = O> + ToPerfString
[src]

impl<T, O> ToPerfString for T where
    O: ToPerfString,
    T: Metric<Output = O>, 
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]