[−][src]Struct nagiosplugin::PartialOrdMetric
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]
T: PartialOrd + ToPerfString + Clone,
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]
name: &str,
value: T,
warning: Option<T>,
critical: Option<T>,
min: Option<T>,
max: Option<T>,
lower_is_critical: bool
) -> Self
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]
T: PartialOrd + ToPerfString + Clone,
type Output = T
fn name(&self) -> &str
[src]
fn state(&self) -> Option<State>
[src]
fn value(&self) -> Self::Output
[src]
fn warning(&self) -> Option<Self::Output>
[src]
fn critical(&self) -> Option<Self::Output>
[src]
fn min(&self) -> Option<Self::Output>
[src]
fn max(&self) -> Option<Self::Output>
[src]
fn unit_of_measurement(&self) -> &Unit
[src]
Auto Trait Implementations
impl<T> Send for PartialOrdMetric<T> where
T: Send,
T: Send,
impl<T> Sync for PartialOrdMetric<T> where
T: Sync,
T: Sync,
impl<T> Unpin for PartialOrdMetric<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for PartialOrdMetric<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for PartialOrdMetric<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, O> ResourceMetric for T where
O: ToPerfString,
T: Metric<Output = O> + ToPerfString,
[src]
O: ToPerfString,
T: Metric<Output = O> + ToPerfString,
fn perf_string(&Self) -> String
[src]
fn name(&Self) -> &str
[src]
fn state(&Self) -> Option<State>
[src]
impl<T, O> ToPerfString for T where
O: ToPerfString,
T: Metric<Output = O>,
[src]
O: ToPerfString,
T: Metric<Output = O>,
fn to_perf_string(&Self) -> String
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,