Skip to content

Commit

Permalink
Remove mentions of Nagios.
Browse files Browse the repository at this point in the history
  • Loading branch information
johanthoren committed Jul 12, 2024
1 parent 9510588 commit e696b13
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "check-macos-updates"
version = "0.3.2"
edition = "2021"
authors = ["Johan Thorén <[email protected]>"]
description = "A Nagios compatible plugin to check if macOS system updates are available."
description = "A monitoring plugin to check if macOS system updates are available."
readme = "README.md"
license = "ISC"
repository = "https://github.com/johanthoren/check_macos_updates"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

``` sh
$ check_macos_updates -h
A Nagios compatible plugin that checks for available MacOS updates.
A monitoring plugin that checks for available MacOS updates.

Thresholds are defined using Nagios range syntax. Examples:
Thresholds are defined using monitoring plugin range syntax. Examples:
+------------------+-------------------------------------------------+
| Range definition | Generate an alert if x... |
+------------------+-------------------------------------------------+
Expand Down
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use nagios_range::NagiosRange;
use nagios_range::Error as RangeError;
use nagios_range::NagiosRange as ThresholdRange;
use serde::Deserialize;
use std::fmt;
use std::process::{self, Output};
Expand All @@ -7,16 +8,16 @@ pub const PLIST_FILE: &str = "/Library/Preferences/com.apple.SoftwareUpdate.plis

#[derive(Clone, Debug, PartialEq)]
pub struct Thresholds {
pub warning: Option<NagiosRange>,
pub critical: Option<NagiosRange>,
pub warning: Option<ThresholdRange>,
pub critical: Option<ThresholdRange>,
}

#[non_exhaustive]
#[derive(Debug, PartialEq)]
pub enum UnkownVariant {
NotMacOS,
NoThresholds,
RangeParseError(String, nagios_range::Error),
RangeParseError(String, RangeError),
UnableToDetermineUpdates,
UnableToParsePlist,
}
Expand Down
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use check_macos_updates::*;
use clap::Parser;
use nagios_range::NagiosRange;
use nagios_range::NagiosRange as ThresholdRange;
use plist::from_file;
use std::process;

const ABOUT_TEXT: &str = r#"
A Nagios compatible plugin that checks for available MacOS updates.
A monitoring plugin that checks for available MacOS updates.
Thresholds are defined using Nagios range syntax. Examples:
Thresholds are defined using monitoring plugin range syntax. Examples:
+------------------+-------------------------------------------------+
| Range definition | Generate an alert if x... |
+------------------+-------------------------------------------------+
Expand Down Expand Up @@ -56,20 +56,20 @@ fn main() {
exit_with_message(Status::Unknown(UnkownVariant::NoThresholds))
}

let mut warning: Option<NagiosRange> = None;
let mut warning: Option<ThresholdRange> = None;

if let Some(w) = args.warning {
let w_range = NagiosRange::from(&w);
let w_range = ThresholdRange::from(&w);
match w_range {
Ok(r) => warning = Some(r),
Err(e) => exit_with_message(Status::Unknown(UnkownVariant::RangeParseError(w, e))),
}
}

let mut critical: Option<NagiosRange> = None;
let mut critical: Option<ThresholdRange> = None;

if let Some(c) = args.critical {
let c_range = NagiosRange::from(&c);
let c_range = ThresholdRange::from(&c);
match c_range {
Ok(r) => critical = Some(r),
Err(e) => exit_with_message(Status::Unknown(UnkownVariant::RangeParseError(c, e))),
Expand Down
22 changes: 11 additions & 11 deletions tests/check_macos_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod plist_examples;
mod tests {
use crate::plist_examples::plists::{NO_UPDATES, ONE_UPDATE, ONE_UPDATE_NO_AUTO_CHECK};
use check_macos_updates::*;
use nagios_range::NagiosRange;
use nagios_range::NagiosRange as ThresholdRange;
use pretty_assertions::assert_eq;
use std::os::unix::process::ExitStatusExt;
use std::process::Output;
Expand Down Expand Up @@ -35,8 +35,8 @@ mod tests {
let result = Ok(output);

let thresholds = Thresholds {
warning: Some(NagiosRange::from("1").unwrap()),
critical: Some(NagiosRange::from("2").unwrap()),
warning: Some(ThresholdRange::from("1").unwrap()),
critical: Some(ThresholdRange::from("2").unwrap()),
};

let status = check_softwareupdate_output(&result, &thresholds);
Expand Down Expand Up @@ -70,8 +70,8 @@ Software Update found the following new or updated software:
let result = Ok(output);

let thresholds = Thresholds {
warning: Some(NagiosRange::from("1").unwrap()),
critical: Some(NagiosRange::from("2").unwrap()),
warning: Some(ThresholdRange::from("1").unwrap()),
critical: Some(ThresholdRange::from("2").unwrap()),
};

let status = check_softwareupdate_output(&result, &thresholds);
Expand All @@ -89,8 +89,8 @@ Software Update found the following new or updated software:
println!("{:?}", software_update_plist);

let thresholds = Thresholds {
warning: Some(NagiosRange::from("1").unwrap()),
critical: Some(NagiosRange::from("2").unwrap()),
warning: Some(ThresholdRange::from("1").unwrap()),
critical: Some(ThresholdRange::from("2").unwrap()),
};

assert_eq!(software_update_plist.last_updates_available, 0);
Expand All @@ -115,8 +115,8 @@ Software Update found the following new or updated software:
println!("{:?}", software_update_plist);

let thresholds = Thresholds {
warning: Some(NagiosRange::from("0").unwrap()),
critical: Some(NagiosRange::from("3").unwrap()),
warning: Some(ThresholdRange::from("0").unwrap()),
critical: Some(ThresholdRange::from("3").unwrap()),
};

assert_eq!(software_update_plist.last_updates_available, 1);
Expand All @@ -141,8 +141,8 @@ Software Update found the following new or updated software:
println!("{:?}", software_update_plist);

let thresholds = Thresholds {
warning: Some(NagiosRange::from("0").unwrap()),
critical: Some(NagiosRange::from("3").unwrap()),
warning: Some(ThresholdRange::from("0").unwrap()),
critical: Some(ThresholdRange::from("3").unwrap()),
};

assert_eq!(software_update_plist.last_updates_available, 1);
Expand Down

0 comments on commit e696b13

Please sign in to comment.