Skip to content

Commit

Permalink
Warn on energy reading error
Browse files Browse the repository at this point in the history
  • Loading branch information
krtab committed Nov 30, 2023
1 parent 5525c68 commit be4d936
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs_src/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Troubleshooting

### I get a **permission denied** error when I run scaphandre, no matter what is the exporter
### I get a "Couldn't read energy consumption: Permission denied (os error 13)"

On some Linux distributions (ubuntu 20.04 for sure), the energy counters files that the [PowercapRAPL sensor](references/sensor-powercap_rapl.md) uses, are owned by root. (since late 2020)
Since Linux kernel 5.10 (late 2020), the energy counters files that the [PowercapRAPL sensor](references/sensor-powercap_rapl.md) uses, are owned by root.

To ensure this is your issue and fix that quickly you can run the [init.sh](https://raw.githubusercontent.com/hubblo-org/scaphandre/main/init.sh) script:

Expand Down
22 changes: 18 additions & 4 deletions src/sensors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,14 @@ impl Topology {
}
}

fn warn_error_reading_sensor(err: Box<dyn Error>) {
warn!(
"Couldn't read energy consumption: {err}. \
You may need to check: \
https://hubblo-org.github.io/scaphandre-documentation/troubleshooting.html#i-get-a-couldnt-read-energy-consumption-permission-denied-os-error-13"
)
}

// !!!!!!!!!!!!!!!!! CPUSocket !!!!!!!!!!!!!!!!!!!!!!!
/// CPUSocket struct represents a CPU socket (matches physical_id attribute in /proc/cpuinfo),
/// owning CPU cores (processor in /proc/cpuinfo).
Expand Down Expand Up @@ -703,8 +711,11 @@ impl RecordGenerator for CPUSocket {
/// Returns a clone of this Record instance.
fn refresh_record(&mut self) {
//if let Ok(record) = self.read_record_uj() {
if let Ok(record) = self.read_record() {
self.record_buffer.push(record);
match self.read_record() {
Ok(record) => {
self.record_buffer.push(record);
}
Err(err) => warn_error_reading_sensor(err)
}

if !self.record_buffer.is_empty() {
Expand Down Expand Up @@ -1043,8 +1054,11 @@ impl RecordGenerator for Domain {
/// stores a copy in self.record_buffer and returns it.
fn refresh_record(&mut self) {
//if let Ok(record) = self.read_record_uj() {
if let Ok(record) = self.read_record() {
self.record_buffer.push(record);
match self.read_record() {
Ok(record) => {
self.record_buffer.push(record);
}
Err(err) => warn_error_reading_sensor(err),
}

if !self.record_buffer.is_empty() {
Expand Down

0 comments on commit be4d936

Please sign in to comment.