tape: add estimated medium wearout to status
This commit is contained in:
parent
8e6459a818
commit
337ff5a3cc
@ -204,4 +204,7 @@ pub struct LinuxDriveAndMediaStatus {
|
||||
/// the head.
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub medium_passes: Option<u64>,
|
||||
/// Estimated tape wearout factor (assuming max. 16000 end-to-end passes)
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub medium_wearout: Option<f64>,
|
||||
}
|
||||
|
@ -696,6 +696,13 @@ fn status(
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let render_percentage = |value: &Value, _record: &Value| {
|
||||
match value.as_f64() {
|
||||
Some(wearout) => Ok(format!("{:.2}%", wearout*100.0)),
|
||||
None => Ok(String::from("ERROR")), // should never happen
|
||||
}
|
||||
};
|
||||
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("blocksize"))
|
||||
.column(ColumnConfig::new("density"))
|
||||
@ -707,6 +714,7 @@ fn status(
|
||||
.column(ColumnConfig::new("bytes-written").renderer(render_bytes_human_readable))
|
||||
.column(ColumnConfig::new("bytes-read").renderer(render_bytes_human_readable))
|
||||
.column(ColumnConfig::new("medium-passes"))
|
||||
.column(ColumnConfig::new("medium-wearout").renderer(render_percentage))
|
||||
.column(ColumnConfig::new("volume-mounts"))
|
||||
;
|
||||
|
||||
|
@ -261,6 +261,7 @@ impl LinuxTapeHandle {
|
||||
bytes_read: None,
|
||||
bytes_written: None,
|
||||
medium_passes: None,
|
||||
medium_wearout: None,
|
||||
volume_mounts: None,
|
||||
};
|
||||
|
||||
@ -276,10 +277,17 @@ impl LinuxTapeHandle {
|
||||
|
||||
if let Ok(volume_stats) = self.volume_statistics() {
|
||||
|
||||
status.medium_passes = Some(std::cmp::max(
|
||||
let passes = std::cmp::max(
|
||||
volume_stats.beginning_of_medium_passes,
|
||||
volume_stats.middle_of_tape_passes,
|
||||
));
|
||||
);
|
||||
|
||||
// assume max. 16000 medium passes
|
||||
// see: https://en.wikipedia.org/wiki/Linear_Tape-Open
|
||||
let wearout: f64 = (passes as f64)/(16000.0 as f64);
|
||||
|
||||
status.medium_passes = Some(passes);
|
||||
status.medium_wearout = Some(wearout);
|
||||
|
||||
status.volume_mounts = Some(volume_stats.volume_mounts);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user