You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the change since the last sample, for the interfaces of decision 1
net_counters_reset
true when 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-required exists
updates_total, updates_security
/usr/lib/update-notifier/apt-check, at start and then each hour (decision 2)
os
PRETTY_NAME from /etc/os-release
kernel
the kernel release (uname -r)
uptime_seconds
/proc/uptime
arch
the arch of the build (amd64 or arm64)
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 17 veth interfaces.
Container traffic goes through a veth, a bridge and eth0. 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>/device exists). On the test server, these are eth0 and eth1. 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-check shows 33;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-check at start and then each hour, and always send the last counts. If apt-check is not on the server, propose a contract change that permits null ("not known").
Completion checks
On a test server, memory and disk agree with free -b and df -B1 /.
cpu_percent stays 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.
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
Cost
Benefit of the fix
Fix
Take one sample each minute, at the cycle second of Add
fly agent run, the base of the monitoring agent #26.Measure these values. All of them need no root.
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_bytesnet_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:
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-releasekerneluname -r)uptime_seconds/proc/uptimearchamd64orarm64)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.
eth0(public),eth1(private network),lo,docker0, 5 Docker bridges and 17vethinterfaces.veth, a bridge andeth0. If the agent adds all interfaces, it counts the same traffic 2 or 3 times./sys/class/net/<name>/deviceexists). On the test server, these areeth0andeth1. If no interface has a device, count the interface of the default route.apt-checkshows33;0(33 updates, 0 security updates) in about 3 seconds. Thus, the agent must not run it each minute.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").Completion checks
free -banddf -B1 /.cpu_percentstays between 0 and 100.eth0.net_counters_reset: true.archincluded.