Skip to content

Commit

Permalink
We should also verify the SERIAL NUMBER together with the SLOT index …
Browse files Browse the repository at this point in the history
…when we parse the FAN.



Co-authored-by: Marcelo Araujo <marcelo.araujo@gandi.net>
Tested by: @herver 
Issue: #3
  • Loading branch information
araujobsd and Marcelo Araujo authored Nov 15, 2021
1 parent b547892 commit 7e73a44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/jbod/enclosure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub mod BackPlane {

#[derive(Debug)]
pub struct EnclosureFan {
/// The slot number provided by the JBOD
pub slot: String,
/// The device serial number
pub serial: String,
/// The name of the component provided by the JBOD.
pub description: String,
/// The slot position used by `sg_ses`.
Expand Down Expand Up @@ -99,6 +103,9 @@ pub mod BackPlane {
Cell::new("SLOT")
.with_style(Attr::Bold)
.with_style(Attr::ForegroundColor(color::BLUE)),
Cell::new("IDENT")
.with_style(Attr::Bold)
.with_style(Attr::ForegroundColor(color::BLUE)),
Cell::new("DESCRIPTION")
.with_style(Attr::Bold)
.with_style(Attr::ForegroundColor(color::BLUE)),
Expand Down Expand Up @@ -244,11 +251,13 @@ pub mod BackPlane {
let _index = index_vec[0];
if !_description.is_empty() && !_index.is_empty() {
let is_present =
enclosure_fan.iter().any(|c| c.index == _index.to_string());
enclosure_fan.iter().any(|c| c.index == _index.to_string() && c.serial == enclosure.serial);
if is_present == false {
let (speed, comment): (i64, String) =
get_enclosure_fan_speed(&enclosure.device_path, &_index);
enclosure_fan.push(EnclosureFan {
slot: enclosure.slot.clone(),
serial: enclosure.serial.clone(),
description: _description.to_string(),
index: _index.to_string(),
speed: speed,
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ fn enclosure_overview(option: &ArgMatches) -> Result<(), ()> {
let mut fan_table = BackPlane::create_fan_table();
for fan in enclosure_fan {
fan_table.add_row(Row::new(vec![
Cell::new(&fan.slot),
Cell::new(&fan.index),
Cell::new(&fan.description),
Cell::new(&fan.comment),
Expand Down

0 comments on commit 7e73a44

Please sign in to comment.