Skip to content

feat(agent): read the server each 10 seconds and send the peaks of the minute - #46

Merged
nabil1440 merged 5 commits into
agent/39-auto-updatefrom
agent/41-peaks
Sep 28, 2026
Merged

nabil1440 merged 5 commits into
agent/39-auto-updatefrom
agent/41-peaks

Conversation

@nabil1440

@nabil1440 nabil1440 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #41.

Part of the monitoring agent stack. This PR is on top of #40. Contract v0.4.0, "The readings" and "The peaks".

What changes

  • Readings each 10 seconds. The agent loop now also wakes at the offset second plus 10, 20, 30, 40 and 50 seconds. At these times it takes a reading. It still sends one sample for each minute.
  • Windows. The sample of the tick at T uses the windows from one reading to the next, from the tick before to T. If a reading fails, the two windows on each side of it join into one. A reading less than 5 seconds from its neighbours is left out, so that no window is some milliseconds long.
  • New optional sample fields: cpu_max_percent, memory_used_max_bytes, swap_used_max_bytes, net_in_max_bytes_per_second and net_out_max_bytes_per_second. A value that is not known is null.
  • Guarantees. cpu_percent ≤ cpu_max_percent, memory_used_bytes ≤ memory_used_max_bytes ≤ memory_total_bytes, the same for swap, and net_in_bytes ≤ 60 × net_in_max_bytes_per_second up to rounding.
  • Network peaks are null when net_counters_reset is true, or when a counter of a window went back.
  • Real reading times. Each reading carries the time at which it ran, with the monotonic clock. A late timer or a step of the wall clock does not change the length of a window. recorded_at stays the time of the tick.
  • A slow reading does not skip the tick after it.
  • apt-check runs after the reading of the tick, so that it does not move the reading.
  • The fields of contract v0.3.1 do not change. The alerts read them as before.
  • A short first minute has no sample. After a fresh start (no recent saved counters), when the first tick comes less than 10 seconds after the start, the agent sends no sample for that minute, and logs it at Info. The tick reading starts the next minute, which has all its values. Before, the first sample after an install could show 100% CPU from the load of the install.

Before release

  • A control plane that implements contract v0.3.1 must accept a sample with the new fields: the contract says that it ignores a field that it does not know. Checked: the request data class of the control plane accepts a report with all the fields of v0.4.0 and v0.5.0.

Tests

  • Loop (fake clock): the readings at the correct seconds, no reading at a tick, and a reading of 10 seconds does not skip the tick.
  • Collector: the peaks of each field, a failed reading, the first sample after a start, a restart with a saved reading, a counter that went back, readings that are not newer, the limit of 30 readings, and a failed tick (the peaks come from the last minute only).
  • A sample queued by an older agent sends the peaks as null.
  • make check passes.

@nabil1440
nabil1440 added this pull request to stack #38 September 24, 2026 06:06
@nabil1440 nabil1440 changed the title agent/41 peaks feat(agent): read the server each 10 seconds and send the peaks of the minute Sep 24, 2026
@nabil1440
nabil1440 marked this pull request as ready for review September 24, 2026 06:07
…e minute

Contract v0.4.0, "The readings" and "The peaks": cpu_max_percent,
memory_used_max_bytes, swap_used_max_bytes and the two network peaks.
The fields of v0.3.1 do not change. apt-check now runs after the reading
of the tick, so that it does not move the reading.

Closes #41
…by the real reading times

- A reading that ends at or after the next tick no longer skips it.
- Each reading, and the tick reading, carries the time at which it ran
  (with the monotonic clock), so a late timer or a step of the wall clock
  does not change the length of a window. recorded_at stays the tick.
- cpu_max_percent leaves out the windows of an older minute whose tick
  failed, as the memory peaks do.
After a fresh start (no saved counters), the first tick can come some
milliseconds after the start reading: its CPU value is the load of the
start, for example 100% during an install. That minute now has no
sample, and the tick reading starts the next minute, which then has all
its values. The agent logs it at Info, not as a warning.
@nabil1440
nabil1440 merged commit 6a8ff9a into develop Sep 28, 2026
1 check passed
@nabil1440
nabil1440 deleted the agent/41-peaks branch September 28, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Send the peaks within each minute

1 participant