ENT-14329: cf-monitord stores only in-use measurement slots - #6276
Open
nickanderson wants to merge 5 commits into
Open
ENT-14329: cf-monitord stores only in-use measurement slots#6276nickanderson wants to merge 5 commits into
nickanderson wants to merge 5 commits into
Conversation
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>
larsewi
approved these changes
Aug 7, 2026
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.
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()andts_key.Needs cfengine/enterprise#989 to land with or before this:
Nova_PackMonitorMgread short records into an unzeroed buffer and reported the trailing slots as measurements that were never taken.