Keep the last valid CPU reading during RAM-only heartbeats
Rust development slice / linux (push) Failing after 8s
Rust development slice / linux (push) Failing after 8s
This commit is contained in:
@@ -358,6 +358,8 @@ fn project(row: &PgRow, now: DateTime<Utc>, full: bool) -> Value {
|
||||
.unwrap_or(Value::Null);
|
||||
let usage_at: Option<DateTime<Utc>> = row.get("system_usage_observed_at");
|
||||
let inventory_at: Option<DateTime<Utc>> = row.get("observed_at");
|
||||
let cpu_observed_at = usage["cpu_usage_observed_at"].as_str();
|
||||
let cpu_usage = cpu_observed_at.and_then(|_| usage["cpu_usage_percent"].as_f64());
|
||||
let ram_available = usage["ram_available_bytes"].as_u64();
|
||||
let ram_total = usage["ram_total_bytes"]
|
||||
.as_u64()
|
||||
@@ -383,8 +385,8 @@ fn project(row: &PgRow, now: DateTime<Utc>, full: bool) -> Value {
|
||||
"disk_free_bytes":data["root_available_bytes"].as_u64(),"disk_total_bytes":data["root_total_bytes"].as_u64(),
|
||||
"cpu_model":cpu["model"].as_str().or_else(||windows["cpu_model"].as_str()),
|
||||
"cpu_logical_count":cpu["logical_processors"].as_u64().or_else(||windows["logical_processors_visible"].as_u64()),
|
||||
"cpu_usage_percent":usage["cpu_usage_percent"],
|
||||
"cpu_usage_observed_at":usage["cpu_usage_percent"].is_number().then_some(usage_at).flatten(),
|
||||
"cpu_usage_percent":cpu_usage,
|
||||
"cpu_usage_observed_at":cpu_observed_at,
|
||||
"ram_total_bytes":ram_total,
|
||||
"ram_available_bytes":ram_available.or_else(|| linux_memory["available_bytes"].as_u64().or_else(||windows["memory_available_bytes"].as_u64())
|
||||
.filter(|available| ram_total.is_some_and(|total| *available <= total))),
|
||||
|
||||
Reference in New Issue
Block a user