diff --git a/agent/Cargo.lock b/agent/Cargo.lock index ab45763..de21580 100644 --- a/agent/Cargo.lock +++ b/agent/Cargo.lock @@ -248,7 +248,7 @@ dependencies = [ [[package]] name = "nanometrics-agent" -version = "0.1.12" +version = "0.1.13" dependencies = [ "libc", "rumqttc", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 380590d..4fd6e1a 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nanometrics-agent" -version = "0.1.12" +version = "0.1.13" edition = "2021" [lib] diff --git a/agent/src/metrics/smart.rs b/agent/src/metrics/smart.rs index 6f3e780..e994789 100644 --- a/agent/src/metrics/smart.rs +++ b/agent/src/metrics/smart.rs @@ -12,7 +12,10 @@ struct SmartJson { struct SmartStatus { passed: bool } #[derive(Deserialize)] -struct SmartTemp { current: i64 } +struct SmartTemp { + #[serde(default)] + current: Option, +} #[derive(Deserialize)] struct SmartAttrs { table: Vec } @@ -44,7 +47,7 @@ pub fn is_available() -> bool { pub fn parse_json(json: &str) -> Result { let s: SmartJson = serde_json::from_str(json)?; - let temperature = s.temperature.as_ref().map(|t| t.current) + let temperature = s.temperature.as_ref().and_then(|t| t.current) .or_else(|| s.nvme_smart_health_information_log.as_ref()?.temperature); let mut reallocated = None;