#![forbid(unsafe_code)]
#![deny(missing_docs)]
use crate::errors::ExporterError;
use crate::rctlstate::RctlState;
use tracing::debug;
pub fn is_available() -> Result<(), ExporterError> {
debug!("Checking RACCT/RCTL status");
match RctlState::check() {
RctlState::Disabled => {
Err(ExporterError::RctlUnavailable(
"Present, but disabled; enable using \
kern.racct.enable=1 tunable".to_owned()
))
},
RctlState::Enabled => Ok(()),
RctlState::Jailed => {
Err(ExporterError::RctlUnavailable(
"Jail Exporter cannot run within a jail".to_owned()
))
},
RctlState::NotPresent => {
Err(ExporterError::RctlUnavailable(
"Support not present in kernel; see rctl(8) \
for details".to_owned()
))
},
}
}