Increase CPU sampling interval for accurate readings

Changed from 100ms to 1 second sampling interval in gopsutil
cpu.Percent() call. Shorter intervals can give inaccurate readings
due to timing issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-09 10:57:51 -06:00
parent 3f2b5415ed
commit 80c6b58361

View File

@@ -77,8 +77,9 @@ func (c *Collector) Collect() SystemStats {
}
func (c *Collector) collectCPU(stats *SystemStats) {
// Get CPU usage percentage (this blocks for ~100ms to sample)
if cpuPercent, err := cpu.Percent(100*time.Millisecond, false); err == nil && len(cpuPercent) > 0 {
// Get CPU usage percentage (blocks for 1 second to get accurate sample)
// Shorter intervals can give inaccurate readings
if cpuPercent, err := cpu.Percent(time.Second, false); err == nil && len(cpuPercent) > 0 {
stats.CPU.UsagePercent = cpuPercent[0]
}