feat(agent): send the CPU, memory and disk use of each site, and conform to contract v0.5.0 - #50
Merged
Merged
Conversation
nabil1440
added this pull request to stack #38
September 24, 2026 06:06
nabil1440
marked this pull request as ready for review
September 24, 2026 06:07
nabil1440
force-pushed
the
agent/45-sites
branch
from
September 24, 2026 08:09
b0bd255 to
ea978c2
Compare
…orm to contract v0.5.0 Contract v0.5.0, "sites": one item for each Docker Compose project in the home folder of the server user. The CPU comes from the cgroup v2 usage_usec of the containers that both ticks saw, as a share of all the CPUs. The memory is memory.current minus inactive_file. A background walk measures the disk use of each folder at most each hour, at the idle I/O priority, and the next sample carries it one time. sites is null when the agent cannot read Docker or on cgroup v1, and [] when Docker runs and no project matches. The README pins contract v0.5.0. Closes #45
…d containers - The sites come after each step of Sample that can fail, so a dropped sample does not take the hourly disk result with it. - Each folder walk runs in a goroutine of its own: a walk that hangs in a system call no longer stops the next walks after the 5 minute limit. - The CPU time of the containers uses the time of their own reads, not the time of the tick reading. - A container that restarted with the same id has a new cgroup: its CPU time is left out for that minute. - A home folder of / makes no site.
… be read On a FlyWP server the databases in ~/.fly belong to the container user, so the walk skips them each hour. The agent now warns one time for each directory in a process, and logs the later walks at debug level.
A first minute without a sample now also reads the containers, so the next sample has the CPU of each site, not null.
nabil1440
force-pushed
the
agent/45-sites
branch
from
September 24, 2026 08:14
ea978c2 to
10544b5
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.
Closes #45.
Part of the monitoring agent stack. This PR is on top of #49. Contract v0.5.0, "
sites". After this PR, the agent conforms to contract v0.5.0, and the README pins it.What changes
sites: one item for each Docker Compose project in the home folder of the server user.GET /containers/json), and groups them by the labelcom.docker.compose.project.working_dir.directoryis the last part of the folder, for exampleexample.comor.fly.usage_usecdeltas of the cgroup v2cpu.statof the containers, as a share of all the CPUs.docker restartkeeps the id, but makes a new cgroup.memory.currentminusinactive_file, at the tick. Both the systemd and the cgroupfs cgroup drivers are supported.~/.fly/databasebelong to the container user, so.flyalways has such files.null.nulland[].sitesisnullwhen the agent cannot read Docker, on cgroup v1, or without a home folder. It is[]when Docker runs and no project matches. The queue on disk keeps the two apart.wiremoves to v0.5.0.Cost
Tests
nulland[], and/as the home.make checkpasses.