diff --git a/README.md b/README.md index 8e88c0e..9dd59e7 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,9 @@ It simply reads from `/proc/net/dev` to obtain byte-counts of the specified network interface and writes to four files, two of which keep track of the total byte count for sending and receiving, and the other two contain the "diffs" for each (configurable) interval (by default 5 seconds). -rust_network_status_rate 0.1.0 + rust_network_status_rate 0.1.0 + USAGE: rust_network_status_rate [FLAGS] [OPTIONS] @@ -21,6 +22,8 @@ rust_network_status_rate 0.1.0 OPTIONS: -p, --prefix Prefix to use instead of XDG_RUNTIME_DIR if enabled [default: /tmp] + -v, --interval-seconds Interval in seconds between checking network rate [default: 5] + -i, --pid-filename Filename to write pid to [default: rust_network_rate_pid] -r, --recv-interval Filename of interval bytes recieved (in prefix dir) [default: rust_recv_interval] @@ -35,4 +38,4 @@ rust_network_status_rate 0.1.0 ARGS: - + diff --git a/src/main.rs b/src/main.rs index 1f2689d..f7bcec7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,8 +7,6 @@ use std::thread::sleep; use std::time::{Duration, Instant}; use structopt::StructOpt; -const INTERVAL_SECONDS: u64 = 5; - const ALTERNATE_PREFIX_DIR: &str = "/tmp"; const DEFAULT_SEND_TOTAL_FILENAME: &str = "rust_send_total"; @@ -76,6 +74,14 @@ struct Opt { default_value = DEFAULT_PID_FILENAME )] pid_filename: String, + + #[structopt( + short = "v", + long = "interval-seconds", + help = "Interval in seconds between checking network rate", + default_value = "5" + )] + interval_seconds: u64, } #[derive(Copy, Clone, Debug)] @@ -357,7 +363,7 @@ fn main() -> Result<(), String> { &recv_total_path, ) }, - INTERVAL_SECONDS, + opt.interval_seconds, )?; Ok(())