Struct nagiosplugin::PartialOrdMetric [−][src]
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);
Implementations
impl<T> PartialOrdMetric<T> where
T: PartialOrd + ToPerfString + Clone,
[src]
T: PartialOrd + ToPerfString + Clone,
pub fn new(
name: impl Into<String>,
value: T,
warning: Option<T>,
critical: Option<T>,
min: Option<T>,
max: Option<T>,
lower_is_critical: bool
) -> Self
[src]
name: impl Into<String>,
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: Debug> Debug for PartialOrdMetric<T> where
T: PartialOrd + ToPerfString + Clone,
[src]
T: PartialOrd + ToPerfString + Clone,
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> RefUnwindSafe for PartialOrdMetric<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
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,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Checkable for T where
T: ResourceMetric,
[src]
T: ResourceMetric,
pub fn name(&Self) -> &str
[src]
pub fn description(&Self) -> Option<&str>
[src]
pub fn state(&Self) -> Option<State>
[src]
pub fn perf_string(&Self) -> Option<String>
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, O> ResourceMetric for T where
T: Metric<Output = O> + ToPerfString + Debug,
O: ToPerfString,
[src]
T: Metric<Output = O> + ToPerfString + Debug,
O: ToPerfString,
pub fn perf_string(&Self) -> String
[src]
pub fn name(&Self) -> &str
[src]
pub fn state(&Self) -> Option<State>
[src]
impl<T, O> ToPerfString for T where
T: Metric<Output = O>,
O: ToPerfString,
[src]
T: Metric<Output = O>,
O: ToPerfString,
pub fn to_perf_string(&Self) -> String
[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.
pub 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>,