Skip to main content

SmartLog

Struct SmartLog 

Source
pub struct SmartLog { /* private fields */ }
Expand description

Decoded SMART / Health Information log page (LID 02h).

Counters that the spec defines as 128-bit are exposed as u128. Times are reported in minutes (per the NVMe spec).

Implementations§

Source§

impl SmartLog

Source

pub fn critical_warning(&self) -> u8

Critical warning bitfield: spare, temperature, degraded reliability, media read-only, volatile memory backup failure, persistent memory read-only. See NVME_SMART_CRIT_* constants in libnvme-sys.

Examples found in repository?
examples/smart_log.rs (line 44)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn temperature_kelvin(&self) -> u16

Composite temperature in Kelvin.

Examples found in repository?
examples/smart_log.rs (line 27)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn temperature_celsius(&self) -> i16

Composite temperature in Celsius.

Examples found in repository?
examples/smart_log.rs (line 28)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn available_spare(&self) -> u8

Available spare capacity as a percentage of normalized spare.

Examples found in repository?
examples/smart_log.rs (line 32)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn available_spare_threshold(&self) -> u8

Threshold below which critical_warning flags the spare condition.

Examples found in repository?
examples/smart_log.rs (line 33)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn percentage_used(&self) -> u8

Vendor-specific estimate of life used, as a percentage. May exceed 100.

Examples found in repository?
examples/smart_log.rs (line 35)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn endurance_group_critical_warning(&self) -> u8

Endurance group critical warning summary.

Source

pub fn data_units_read(&self) -> u128

Number of 512-byte data units the host has read from the controller, in thousands. Multiply by 1000 and by 512 for total bytes read.

Examples found in repository?
examples/smart_log.rs (line 36)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn data_units_written(&self) -> u128

Number of 512-byte data units the host has written to the controller, in thousands. See data_units_read.

Examples found in repository?
examples/smart_log.rs (line 37)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn host_read_commands(&self) -> u128

Number of read commands completed by the controller.

Examples found in repository?
examples/smart_log.rs (line 38)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn host_write_commands(&self) -> u128

Number of write commands completed by the controller.

Examples found in repository?
examples/smart_log.rs (line 39)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn controller_busy_time_minutes(&self) -> u128

Time the controller has been busy with I/O commands, in minutes.

Source

pub fn power_cycles(&self) -> u128

Number of power-on/off cycles experienced by the controller.

Examples found in repository?
examples/smart_log.rs (line 40)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn power_on_hours(&self) -> u128

Cumulative power-on time in hours.

Examples found in repository?
examples/smart_log.rs (line 41)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn unsafe_shutdowns(&self) -> u128

Number of unsafe shutdowns (loss of power without a normal shutdown).

Examples found in repository?
examples/smart_log.rs (line 42)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn media_errors(&self) -> u128

Number of media or data integrity errors detected.

Examples found in repository?
examples/smart_log.rs (line 43)
22fn print_smart(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let log = ctrl.smart_log()?;
25    println!(
26        "  temperature        : {} K ({} C)",
27        log.temperature_kelvin(),
28        log.temperature_celsius()
29    );
30    println!(
31        "  available spare    : {}% (threshold {}%)",
32        log.available_spare(),
33        log.available_spare_threshold()
34    );
35    println!("  percentage used    : {}%", log.percentage_used());
36    println!("  data units read    : {}", log.data_units_read());
37    println!("  data units written : {}", log.data_units_written());
38    println!("  host read cmds     : {}", log.host_read_commands());
39    println!("  host write cmds    : {}", log.host_write_commands());
40    println!("  power cycles       : {}", log.power_cycles());
41    println!("  power on hours     : {}", log.power_on_hours());
42    println!("  unsafe shutdowns   : {}", log.unsafe_shutdowns());
43    println!("  media errors       : {}", log.media_errors());
44    println!("  critical warning   : 0x{:02x}", log.critical_warning());
45    println!();
46    Ok(())
47}
Source

pub fn num_error_log_entries(&self) -> u128

Number of entries in the Error Information Log.

Source

pub fn warning_temp_time_minutes(&self) -> u32

Time the composite temperature has exceeded the warning threshold, in minutes.

Source

pub fn critical_temp_time_minutes(&self) -> u32

Time the composite temperature has exceeded the critical threshold, in minutes.

Source

pub fn temperature_sensor_kelvin(&self, index: u8) -> Option<u16>

Temperature sensor reading in Kelvin (index is 1..=8). Returns None for out-of-range indices or unreported sensors (0).

Trait Implementations§

Source§

impl Debug for SmartLog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.