diff --git a/gping/src/main.rs b/gping/src/main.rs index b9b053bd..2e16fc6c 100644 --- a/gping/src/main.rs +++ b/gping/src/main.rs @@ -53,6 +53,12 @@ build_env: {},{}"#, build::RUST_CHANNEL ); +#[cfg(target_os = "openbsd")] +const DEFAULT_PING_INTERVAL_SECONDS: f32 = 1.0; +#[cfg(not(target_os = "openbsd"))] +const DEFAULT_PING_INTERVAL_SECONDS: f32 = 0.2; +const DEFAULT_CMD_INTERVAL_SECONDS: f32 = 0.5; + #[derive(Parser, Debug)] #[command(author, version=build::PKG_VERSION, name = "gping", about = "Ping, but with a graph.", long_version = VERSION_INFO, styles = clap_cargo::style::CLAP_STYLING )] @@ -61,7 +67,7 @@ struct Args { #[arg(long)] cmd: bool, - /// Watch interval seconds (provide partial seconds like '0.5'). Default for ping is 0.2, default for cmd is 0.5. + /// Watch interval seconds (provide partial seconds like '0.5'). Default for ping is 0.2 (1.0 on OpenBSD), default for cmd is 0.5. #[arg(short = 'n', long)] watch_interval: Option, @@ -270,7 +276,9 @@ fn start_cmd_thread( .to_string(); let cmd_args = words.map(|w| w.to_string()).collect::>(); - let interval = Duration::from_millis((watch_interval.unwrap_or(0.5) * 1000.0) as u64); + let interval = Duration::from_millis( + (watch_interval.unwrap_or(DEFAULT_CMD_INTERVAL_SECONDS) * 1000.0) as u64, + ); // Pump cmd watches into the queue thread::spawn(move || -> Result<()> { @@ -430,8 +438,9 @@ fn main() -> Result<()> { ); threads.push(cmd_thread); } else { - let interval = - Duration::from_millis((args.watch_interval.unwrap_or(0.2) * 1000.0) as u64); + let interval = Duration::from_millis( + (args.watch_interval.unwrap_or(DEFAULT_PING_INTERVAL_SECONDS) * 1000.0) as u64, + ); let mut ping_opts = if args.ipv4 { PingOptions::new_ipv4(host_or_cmd, interval, interface.clone())