Skip to content

fix: freebsd plugin counters size mismatch - #23044

Merged
ilyam8 merged 2 commits into
netdata:masterfrom
DavidMarec:fix/plugin/freebsd/64bcounters
Jul 10, 2026
Merged

fix: freebsd plugin counters size mismatch#23044
ilyam8 merged 2 commits into
netdata:masterfrom
DavidMarec:fix/plugin/freebsd/64bcounters

Conversation

@DavidMarec

@DavidMarec DavidMarec commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
Summary

Fix incorrect data types for FreeBSD vm.stats.* counters. All vm.stats. counters are defined as counter_u64_t (64-bit) in the FreeBSD kernel, but the Netdata FreeBSD plugin was reading them as u_int (32-bit).

Test Plan

NetData outputs tested on one FreeBSD 15 machine.

Additional Information

This work was sponsored by OVHcloud.


Summary by cubic

Read FreeBSD vm.stats.* counters as 64-bit (uint64_t) in the plugin to match kernel counter_u64_t. Fixes truncation and inaccurate values for interrupts (v_intr), soft interrupts (v_soft), context switches (v_swtch), and forks (v_forks).

Written for commit 2defc73. Summary will update on new commits.

Review in cubic

Fix incorrect data types for FreeBSD `vm.stats.*` counters.
All `vm.stats.` counters are defined as `counter_u64_t` (64-bit) in the FreeBSD kernel,
but the Netdata FreeBSD plugin was reading them as `u_int` (32-bit).

This work was sponsored by [OVHcloud](https://www.ovhcloud.com).
@DavidMarec
DavidMarec requested a review from thiagoftsm as a code owner July 8, 2026 08:53
@CLAassistant

CLAassistant commented Jul 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added area/collectors Everything related to data collection collectors/freebsd labels Jul 8, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes FreeBSD vm.stats.* sysctl counter reads in freebsd.plugin by using 64-bit types so they match the kernel’s 64-bit counter storage and avoid size-mismatch failures/inaccurate readings.

Changes:

  • Read vm.stats.sys.v_intr, vm.stats.sys.v_soft, vm.stats.sys.v_swtch, and vm.stats.vm.v_forks into uint64_t instead of u_int.
  • Preserve existing chart update logic while allowing these counters to be fetched with the correct sysctl value size.
Comments suppressed due to low confidence (2)

src/collectors/freebsd.plugin/freebsd_sysctl.c:690

  • The error message for the v_soft sysctl failure disables the wrong chart name. This function creates the system.soft_intr chart, but the error message currently says system.dev_intr, which is misleading during troubleshooting.
    uint64_t soft_intr_number;

    if (unlikely(GETSYSCTL_SIMPLE("vm.stats.sys.v_soft", mib, soft_intr_number))) {
        collector_error("DISABLED: system.dev_intr chart");
        collector_error("DISABLED: vm.stats.sys.v_soft module");

src/collectors/freebsd.plugin/freebsd_sysctl.c:772

  • The module name in this error message doesn't match the sysctl being read. On failure of vm.stats.vm.v_forks, it currently reports vm.stats.sys.v_swtch, which makes logs misleading.
    uint64_t forks_number;

    if (unlikely(GETSYSCTL_SIMPLE("vm.stats.vm.v_forks", mib, forks_number))) {
        collector_error("DISABLED: system.forks chart");
        collector_error("DISABLED: vm.stats.sys.v_swtch module");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ilyam8

ilyam8 commented Jul 8, 2026

Copy link
Copy Markdown
Member

@DavidMarec, thanks! See the CLA. We'll need it to be signed before we can merge the PR.

@DavidMarec

Copy link
Copy Markdown
Contributor Author

@DavidMarec, thanks! See the CLA. We'll need it to be signed before we can merge the PR.

it's signed for.

@sonarqubecloud

Copy link
Copy Markdown

@ilyam8
ilyam8 enabled auto-merge (squash) July 10, 2026 08:00
@ilyam8
ilyam8 merged commit 3ad0f3f into netdata:master Jul 10, 2026
150 of 154 checks passed
@DavidMarec
DavidMarec deleted the fix/plugin/freebsd/64bcounters branch July 10, 2026 09:47
stelfrag pushed a commit to stelfrag/netdata that referenced this pull request Jul 12, 2026
@stelfrag stelfrag mentioned this pull request Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/collectors Everything related to data collection collectors/freebsd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants