Struct nagiosplugin::Resource [−][src]
pub struct Resource { /* fields omitted */ }
A Resource basically represents a single service if you view it from the perspective of nagios. If you init it without a state it will determine one from the given metrics.
You can also create a Resource filled with metrics via the resource! macro, which is much like the vec! macro.
let m1 = SimpleMetric::new("test", Some(State::Ok), 12, None, None, None, None); let m2 = SimpleMetric::new("other", None, true, None, None, None, None); let resource = resource![m1, m2]; assert_eq!(&resource.to_nagios_string(), "OK | test=12 other=true")
Methods
impl Resource
[src]
impl Resource
pub fn new(state: Option<State>, description: Option<&str>) -> Resource
[src]
pub fn new(state: Option<State>, description: Option<&str>) -> Resource
If state is set to Some(State) then it will always use this instead of determining it from the given metrics.
If you want to create a Resource from some metrics with automatic determination of the state you can use the resource! macro.
pub fn push<M>(&mut self, metric: M) where
M: 'static + ResourceMetric,
[src]
pub fn push<M>(&mut self, metric: M) where
M: 'static + ResourceMetric,
Pushes a single ResourceMetric into the resource.
pub fn metrics(&self) -> &[Box<ResourceMetric>]
[src]
pub fn metrics(&self) -> &[Box<ResourceMetric>]
Returns a slice of the pushed metrics.
pub fn set_state(&mut self, state: State)
[src]
pub fn set_state(&mut self, state: State)
pub fn to_nagios_string(&self) -> String
[src]
pub fn to_nagios_string(&self) -> String
Returns a string which nagios understands to determine the service state.
This function will automatically determine which service state is appropriate based on the included metrics. If state has been set manually it will always use the manually set state.
pub fn get_state(&self) -> State
[src]
pub fn get_state(&self) -> State
Will determine a State by the given metrics.
pub fn get_description(&self) -> Option<&String>
[src]
pub fn get_description(&self) -> Option<&String>
Get the description of this resource.
pub fn set_description(&mut self, description: &str)
[src]
pub fn set_description(&mut self, description: &str)
Set the description of this resource.
pub fn exit_code(&self) -> i32
[src]
pub fn exit_code(&self) -> i32
Will return the exit code of the determined state via Self::state.
pub fn print_and_exit(&self)
[src]
pub fn print_and_exit(&self)
Will print Self::to_nagios_string and exit with the exit code from Self::exit_code