Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
766 changes: 396 additions & 370 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ homepage = "https://hubblo-org.github.io/scaphandre-documentation"
[dependencies]
loggerv = "0.7.2"
log = "0.4"
clap = "2.33.3"
regex = "1"
clap = { version = "3.2.11", features = ["cargo"] }
regex = "1.4.6"
#procfs = "0.13.2"
procfs = "0.12.0"
riemann_client = { version = "0.9.0", optional = true }
hostname = "0.3.1"
protobuf = "2.20.0"
protobuf = "2.27.1"
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
warp10 = { version = "1.0.0", optional = true }
#time = { version = "0.3.11", features = ["std"] }
#time blocked because used by chrono and warp10
time = "0.2.25"
colored = "2.0.0"
chrono = "0.4.19"
Expand Down
12 changes: 6 additions & 6 deletions src/exporters/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ impl Exporter for JSONExporter {

/// Returns options needed for that exporter, as a HashMap

fn get_options() -> Vec<clap::Arg<'static, 'static>> {
fn get_options() -> Vec<clap::Arg<'static>> {
let mut options = Vec::new();
let arg = Arg::with_name("timeout")
.help("Maximum time spent measuring, in seconds.")
.long("timeout")
.short("t")
.short('t')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -37,7 +37,7 @@ impl Exporter for JSONExporter {
.default_value("2")
.help("Set measurement step duration in second.")
.long("step")
.short("s")
.short('s')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -46,7 +46,7 @@ impl Exporter for JSONExporter {
.default_value("0")
.help("Set measurement step duration in nano second.")
.long("step_nano")
.short("n")
.short('n')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -55,7 +55,7 @@ impl Exporter for JSONExporter {
.default_value("")
.help("Destination file for the report.")
.long("file")
.short("f")
.short('f')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -64,7 +64,7 @@ impl Exporter for JSONExporter {
.default_value("10")
.help("Maximum number of processes to watch.")
.long("max-top-consumers")
.short("m")
.short('m')
.required(false)
.takes_value(true);
options.push(arg);
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub trait Exporter {
/// Entry point for all Exporters
fn run(&mut self, parameters: ArgMatches);
/// Get the options passed via the command line
fn get_options() -> Vec<clap::Arg<'static, 'static>>;
fn get_options() -> Vec<clap::Arg<'static>>;
}

/// MetricGenerator is an exporter helper structure to collect Scaphandre metrics.
Expand Down
10 changes: 5 additions & 5 deletions src/exporters/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ impl Exporter for PrometheusExporter {
);
}
/// Returns options understood by the exporter.
fn get_options() -> Vec<clap::Arg<'static, 'static>> {
fn get_options() -> Vec<clap::Arg<'static>> {
let mut options = Vec::new();
let arg = Arg::with_name("address")
.default_value(DEFAULT_IP_ADDRESS)
.help("ipv6 or ipv4 address to expose the service to")
.long("address")
.short("a")
.short('a')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -73,7 +73,7 @@ impl Exporter for PrometheusExporter {
.default_value("8080")
.help("TCP port number to expose the service")
.long("port")
.short("p")
.short('p')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -82,15 +82,15 @@ impl Exporter for PrometheusExporter {
.default_value("metrics")
.help("url suffix to access metrics")
.long("suffix")
.short("s")
.short('s')
.required(false)
.takes_value(true);
options.push(arg);

let arg = Arg::with_name("qemu")
.help("Apply labels to metrics of processes looking like a Qemu/KVM virtual machine")
.long("qemu")
.short("q")
.short('q')
.required(false)
.takes_value(false);
options.push(arg);
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Exporter for QemuExporter {
}
}

fn get_options() -> Vec<clap::Arg<'static, 'static>> {
fn get_options() -> Vec<clap::Arg<'static>> {
Vec::new()
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/exporters/riemann.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ impl Exporter for RiemannExporter {
}

/// Returns options understood by the exporter.
fn get_options() -> Vec<clap::Arg<'static, 'static>> {
fn get_options() -> Vec<clap::Arg<'static>> {
let mut options = Vec::new();
let arg = Arg::with_name("address")
.default_value(DEFAULT_IP_ADDRESS)
.help("Riemann ipv6 or ipv4 address. If mTLS is used then server fqdn must be provided")
.long("address")
.short("a")
.short('a')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -245,7 +245,7 @@ impl Exporter for RiemannExporter {
.default_value(DEFAULT_PORT)
.help("Riemann TCP port number")
.long("port")
.short("p")
.short('p')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -254,15 +254,15 @@ impl Exporter for RiemannExporter {
.default_value("5")
.help("Duration between metrics dispatch")
.long("dispatch")
.short("d")
.short('d')
.required(false)
.takes_value(true);
options.push(arg);

let arg = Arg::with_name("qemu")
.help("Instruct that scaphandre is running on an hypervisor")
.long("qemu")
.short("q")
.short('q')
.required(false)
.takes_value(false);
options.push(arg);
Expand Down
15 changes: 8 additions & 7 deletions src/exporters/stdout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ impl Exporter for StdoutExporter {
}

/// Returns options needed for that exporter, as a HashMap
fn get_options() -> Vec<clap::Arg<'static, 'static>> {
fn get_options() -> Vec<clap::Arg<'static>> {
let mut options = Vec::new();
let arg = Arg::with_name("timeout")
.default_value("10")
.help("Maximum time spent measuring, in seconds. 0 means continuous measurement.")
.long("timeout")
.short("t")
.short('t')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -35,7 +35,7 @@ impl Exporter for StdoutExporter {
.default_value("2")
.help("Set measurement step duration in second.")
.long("step")
.short("s")
.short('s')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -44,23 +44,23 @@ impl Exporter for StdoutExporter {
.default_value("5")
.help("Number of processes to display.")
.long("process")
.short("p")
.short('p')
.required(false)
.takes_value(true);
options.push(arg);

let arg = Arg::with_name("regex_filter")
.help("Filter processes based on regular expressions (e.g: 'scaph\\w\\wd.e'). This option disable '-p' or '--process' one.")
.long("regex")
.short("r")
.short('r')
.required(false)
.takes_value(true);
options.push(arg);

let arg = Arg::with_name("qemu")
.help("Apply labels to metrics of processes looking like a Qemu/KVM virtual machine")
.long("qemu")
.short("q")
.short('q')
.required(false)
.takes_value(false);
options.push(arg);
Expand Down Expand Up @@ -123,7 +123,8 @@ impl StdoutExporter {
topology,
utils::get_hostname(),
parameters.is_present("qemu"),
parameters.is_present("containers"),
parameters.is_present("containers"), // This broke clap as the parameter is not
// defined
);

println!("Measurement step is: {}s", step_duration);
Expand Down
14 changes: 7 additions & 7 deletions src/exporters/warpten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ impl Exporter for Warp10Exporter {
}

/// Options for configuring the exporter.
fn get_options() -> Vec<clap::Arg<'static, 'static>> {
fn get_options() -> Vec<clap::Arg<'static>> {
let mut options = Vec::new();
let arg = Arg::with_name("host")
.default_value("localhost")
.help("Warp10 host's FQDN or IP address to send data to")
.long("host")
.short("H")
.short('H')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -65,7 +65,7 @@ impl Exporter for Warp10Exporter {
.default_value("http")
.help("Either 'http' or 'https'")
.long("scheme")
.short("s")
.short('s')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -74,15 +74,15 @@ impl Exporter for Warp10Exporter {
.default_value("8080")
.help("TCP port to join Warp10 on the host")
.long("port")
.short("p")
.short('p')
.required(false)
.takes_value(true);
options.push(arg);

let arg = Arg::with_name("write-token")
.help("Auth. token to write on Warp10")
.long("write-token")
.short("t")
.short('t')
.required(false)
.takes_value(true);
options.push(arg);
Expand All @@ -91,15 +91,15 @@ impl Exporter for Warp10Exporter {
.default_value("30")
.help("Time step between measurements, in seconds.")
.long("step")
.short("S")
.short('S')
.required(false)
.takes_value(true);
options.push(arg);

let arg = Arg::with_name("qemu")
.help("Tells scaphandre it is running on a Qemu hypervisor.")
.long("qemu")
.short("q")
.short('q')
.required(false)
.takes_value(false);
options.push(arg);
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn run(matches: ArgMatches) {

/// Returns options needed for each exporter as a HashMap.
/// This function has to be updated to enable a new exporter.
pub fn get_exporters_options() -> HashMap<String, Vec<clap::Arg<'static, 'static>>> {
pub fn get_exporters_options() -> HashMap<String, Vec<clap::Arg<'static>>> {
let mut options = HashMap::new();
options.insert(
String::from("stdout"),
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Generic sensor and transmission agent for energy consumption related metrics.
use clap::{crate_authors, crate_version, App, AppSettings, Arg, SubCommand};
use clap::{crate_authors, crate_version, App, AppSettings, Arg, ArgAction, SubCommand};
use scaphandre::{get_exporters_options, run};
fn main() {
let sensors = ["powercap_rapl"];
Expand All @@ -14,8 +14,8 @@ fn main() {
.setting(AppSettings::SubcommandRequiredElseHelp)
.arg(
Arg::with_name("v")
.short("v")
.multiple(true)
.short('v')
.action(ArgAction::Count)
.help("Sets the level of verbosity.")
)
.arg(
Expand All @@ -33,8 +33,8 @@ fn main() {
.required(false)
.takes_value(true)
.default_value("powercap_rapl")
.possible_values(&sensors)
.short("s")
.possible_values(sensors)
.short('s')
.long("sensor")
).arg(
Arg::with_name("sensor-buffer-per-domain-max-kB")
Expand Down