hubblo-org / scaphandre

⚡ Energy consumption metrology agent. Let "scaph" dive and bring back the metrics that will help you make your systems and applications more sustainable !
Apache License 2.0
1.56k stars 103 forks source link

v0.5: Using regex filter causes Scaphandre to panic #295

Closed olepbr closed 1 year ago

olepbr commented 1 year ago

Bug description

Attempting to use the stdout exporter's regex filter (-r) causes Scaphandre to panic and exit. Backtrace:

⚘ ~/dev/rust/scaphandre RUST_BACKTRACE=1 ./target/debug/scaphandre stdout -r chromium                                                                                                                          [101]
Scaphandre stdout exporter
Sending ⚡ metrics
Measurement step is: 2s
Host:   0 W
    package     core        dram        uncore
Processes filtered by 'chromium':
Power       PID Exe
No processes found yet or filter returns no value.
------------------------------------------------------------

Host:   2.072913 W
    package     core        dram        uncore
Socket0 2.072913 W |    0.61677 W   0.438338 W  0.007717 W  

Processes filtered by 'chromium':
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PermissionDenied(None)', src/sensors/utils.rs:302:48
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5e1d3299a290026b85787bc9c7e72bcc53ac283f/library/std/src/panicking.rs:577:5
   1: core::panicking::panic_fmt
             at /rustc/5e1d3299a290026b85787bc9c7e72bcc53ac283f/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/5e1d3299a290026b85787bc9c7e72bcc53ac283f/library/core/src/result.rs:1690:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/5e1d3299a290026b85787bc9c7e72bcc53ac283f/library/core/src/result.rs:1092:23
   4: scaphandre::sensors::utils::IProcess::exe
             at ./src/sensors/utils.rs:302:28
   5: scaphandre::sensors::utils::ProcessTracker::get_filtered_processes
             at ./src/sensors/utils.rs:903:39
   6: scaphandre::exporters::stdout::StdoutExporter::show_metrics
             at ./src/exporters/stdout.rs:242:25
   7: scaphandre::exporters::stdout::StdoutExporter::iterate
             at ./src/exporters/stdout.rs:157:9
   8: scaphandre::exporters::stdout::StdoutExporter::runner
             at ./src/exporters/stdout.rs:140:17
   9: <scaphandre::exporters::stdout::StdoutExporter as scaphandre::exporters::Exporter>::run
             at ./src/exporters/stdout.rs:20:9
  10: scaphandre::run
             at ./src/lib.rs:89:9
  11: scaphandre::main
             at ./src/main.rs:89:5
  12: core::ops::function::FnOnce::call_once
             at /rustc/5e1d3299a290026b85787bc9c7e72bcc53ac283f/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

To Reproduce

  1. scaphandre stdout -r foo
  2. Watch it panic.

Expected behavior

Scaphandre should output the list of processes matching the regex, if any.

Environment

Additional context

This is fixed on dev due to the problematic implementation of IProcess.exe(&self) being removed in b18aaee67f4e5124128e84ed63823a62edba5f11. Obviously Scaphandre isn't "stable" software yet, but it would maybe be nice to release a new version which addresses this? (Provided that cutting a new release from dev isn't too much work.)

Cheers!

TheElectronWill commented 1 year ago

Maybe a new label fixed-on-dev could be added for issues like this?

bpetit commented 1 year ago

Hi,

Next release is close. In the mean time, would it be acceptable to use the dev version ?