Skip to content

fix(inputs.cpu): Compute Windows total from individual CPUs#19286

Open
srebhan wants to merge 1 commit into
influxdata:masterfrom
srebhan:cpu_issue_18141a
Open

fix(inputs.cpu): Compute Windows total from individual CPUs#19286
srebhan wants to merge 1 commit into
influxdata:masterfrom
srebhan:cpu_issue_18141a

Conversation

@srebhan

@srebhan srebhan commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

Testing for now...

Checklist

Related issues

resolves #18141

@telegraf-tiger telegraf-tiger Bot added fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Jul 14, 2026
@srebhan
srebhan force-pushed the cpu_issue_18141a branch from 403d9ad to 6e481c2 Compare July 20, 2026 14:07
@srebhan
srebhan marked this pull request as ready for review July 20, 2026 14:07
@srebhan srebhan added area/system ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. labels Jul 20, 2026
@telegraf-tiger

Copy link
Copy Markdown
Contributor

@skartikey skartikey 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.

plugins/inputs/cpu/cpu_test.go TestCases skips on non-Linux and it's the only test, so none of the 245 lines of new Windows syscall code (queryWithGroups, group concat, total accumulation) ever runs. test-go-windows going green only means it compiles. Split the arithmetic out of the querying so it can be table-tested with a synthetic []systemProcessorPerformanceInformation.

Comment thread plugins/inputs/cpu/cpu.go
}

// Debug print the raw data for invalid values
if c.Log.Level().Includes(telegraf.Trace) && report {

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.

is this trace block staying? The zero-delta path at line 104 sets report=true, which isn't an invalid value, so on an idle box this logs "Detected invalid field values!" on healthy data, and it dumps every CPU instead of the ones that actually failed valid().

total.User += uint64(s.UserTime)
total.System += uint64(s.KernelTime - s.IdleTime)
total.Idle += uint64(s.IdleTime)
total.Irq += uint64(s.InterruptTime)

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.

summing Irq into the total here (and into the denominator at line 109) changes the Windows cpu-total: usage_irq was structurally always zero via GetSystemTimes and now isn't, and usage_user/system/idle shift down as the denominator grew. Intended? Per-CPU is unaffected, but this moves existing Windows dashboards

Comment thread plugins/inputs/cpu/cpu.go
@@ -19,7 +19,7 @@ var sampleConfig string

type CPU struct {
ps psutil.PS

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.

ps is now write-only, set in the init factory and the test but never read since Gather stopped calling c.ps.CPUTimes. Drop the field, the two assignments, and the psutil import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/system fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegraf reports more than 100% cpu usage and negative values on a 40 logical cores system

2 participants