Repository navigation
Description
Blocker: no. No other issue waits for this.
Part of the monitoring agent (contract v0.2.1). Order: #26 → #27 → #28 → #29 → #30, with #9.
Defect
- The contract requires one sample each minute and the status of the server (section 4, and "What 'used' means").
- The CLI measures nothing.
Cost
- FlyWP cannot show the charts, the update status or the alerts of the server page.
Benefit of the fix
- The server page shows CPU, memory, disk and bandwidth, and the restart and update status.
- FlyWP can send an alert before a server runs out of a resource.
Fix
-
Take one sample each minute, at the cycle second of enhancement: Add
fly agent run, the base of the monitoring agent #26. -
Measure these values. All of them need no root.
Field Source cpu_percent/proc/stat, the change since the last sample, 0 to 100load_1/proc/loadavgmemory_used_bytes,memory_total_bytes/proc/meminfo:MemTotal−MemAvailable, andMemTotalswap_used_bytes,swap_total_bytes/proc/meminfo:SwapTotal−SwapFree, andSwapTotaldisk_used_bytes,disk_total_bytesstatfs("/"): (blocks − free) × block size, and blocks × block sizenet_in_bytes,net_out_bytesthe change since the last sample, for the interfaces of decision 1 net_counters_resettruewhen a counter goes back. Then send 0 for that minute. -
Keep the last CPU and network counters in the state folder, with the boot id (
/proc/sys/kernel/random/boot_id). After an agent restart, the next sample continues from them. -
If the boot id changed, or the saved counters are older than 2 minutes, send 0 and
net_counters_reset: true. Reason: the change then covers more than one minute. -
Send the status in each report:
Field Source reboot_required/var/run/reboot-requiredexistsupdates_total,updates_security/usr/lib/update-notifier/apt-check, at start and then each hour (decision 2)osPRETTY_NAMEfrom/etc/os-releasekernelthe kernel release ( uname -r)uptime_seconds/proc/uptimearchthe arch of the build ( amd64orarm64) -
Always send the full status object. Reason: the control plane replaces the status. A field that is not sent becomes 0 or empty.
Decision necessary
Both decisions are gaps in the contract. After the decision, propose a contract change.
- Which network interfaces does the agent count?
- The contract does not say.
- A test server has 27 interfaces:
eth0(public),eth1(private network),lo,docker0, 5 Docker bridges and 17vethinterfaces. - Container traffic goes through a
veth, a bridge andeth0. If the agent adds all interfaces, it counts the same traffic 2 or 3 times. - Recommendation: count the interfaces that have a hardware device (
/sys/class/net/<name>/deviceexists). On the test server, these areeth0andeth1. If no interface has a device, count the interface of the default route. - Other option: count only the interface of the default route. This ignores the private network.
- What does the agent send when it cannot count the updates?
- On the test server,
apt-checkshows33;0(33 updates, 0 security updates) in about 3 seconds. Thus, the agent must not run it each minute. - The control plane stores 0 when the agent does not send a count. Thus "not known" and "no updates" look the same.
- Recommendation: run
apt-checkat start and then each hour, and always send the last counts. Ifapt-checkis not on the server, propose a contract change that permitsnull("not known").
- On the test server,
Completion checks
- On a test server, memory and disk agree with
free -banddf -B1 /. -
cpu_percentstays between 0 and 100. - Container traffic is not counted two times. Compare with the counters of
eth0. - An agent restart makes no bandwidth spike.
- After a reboot, the first sample has
net_counters_reset: true. - The status has all fields,
archincluded. - The agent measures when Docker is stopped.
Activity
feat(agent): measure the server each minute (#33)
[-]Measure the server each minute for the monitoring agent[/-][+]enhancement: Measure the server each minute for the monitoring agent[/+]