Skip to content

ENT-14329: cf-monitord stores only in-use measurement slots - #6276

Open
nickanderson wants to merge 5 commits into
cfengine:masterfrom
nickanderson:ENT-14329/master
Open

ENT-14329: cf-monitord stores only in-use measurement slots#6276
nickanderson wants to merge 5 commits into
cfengine:masterfrom
nickanderson:ENT-14329/master

Conversation

@nickanderson

@nickanderson nickanderson commented Aug 5, 2026

Copy link
Copy Markdown
Member

cf-monitord now stores only the measurement slots in use, so the 300-slot capacity from ENT-6511 costs no disk on hosts that do not use it: about 22.8 MB per host instead of 79 MB.

Also drops the Averages DB migration this makes unnecessary, and fixes three bugs it surfaced, in cf-check dump, GetObservable() and ts_key.

Needs cfengine/enterprise#989 to land with or before this: Nova_PackMonitorMg read short records into an unzeroed buffer and reported the trailing slots as measurements that were never taken.

nickanderson and others added 5 commits August 5, 2026 12:47
Nova_DumpSlots() appended to a 16 KB stack buffer with strlcat(), which
truncates silently. Line length depends on the name, description and units a
measurement promise gives the slot, so there is no useful bound to size against;
at CF_OBSERVABLES=300 the file is already 8474 bytes with only the built-in
observables in it. It is now built in a Writer that grows.

Once a record is written only through the highest slot in use, a truncated
ts_key costs the measurements in the lost slots, not just their names.

Ticket: ENT-14329
Changelog: cf-monitord no longer silently truncates the ts_key measurement name file
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
AveragesUsedSize() gives the length through the highest slot in use, and the two
WriteDB() call sites now write that much. GetRecordForTime() zeroes its buffer
and DBPrivRead() clamps the copy, so unstored slots read back as zero -- which is
also how a record from a smaller-CF_OBSERVABLES agent already reads.

On Linux, where the memory and I/O probes register nine slots, a record is 2600
bytes rather than 9608: about 22.8 MB per host across both DBs instead of 79 MB.

Ticket: ENT-14329
Changelog: cf-monitord stores only in-use measurement slots
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…e table

GetObservable() copied from OBSERVABLES for slots the table does not name, so
raising CF_OBSERVABLES meant adding a {"spare", "unused"} row per added slot to
keep strncpy() off a NULL. It now reports those slots directly, and the rows are
gone.

Ticket: ENT-14329
Changelog: None
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…records

The migration (ENT-6511) rewrote pre-ENT-6511 records to the full Averages size
so every record on disk shared one layout. Short records are now the normal case
and readers handle them, so the migration would only work against this ticket:
on upgrade it expands ~4392 records in each of two DBs to full size, the ~56 MB
per host this change removes.

It never shipped in a release, so only hosts tracking master carry the "version"
key it wrote, and that key is inert once the plan is unregistered.

Ticket: ENT-14329
Changelog: None
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
GetObservableNames() had its two cases the wrong way round: named slots came
back as "spare[<index>]", and every spare slot shared the single name "spare" so
the whole tail collapsed into one key of the JSON object. A malformed line also
reached that comparison with name possibly untouched by sscanf(); it now falls
back to the numbered placeholder.

Ticket: ENT-14329
Changelog: cf-check dump reports measurement names instead of labelling them spare
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nickanderson
nickanderson requested a review from larsewi August 6, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants