Show available RAM and measured CPU usage for devices
Rust development slice / linux (push) Failing after 8s
Rust development slice / linux (push) Failing after 8s
This commit is contained in:
@@ -649,6 +649,7 @@ impl<C: reconcile::SyncClock> Agent<C> {
|
||||
let mut inventory_at = Instant::now();
|
||||
let mut update_at = Instant::now();
|
||||
let mut heartbeat_at = Instant::now();
|
||||
let mut previous_cpu = None;
|
||||
let mut heartbeat_after = Duration::from_millis(rand::random_range(27_000..33_000));
|
||||
let mut tick = tokio::time::interval(Duration::from_secs(5));
|
||||
let mut sync_at = Instant::now();
|
||||
@@ -809,11 +810,21 @@ impl<C: reconcile::SyncClock> Agent<C> {
|
||||
}
|
||||
if first_heartbeat || heartbeat_at.elapsed() >= heartbeat_after {
|
||||
first_heartbeat = false;
|
||||
let cpu = rmm_agent_linux::inventory::cpu_times();
|
||||
let cpu_usage_basis_points = cpu.zip(previous_cpu)
|
||||
.and_then(|(current, previous)| current.usage_since(previous));
|
||||
previous_cpu = cpu;
|
||||
let memory = rmm_agent_linux::inventory::memory().data;
|
||||
let heartbeat = self.envelope(
|
||||
generation,
|
||||
Payload::Heartbeat(Heartbeat {
|
||||
instance_id: self.instance.clone(),
|
||||
uptime_seconds: self.started.elapsed().as_secs(),
|
||||
system_usage: Some(SystemUsage {
|
||||
cpu_usage_basis_points,
|
||||
ram_available_bytes: memory.as_ref().and_then(|m| m.available_bytes),
|
||||
ram_total_bytes: memory.map(|m| m.total_bytes),
|
||||
}),
|
||||
}),
|
||||
)?;
|
||||
ws.send(&heartbeat).await?;
|
||||
@@ -823,6 +834,7 @@ impl<C: reconcile::SyncClock> Agent<C> {
|
||||
Payload::Heartbeat(Heartbeat {
|
||||
instance_id: self.instance.clone(),
|
||||
uptime_seconds: self.started.elapsed().as_secs(),
|
||||
system_usage: None,
|
||||
}),
|
||||
)?;
|
||||
ws.poll(poll).await?;
|
||||
|
||||
Reference in New Issue
Block a user