feat(agent): measure the server each minute - #33
Merged
Merged
Conversation
nabil1440
added this pull request to stack #38
September 22, 2026 10:40
- Measure CPU, load, memory, swap, disk and network from /proc and
statfs("/"). Used memory is MemTotal - MemAvailable; used disk is
(blocks - free blocks), as the contract defines them.
- Count only the network interfaces that have a hardware device, so that
container traffic through veth, the bridges and docker0 is not counted two
or three times. Without such an interface, count the default route.
- Save the last counters with the boot id. After an agent restart the next
sample continues from them. After a reboot, a counter that went back or a
reading older than 90 seconds, send 0 with net_counters_reset.
- Send the status in each report: reboot required, the update counts from
apt-check (each hour; 0 and a warning when it fails), the OS name, the
kernel, the uptime and the arch.
- A measurement that fails skips that minute. The agent continues.
Refs #28
…4.04 Fixes from the adversarial review of this layer. - apt-check can write warnings before its result, for example for a source that is configured two times. Read only the last line. Before, both counts became 0, and a server with security updates looked up to date. - A failed count keeps the last counts. The counts are 0 only when apt-check never gave a result. - Count the updates with the sample of the minute, before the sends of a report, so a slow apt-check cannot use the time of the sends. - When no interface is counted, mark the traffic as not known (net_counters_reset), not as 0, and log it one time. - The default route must have mask 0, so a VPN route 0.0.0.0/1 is not taken. - Leave out an interface that is a port of an other interface (a bond or a bridge port, or the Azure VF under netvsc): its traffic is also in the interface above it. Refs #28
nabil1440
force-pushed
the
agent/28-metrics
branch
from
September 24, 2026 08:09
d4b0527 to
fed7577
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Layer 3 of 7 of the monitoring agent (#31 → #37).
Summary
Change
internal/metrics:/proc/stat,/proc/loadavg,/proc/meminfo,statfs("/")and/proc/net/dev, as the contract section "What 'used' means" defines them.net_counters_reset: true.Adversarial review
The first version was refuted. These items are fixed in this PR:
apt-checkcan write warnings before its result, and both counts became 0. Only the last line counts now.net_counters_reset), not 0.0.0.0.0/1is not taken.Tests
/proc(Linux CI), the interface rules, the reset rules andapt-checkoutput with warnings.dfandfree.Closes #28