diff --git a/plugins/inputs/cpu/cpu_test.go b/plugins/inputs/cpu/cpu_test.go index f9c07678a51a9..7ae804b5161b9 100644 --- a/plugins/inputs/cpu/cpu_test.go +++ b/plugins/inputs/cpu/cpu_test.go @@ -1,249 +1,119 @@ package cpu import ( + "os" + "path/filepath" + "runtime" + "slices" "testing" - "github.com/shirou/gopsutil/v4/cpu" + "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/common/psutil" + "github.com/influxdata/telegraf/plugins/inputs" + "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/testutil" ) -func newCPUStats(ps psutil.PS) *CPU { - return &CPU{ - ps: ps, - CollectCPUTime: true, - ReportActive: true, - } -} - -func TestCPUStats(t *testing.T) { - var mps psutil.MockPS - defer mps.AssertExpectations(t) - var acc testutil.Accumulator - - cts := cpu.TimesStat{ - CPU: "cpu0", - User: 8.8, - System: 8.2, - Idle: 80.1, - Nice: 1.3, - Iowait: 0.8389, - Irq: 0.6, - Softirq: 0.11, - Steal: 0.0511, - Guest: 3.1, - GuestNice: 0.324, - } - - cts2 := cpu.TimesStat{ - CPU: "cpu0", - User: 24.9, // increased by 16.1 - System: 10.9, // increased by 2.7 - Idle: 157.9798, // increased by 77.8798 (for total increase of 100) - Nice: 3.5, // increased by 2.2 - Iowait: 0.929, // increased by 0.0901 - Irq: 1.2, // increased by 0.6 - Softirq: 0.31, // increased by 0.2 - Steal: 0.2812, // increased by 0.2301 - Guest: 11.4, // increased by 8.3 - GuestNice: 2.524, // increased by 2.2 +func TestCases(t *testing.T) { + if runtime.GOOS != "linux" { + t.Skip("CPU usage mocking works on Linux only!") } - mps.On("CPUTimes").Return([]cpu.TimesStat{cts}, nil) - - cs := newCPUStats(&mps) - - err := cs.Gather(&acc) + // Get all testcase directories + testcases, err := os.ReadDir("testcases") require.NoError(t, err) - // Computed values are checked with delta > 0 because of floating point arithmetic - // imprecision - assertContainsTaggedFloat(t, &acc, "time_user", 8.8, 0) - assertContainsTaggedFloat(t, &acc, "time_system", 8.2, 0) - assertContainsTaggedFloat(t, &acc, "time_idle", 80.1, 0) - assertContainsTaggedFloat(t, &acc, "time_active", 19.9, 0.0005) - assertContainsTaggedFloat(t, &acc, "time_nice", 1.3, 0) - assertContainsTaggedFloat(t, &acc, "time_iowait", 0.8389, 0) - assertContainsTaggedFloat(t, &acc, "time_irq", 0.6, 0) - assertContainsTaggedFloat(t, &acc, "time_softirq", 0.11, 0) - assertContainsTaggedFloat(t, &acc, "time_steal", 0.0511, 0) - assertContainsTaggedFloat(t, &acc, "time_guest", 3.1, 0) - assertContainsTaggedFloat(t, &acc, "time_guest_nice", 0.324, 0) - - mps2 := psutil.MockPS{} - mps2.On("CPUTimes").Return([]cpu.TimesStat{cts2}, nil) - cs.ps = &mps2 - - // Should have added cpu percentages too - err = cs.Gather(&acc) - require.NoError(t, err) - - assertContainsTaggedFloat(t, &acc, "time_user", 24.9, 0) - assertContainsTaggedFloat(t, &acc, "time_system", 10.9, 0) - assertContainsTaggedFloat(t, &acc, "time_idle", 157.9798, 0) - assertContainsTaggedFloat(t, &acc, "time_active", 42.0202, 0.0005) - assertContainsTaggedFloat(t, &acc, "time_nice", 3.5, 0) - assertContainsTaggedFloat(t, &acc, "time_iowait", 0.929, 0) - assertContainsTaggedFloat(t, &acc, "time_irq", 1.2, 0) - assertContainsTaggedFloat(t, &acc, "time_softirq", 0.31, 0) - assertContainsTaggedFloat(t, &acc, "time_steal", 0.2812, 0) - assertContainsTaggedFloat(t, &acc, "time_guest", 11.4, 0) - assertContainsTaggedFloat(t, &acc, "time_guest_nice", 2.524, 0) - - assertContainsTaggedFloat(t, &acc, "usage_user", 7.8, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_system", 2.7, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_idle", 77.8798, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_active", 22.1202, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_nice", 0, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_iowait", 0.0901, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_irq", 0.6, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_softirq", 0.2, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_steal", 0.2301, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_guest", 8.3, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_guest_nice", 2.2, 0.0005) -} - -// Asserts that a given accumulator contains a measurement of type float64 with -// specific tags within a certain distance of a given expected value. Asserts a failure -// if the measurement is of the wrong type, or if no matching measurements are found -// -// Parameters: -// -// t *testing.T : Testing object to use -// acc testutil.Accumulator: Accumulator to examine -// field string : Name of field to examine -// expectedValue float64 : Value to search for within the measurement -// delta float64 : Maximum acceptable distance of an accumulated value -// from the expectedValue parameter. Useful when -// floating-point arithmetic imprecision makes looking -// for an exact match impractical -func assertContainsTaggedFloat( - t *testing.T, - acc *testutil.Accumulator, - field string, - expectedValue, delta float64, -) { - var actualValue float64 - measurement := "cpu" // always cpu - for _, pt := range acc.Metrics { - if pt.Measurement == measurement { - for fieldname, value := range pt.Fields { - if fieldname == field { - if value, ok := value.(float64); ok { - actualValue = value - if (value >= expectedValue-delta) && (value <= expectedValue+delta) { - // Found the point, return without failing - return - } - } else { - require.Failf(t, "Wrong type", "Measurement %q does not have type float64", measurement) - } - } - } + // Register the plugin + inputs.Add("cpu", func() telegraf.Input { + return &CPU{ + PerCPU: true, + TotalCPU: true, + ps: psutil.NewSystemPS(), } - } - require.Failf(t, "Measurement not found", - "Could not find measurement %q with requested tags within %f of %f, Actual: %f", measurement, delta, expectedValue, actualValue) -} - -// TestCPUCountChange tests that no errors are encountered if the number of -// CPUs increases as reported with LXC. -func TestCPUCountIncrease(t *testing.T) { - var mps psutil.MockPS - var mps2 psutil.MockPS - var acc testutil.Accumulator - var err error - - cs := newCPUStats(&mps) - - mps.On("CPUTimes").Return( - []cpu.TimesStat{ - { - CPU: "cpu0", - }, - }, nil) - - err = cs.Gather(&acc) - require.NoError(t, err) + }) - mps2.On("CPUTimes").Return( - []cpu.TimesStat{ - { - CPU: "cpu0", - }, - { - CPU: "cpu1", - }, - }, nil) - cs.ps = &mps2 - - err = cs.Gather(&acc) - require.NoError(t, err) -} - -// TestCPUTimesDecrease tests that telegraf continue to works after -// CPU times decrease, which seems to occur when Linux system is suspended. -func TestCPUTimesDecrease(t *testing.T) { - var mps psutil.MockPS - defer mps.AssertExpectations(t) - var acc testutil.Accumulator - - cts := cpu.TimesStat{ - CPU: "cpu0", - User: 18, - Idle: 80, - Iowait: 2, - } - - cts2 := cpu.TimesStat{ - CPU: "cpu0", - User: 38, // increased by 20 - Idle: 40, // decreased by 40 - Iowait: 1, // decreased by 1 + // Testing options + opts := []cmp.Option{ + testutil.IgnoreTime(), + testutil.IgnoreType(), + testutil.SortMetrics(), } - cts3 := cpu.TimesStat{ - CPU: "cpu0", - User: 56, // increased by 18 - Idle: 120, // increased by 80 - Iowait: 3, // increased by 2 - } - - mps.On("CPUTimes").Return([]cpu.TimesStat{cts}, nil) - - cs := newCPUStats(&mps) - - err := cs.Gather(&acc) - require.NoError(t, err) - - // Computed values are checked with delta > 0 because of floating point arithmetic - // imprecision - assertContainsTaggedFloat(t, &acc, "time_user", 18, 0) - assertContainsTaggedFloat(t, &acc, "time_idle", 80, 0) - assertContainsTaggedFloat(t, &acc, "time_iowait", 2, 0) - - mps2 := psutil.MockPS{} - mps2.On("CPUTimes").Return([]cpu.TimesStat{cts2}, nil) - cs.ps = &mps2 - - // CPU times decreased. An error should be raised - err = cs.Gather(&acc) - require.Error(t, err) + for _, testcase := range testcases { + // Only handle folders + if !testcase.IsDir() { + continue + } - mps3 := psutil.MockPS{} - mps3.On("CPUTimes").Return([]cpu.TimesStat{cts3}, nil) - cs.ps = &mps3 + t.Run(testcase.Name(), func(t *testing.T) { + testcaseDir := filepath.Join("testcases", testcase.Name()) + configFile := filepath.Join(testcaseDir, "telegraf.conf") + + // Load plugin from config + conf := config.NewConfig() + require.NoError(t, conf.LoadConfig(configFile)) + require.Len(t, conf.Inputs, 1) + plugin, ok := conf.Inputs[0].Input.(*CPU) + require.True(t, ok) + + // Create parser for loading the expected metrics + parser := &influx.Parser{} + require.NoError(t, parser.Init()) + + // Get all steps + matches, err := filepath.Glob(filepath.Join(testcaseDir, "proc*")) + require.NoError(t, err) + slices.Sort(matches) + + // Make sure we cleanup the environment + backup := os.Getenv("HOST_PROC") + //nolint:usetesting // We need to reset the environment manually as we reset the environment multiple times + t.Cleanup(func() { os.Setenv("HOST_PROC", backup) }) + + // Iterate the different counter states and check the results + for _, m := range matches { + proc, err := filepath.Abs(m) + require.NoError(t, err) + + // Point processing to mock file + //nolint:usetesting // We manually cleanup the environment as it's unclear whether t.Setenv can handle + // multiple calls within a test or not + os.Setenv("HOST_PROC", proc) + + // Read the expected output if any + expectedErrorFilename := filepath.Join(proc, "expected.err") + var expectedError string + if _, err := os.Stat(expectedErrorFilename); err == nil { + expectedErrors, err := testutil.ParseLinesFromFile(expectedErrorFilename) + require.NoError(t, err) + require.Len(t, expectedErrors, 1) + expectedError = expectedErrors[0] + } - err = cs.Gather(&acc) - require.NoError(t, err) + // Load exected metrics + var expected []telegraf.Metric + if expectedError == "" { + expected, err = testutil.ParseMetricsFromFile(filepath.Join(proc, "expected.out"), parser) + require.NoError(t, err) + } - assertContainsTaggedFloat(t, &acc, "time_user", 56, 0) - assertContainsTaggedFloat(t, &acc, "time_idle", 120, 0) - assertContainsTaggedFloat(t, &acc, "time_iowait", 3, 0) + // Gather data and check for error or for the returned metrics + var acc testutil.Accumulator + err = plugin.Gather(&acc) + if expectedError != "" { + require.ErrorContains(t, err, expectedError) + continue + } - assertContainsTaggedFloat(t, &acc, "usage_user", 18, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_idle", 80, 0.0005) - assertContainsTaggedFloat(t, &acc, "usage_iowait", 2, 0.0005) + // Check the outcome in no-error case + require.NoError(t, err) + t.Logf("checking %q", m) + testutil.RequireMetricsEqual(t, expected, acc.GetTelegrafMetrics(), opts...) + } + }) + } } diff --git a/plugins/inputs/cpu/testcases/counters/proc/expected.out b/plugins/inputs/cpu/testcases/counters/proc/expected.out new file mode 100644 index 0000000000000..f7db26f85d391 --- /dev/null +++ b/plugins/inputs/cpu/testcases/counters/proc/expected.out @@ -0,0 +1 @@ +cpu,cpu=cpu-total time_guest=0,time_guest_nice=0,time_idle=153423.53,time_iowait=67.31,time_irq=159.58,time_nice=0.3,time_softirq=36.21,time_steal=0,time_system=360.48,time_user=1106.86 1784292599146890138 diff --git a/plugins/inputs/cpu/testcases/counters/proc/stat b/plugins/inputs/cpu/testcases/counters/proc/stat new file mode 100644 index 0000000000000..3a013faf2addd --- /dev/null +++ b/plugins/inputs/cpu/testcases/counters/proc/stat @@ -0,0 +1,24 @@ +cpu 110686 30 36048 15342353 6731 15958 3621 0 0 0 +cpu0 5006 0 2060 960064 467 741 1220 0 0 0 +cpu1 18428 4 5470 942378 830 1224 416 0 0 0 +cpu2 17820 10 4259 944457 943 1216 289 0 0 0 +cpu3 7942 0 3004 956117 635 1180 513 0 0 0 +cpu4 1955 0 525 967247 127 185 64 0 0 0 +cpu5 2145 0 1041 966329 207 264 69 0 0 0 +cpu6 2650 0 1425 965279 289 285 79 0 0 0 +cpu7 1764 0 566 967413 197 199 52 0 0 0 +cpu8 5151 0 1877 961476 423 654 109 0 0 0 +cpu9 15653 13 6061 945775 644 878 179 0 0 0 +cpu10 18587 0 4112 938088 642 7565 197 0 0 0 +cpu11 6396 0 2672 958675 585 896 278 0 0 0 +cpu12 1437 0 461 967933 188 160 30 0 0 0 +cpu13 1871 0 838 967145 144 161 36 0 0 0 +cpu14 2195 0 1229 966266 198 195 47 0 0 0 +cpu15 1678 0 440 967703 204 149 35 0 0 0 +intr 20906479 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 28964860 +btime 1784274102 +processes 6861 +procs_running 2 +procs_blocked 1 +softirq 4988227 195425 921067 207 218639 267 0 30784 2839132 5 782701 diff --git a/plugins/inputs/cpu/testcases/counters/telegraf.conf b/plugins/inputs/cpu/testcases/counters/telegraf.conf new file mode 100644 index 0000000000000..bc66cd07ce416 --- /dev/null +++ b/plugins/inputs/cpu/testcases/counters/telegraf.conf @@ -0,0 +1,3 @@ +[[inputs.cpu]] + collect_cpu_time = true + percpu = false diff --git a/plugins/inputs/cpu/testcases/cpu_count_decrease/proc0/expected.out b/plugins/inputs/cpu/testcases/cpu_count_decrease/proc0/expected.out new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/plugins/inputs/cpu/testcases/cpu_count_decrease/proc0/stat b/plugins/inputs/cpu/testcases/cpu_count_decrease/proc0/stat new file mode 100644 index 0000000000000..16be82c8253a6 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_count_decrease/proc0/stat @@ -0,0 +1,10 @@ +cpu 110686 30 36048 15342353 6731 15958 3621 0 0 0 +cpu0 5006 0 2060 960064 467 741 1220 0 0 0 +cpu1 18428 4 5470 942378 830 1224 416 0 0 0 +intr 20906479 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 73 0 1 1 1 1 0 1 0 1 0 1 0 0 75 2293 0 0 0 0 0 0 0 0 194491 0 0 0 0 0 0 0 0 127 126 30931 25097 23368 23289 13177 15355 14638 14865 16237 15868 15531 15929 30489 26183 21121 22437 143 424 457 171 34 31 223 88 435 30 51 73 1713 216 116 92 0 0 0 0 707 0 0 842993 0 129196 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 28964860 +btime 1784274102 +processes 6861 +procs_running 2 +procs_blocked 1 +softirq 4988227 195425 921067 207 218639 267 0 30784 2839132 5 782701 diff --git a/plugins/inputs/cpu/testcases/cpu_count_decrease/proc1/expected.out b/plugins/inputs/cpu/testcases/cpu_count_decrease/proc1/expected.out new file mode 100644 index 0000000000000..4d5f01006af24 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_count_decrease/proc1/expected.out @@ -0,0 +1,2 @@ +cpu,cpu=cpu0 usage_guest=0,usage_guest_nice=0,usage_idle=98.99208959203628,usage_iowait=0.03393637737251638,usage_irq=0.10245553930559709,usage_nice=0,usage_softirq=0.14027035980640107,usage_steal=0,usage_system=0.3120530700301387,usage_user=0.41919506144908336 1784293055014711043 +cpu,cpu=cpu-total usage_guest=0,usage_guest_nice=0,usage_idle=98.79324440645692,usage_iowait=0.0320620665057134,usage_irq=0.13419615804548835,usage_nice=0.000010098288663216828,usage_softirq=0.0386057575594779,usage_steal=0,usage_system=0.40175031617741797,usage_user=0.6001311969663126 1784293055014711043 diff --git a/plugins/inputs/cpu/testcases/cpu_count_decrease/proc1/stat b/plugins/inputs/cpu/testcases/cpu_count_decrease/proc1/stat new file mode 100644 index 0000000000000..d10e78fbaf9a6 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_count_decrease/proc1/stat @@ -0,0 +1,9 @@ +cpu 170115 31 75832 25125520 9906 29247 7444 0 0 0 +cpu0 7600 0 3991 1572632 677 1375 2088 0 0 0 +intr 45048657 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 123 0 1 1 1 1 0 1 0 1 0 1 0 0 77 21045 0 0 0 0 0 0 0 0 302128 0 0 0 0 0 0 0 0 177 175 71569 54574 43086 34410 14401 16556 16569 15788 19087 18385 16613 16948 63242 44624 30094 30833 143 424 457 171 34 31 223 88 460 41 52 75 1713 216 116 92 0 0 0 0 707 0 0 1365814 0 3353162 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 63952662 +btime 1784274102 +processes 37029 +procs_running 2 +procs_blocked 1 +softirq 13952814 321794 1531238 314 5602346 366 0 34044 5070960 10007 1381745 diff --git a/plugins/inputs/cpu/testcases/cpu_count_decrease/telegraf.conf b/plugins/inputs/cpu/testcases/cpu_count_decrease/telegraf.conf new file mode 100644 index 0000000000000..4c36f6ce9bc7a --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_count_decrease/telegraf.conf @@ -0,0 +1,2 @@ +# Tests case where the number of CPUs decreases e.g. in LXC VMs +[[inputs.cpu]] diff --git a/plugins/inputs/cpu/testcases/cpu_count_increase/proc0/expected.out b/plugins/inputs/cpu/testcases/cpu_count_increase/proc0/expected.out new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/plugins/inputs/cpu/testcases/cpu_count_increase/proc0/stat b/plugins/inputs/cpu/testcases/cpu_count_increase/proc0/stat new file mode 100644 index 0000000000000..10241e8ae81e2 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_count_increase/proc0/stat @@ -0,0 +1,9 @@ +cpu 110686 30 36048 15342353 6731 15958 3621 0 0 0 +cpu0 5006 0 2060 960064 467 741 1220 0 0 0 +intr 20906479 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 73 0 1 1 1 1 0 1 0 1 0 1 0 0 75 2293 0 0 0 0 0 0 0 0 194491 0 0 0 0 0 0 0 0 127 126 30931 25097 23368 23289 13177 15355 14638 14865 16237 15868 15531 15929 30489 26183 21121 22437 143 424 457 171 34 31 223 88 435 30 51 73 1713 216 116 92 0 0 0 0 707 0 0 842993 0 129196 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 28964860 +btime 1784274102 +processes 6861 +procs_running 2 +procs_blocked 1 +softirq 4988227 195425 921067 207 218639 267 0 30784 2839132 5 782701 diff --git a/plugins/inputs/cpu/testcases/cpu_count_increase/proc1/expected.out b/plugins/inputs/cpu/testcases/cpu_count_increase/proc1/expected.out new file mode 100644 index 0000000000000..0db22e54bf05d --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_count_increase/proc1/expected.out @@ -0,0 +1,2 @@ +cpu,cpu=cpu0 usage_guest=0,usage_guest_nice=0,usage_idle=98.99208959203628,usage_iowait=0.03393637737251638,usage_irq=0.10245553930559709,usage_nice=0,usage_softirq=0.14027035980640107,usage_steal=0,usage_system=0.3120530700301387,usage_user=0.41919506144908336 1784292824479533244 +cpu,cpu=cpu-total usage_guest=0,usage_guest_nice=0,usage_idle=98.79324440645692,usage_iowait=0.0320620665057134,usage_irq=0.13419615804548835,usage_nice=0.000010098288663216828,usage_softirq=0.0386057575594779,usage_steal=0,usage_system=0.40175031617741797,usage_user=0.6001311969663126 1784292824479533244 diff --git a/plugins/inputs/cpu/testcases/cpu_count_increase/proc1/stat b/plugins/inputs/cpu/testcases/cpu_count_increase/proc1/stat new file mode 100644 index 0000000000000..8b7ffdc6149d3 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_count_increase/proc1/stat @@ -0,0 +1,10 @@ +cpu 170115 31 75832 25125520 9906 29247 7444 0 0 0 +cpu0 7600 0 3991 1572632 677 1375 2088 0 0 0 +cpu1 29604 4 12656 1540003 1309 2340 741 0 0 0 +intr 45048657 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 123 0 1 1 1 1 0 1 0 1 0 1 0 0 77 21045 0 0 0 0 0 0 0 0 302128 0 0 0 0 0 0 0 0 177 175 71569 54574 43086 34410 14401 16556 16569 15788 19087 18385 16613 16948 63242 44624 30094 30833 143 424 457 171 34 31 223 88 460 41 52 75 1713 216 116 92 0 0 0 0 707 0 0 1365814 0 3353162 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 63952662 +btime 1784274102 +processes 37029 +procs_running 2 +procs_blocked 1 +softirq 13952814 321794 1531238 314 5602346 366 0 34044 5070960 10007 1381745 diff --git a/plugins/inputs/cpu/testcases/cpu_count_increase/telegraf.conf b/plugins/inputs/cpu/testcases/cpu_count_increase/telegraf.conf new file mode 100644 index 0000000000000..14661b9c5b137 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_count_increase/telegraf.conf @@ -0,0 +1,2 @@ +# Tests case where the number of CPUs increases e.g. in LXC VMs +[[inputs.cpu]] diff --git a/plugins/inputs/cpu/testcases/cpu_times_decrease/proc0/expected.out b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc0/expected.out new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/plugins/inputs/cpu/testcases/cpu_times_decrease/proc0/stat b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc0/stat new file mode 100644 index 0000000000000..f204b2c768266 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc0/stat @@ -0,0 +1,9 @@ +cpu 18 0 0 100 80 2 0 0 0 0 +cpu0 18 0 0 100 80 2 0 0 0 0 +intr 20906479 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 73 0 1 1 1 1 0 1 0 1 0 1 0 0 75 2293 0 0 0 0 0 0 0 0 194491 0 0 0 0 0 0 0 0 127 126 30931 25097 23368 23289 13177 15355 14638 14865 16237 15868 15531 15929 30489 26183 21121 22437 143 424 457 171 34 31 223 88 435 30 51 73 1713 216 116 92 0 0 0 0 707 0 0 842993 0 129196 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 28964860 +btime 1784274102 +processes 6861 +procs_running 2 +procs_blocked 1 +softirq 4988227 195425 921067 207 218639 267 0 30784 2839132 5 782701 diff --git a/plugins/inputs/cpu/testcases/cpu_times_decrease/proc1/expected.err b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc1/expected.err new file mode 100644 index 0000000000000..eed307ec80045 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc1/expected.err @@ -0,0 +1 @@ +current total CPU time is less than previous total CPU time diff --git a/plugins/inputs/cpu/testcases/cpu_times_decrease/proc1/stat b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc1/stat new file mode 100644 index 0000000000000..2632eeba31e70 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc1/stat @@ -0,0 +1,9 @@ +cpu 38 0 0 100 40 1 0 0 0 0 +cpu0 38 0 0 100 40 1 0 0 0 0 +intr 45048657 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 123 0 1 1 1 1 0 1 0 1 0 1 0 0 77 21045 0 0 0 0 0 0 0 0 302128 0 0 0 0 0 0 0 0 177 175 71569 54574 43086 34410 14401 16556 16569 15788 19087 18385 16613 16948 63242 44624 30094 30833 143 424 457 171 34 31 223 88 460 41 52 75 1713 216 116 92 0 0 0 0 707 0 0 1365814 0 3353162 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 63952662 +btime 1784274102 +processes 37029 +procs_running 2 +procs_blocked 1 +softirq 13952814 321794 1531238 314 5602346 366 0 34044 5070960 10007 1381745 diff --git a/plugins/inputs/cpu/testcases/cpu_times_decrease/proc2/expected.out b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc2/expected.out new file mode 100644 index 0000000000000..a52417d539eaf --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc2/expected.out @@ -0,0 +1,2 @@ +cpu,cpu=cpu0 usage_guest=0,usage_guest_nice=0,usage_idle=0,usage_iowait=80,usage_irq=1.9999999999999998,usage_nice=0,usage_softirq=0,usage_steal=0,usage_system=0,usage_user=18.000000000000004 1784293771279066203 +cpu,cpu=cpu-total usage_guest=0,usage_guest_nice=0,usage_idle=0,usage_iowait=80,usage_irq=1.9999999999999998,usage_nice=0,usage_softirq=0,usage_steal=0,usage_system=0,usage_user=18.000000000000004 1784293771279066203 diff --git a/plugins/inputs/cpu/testcases/cpu_times_decrease/proc2/stat b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc2/stat new file mode 100644 index 0000000000000..5ff4bfd452140 --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_times_decrease/proc2/stat @@ -0,0 +1,9 @@ +cpu 56 0 0 100 120 3 0 0 0 0 +cpu0 56 0 0 100 120 3 0 0 0 0 +intr 45048657 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 123 0 1 1 1 1 0 1 0 1 0 1 0 0 77 21045 0 0 0 0 0 0 0 0 302128 0 0 0 0 0 0 0 0 177 175 71569 54574 43086 34410 14401 16556 16569 15788 19087 18385 16613 16948 63242 44624 30094 30833 143 424 457 171 34 31 223 88 460 41 52 75 1713 216 116 92 0 0 0 0 707 0 0 1365814 0 3353162 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 63952662 +btime 1784274102 +processes 37029 +procs_running 2 +procs_blocked 1 +softirq 13952814 321794 1531238 314 5602346 366 0 34044 5070960 10007 1381745 diff --git a/plugins/inputs/cpu/testcases/cpu_times_decrease/telegraf.conf b/plugins/inputs/cpu/testcases/cpu_times_decrease/telegraf.conf new file mode 100644 index 0000000000000..4c36f6ce9bc7a --- /dev/null +++ b/plugins/inputs/cpu/testcases/cpu_times_decrease/telegraf.conf @@ -0,0 +1,2 @@ +# Tests case where the number of CPUs decreases e.g. in LXC VMs +[[inputs.cpu]] diff --git a/plugins/inputs/cpu/testcases/default/proc0/expected.out b/plugins/inputs/cpu/testcases/default/proc0/expected.out new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/plugins/inputs/cpu/testcases/default/proc0/stat b/plugins/inputs/cpu/testcases/default/proc0/stat new file mode 100644 index 0000000000000..3a013faf2addd --- /dev/null +++ b/plugins/inputs/cpu/testcases/default/proc0/stat @@ -0,0 +1,24 @@ +cpu 110686 30 36048 15342353 6731 15958 3621 0 0 0 +cpu0 5006 0 2060 960064 467 741 1220 0 0 0 +cpu1 18428 4 5470 942378 830 1224 416 0 0 0 +cpu2 17820 10 4259 944457 943 1216 289 0 0 0 +cpu3 7942 0 3004 956117 635 1180 513 0 0 0 +cpu4 1955 0 525 967247 127 185 64 0 0 0 +cpu5 2145 0 1041 966329 207 264 69 0 0 0 +cpu6 2650 0 1425 965279 289 285 79 0 0 0 +cpu7 1764 0 566 967413 197 199 52 0 0 0 +cpu8 5151 0 1877 961476 423 654 109 0 0 0 +cpu9 15653 13 6061 945775 644 878 179 0 0 0 +cpu10 18587 0 4112 938088 642 7565 197 0 0 0 +cpu11 6396 0 2672 958675 585 896 278 0 0 0 +cpu12 1437 0 461 967933 188 160 30 0 0 0 +cpu13 1871 0 838 967145 144 161 36 0 0 0 +cpu14 2195 0 1229 966266 198 195 47 0 0 0 +cpu15 1678 0 440 967703 204 149 35 0 0 0 +intr 20906479 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 73 0 1 1 1 1 0 1 0 1 0 1 0 0 75 2293 0 0 0 0 0 0 0 0 194491 0 0 0 0 0 0 0 0 127 126 30931 25097 23368 23289 13177 15355 14638 14865 16237 15868 15531 15929 30489 26183 21121 22437 143 424 457 171 34 31 223 88 435 30 51 73 1713 216 116 92 0 0 0 0 707 0 0 842993 0 129196 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 28964860 +btime 1784274102 +processes 6861 +procs_running 2 +procs_blocked 1 +softirq 4988227 195425 921067 207 218639 267 0 30784 2839132 5 782701 diff --git a/plugins/inputs/cpu/testcases/default/proc1/expected.out b/plugins/inputs/cpu/testcases/default/proc1/expected.out new file mode 100644 index 0000000000000..f44748ec0d34b --- /dev/null +++ b/plugins/inputs/cpu/testcases/default/proc1/expected.out @@ -0,0 +1,17 @@ +cpu,cpu=cpu0 usage_guest=0,usage_guest_nice=0,usage_idle=98.99208959203628,usage_iowait=0.03393637737251638,usage_irq=0.10245553930559709,usage_nice=0,usage_softirq=0.14027035980640107,usage_steal=0,usage_system=0.3120530700301387,usage_user=0.41919506144908336 1784292355882553116 +cpu,cpu=cpu1 usage_guest=0,usage_guest_nice=0,usage_idle=96.71762902831654,usage_iowait=0.0775197562092677,usage_irq=0.18060970340196816,usage_nice=0,usage_softirq=0.052596911833010455,usage_steal=0,usage_system=1.1629581797908097,usage_user=1.8086864204483846 1784292355882553116 +cpu,cpu=cpu2 usage_guest=0,usage_guest_nice=0,usage_idle=96.65156247471397,usage_iowait=0.0867412166426618,usage_irq=0.19484407618985972,usage_nice=0,usage_softirq=0.05744987296295698,usage_steal=0,usage_system=1.2850970174615248,usage_user=1.7243053420290329 1784292355882553116 +cpu,cpu=cpu3 usage_guest=0,usage_guest_nice=0,usage_idle=98.58557741579335,usage_iowait=0.06853887722327023,usage_irq=0.14871643171086937,usage_nice=0,usage_softirq=0.04639306076197773,usage_steal=0,usage_system=0.4925423558945859,usage_user=0.6582318586159349 1784292355882553116 +cpu,cpu=cpu4 usage_guest=0,usage_guest_nice=0,usage_idle=99.72212175620339,usage_iowait=0.01001072115943526,usage_irq=0.031162406189854924,usage_nice=0,usage_softirq=0.008719015203379098,usage_steal=0,usage_system=0.09542477750364903,usage_user=0.13256132374026372 1784292355882553116 +cpu,cpu=cpu5 usage_guest=0,usage_guest_nice=0,usage_idle=99.67625783116969,usage_iowait=0.014209132597041924,usage_irq=0.03406962474972551,usage_nice=0,usage_softirq=0.007588968546147389,usage_steal=0,usage_system=0.11496480010333919,usage_user=0.15290964283407615 1784292355882553116 +cpu,cpu=cpu6 usage_guest=0,usage_guest_nice=0,usage_idle=99.45207204937653,usage_iowait=0.020831920315482477,usage_irq=0.04053342635027987,usage_nice=0,usage_softirq=0.00904331424548077,usage_steal=0,usage_system=0.2738832314345604,usage_user=0.20363605827770087 1784292355882553116 +cpu,cpu=cpu7 usage_guest=0,usage_guest_nice=0,usage_idle=99.7349047465289,usage_iowait=0.011301259283177269,usage_irq=0.02857604133031966,usage_nice=0,usage_softirq=0.0056506296415886345,usage_steal=0,usage_system=0.09686793671294801,usage_user=0.12269938650306744 1784292355882553116 +cpu,cpu=cpu8 usage_guest=0,usage_guest_nice=0,usage_idle=99.20501551189243,usage_iowait=0.02843846949327817,usage_irq=0.09565667011375388,usage_nice=0,usage_softirq=0.013411323681489137,usage_steal=0,usage_system=0.2562693898655636,usage_user=0.4012086349534643 1784292355882553116 +cpu,cpu=cpu9 usage_guest=0,usage_guest_nice=0,usage_idle=97.62095294446681,usage_iowait=0.0460742328640228,usage_irq=0.12399626879545789,usage_nice=0,usage_softirq=0.022471292519646215,usage_steal=0,usage_system=0.7148780972796803,usage_user=1.4716271640743848 1784292355882553116 +cpu,cpu=cpu10 usage_guest=0,usage_guest_nice=0,usage_idle=96.8662847941332,usage_iowait=0.060465845689221705,usage_irq=0.8138638160415562,usage_nice=0,usage_softirq=0.026514435008107913,usage_steal=0,usage_system=0.7482244220580698,usage_user=1.4846466870698471 1784292355882553116 +cpu,cpu=cpu11 usage_guest=0,usage_guest_nice=0,usage_idle=98.5089781439672,usage_iowait=0.030557702319475136,usage_irq=0.2554559241522259,usage_nice=0,usage_softirq=0.20905348729672668,usage_steal=0,usage_system=0.46143747312053973,usage_user=0.5345172691438347 1784292355882553116 +cpu,cpu=cpu12 usage_guest=0,usage_guest_nice=0,usage_idle=99.76752145583231,usage_iowait=0.005004746436943426,usage_irq=0.024377958450917968,usage_nice=0,usage_softirq=0.00452041613659406,usage_steal=0,usage_system=0.09767327723712167,usage_user=0.10090214590611747 1784292355882553116 +cpu,cpu=cpu13 usage_guest=0,usage_guest_nice=0,usage_idle=99.77720338586276,usage_iowait=0.006296426051704963,usage_irq=0.023571235988433952,usage_nice=0,usage_softirq=0.004359064189641896,usage_steal=0,usage_system=0.07006792067794752,usage_user=0.11850196722952414 1784292355882553116 +cpu,cpu=cpu14 usage_guest=0,usage_guest_nice=0,usage_idle=99.61752692164872,usage_iowait=0.0074266617155588546,usage_irq=0.027123460178562774,usage_nice=0,usage_softirq=0.005812170038263452,usage_steal=0,usage_system=0.18050016952162606,usage_user=0.16161061689726988 1784292355882553116 +cpu,cpu=cpu15 usage_guest=0,usage_guest_nice=0,usage_idle=99.7826988926684,usage_iowait=0.005489032428880703,usage_irq=0.0230862246273512,usage_nice=0,usage_softirq=0.004358937517052325,usage_steal=0,usage_system=0.07022732666362078,usage_user=0.11413958609466643 1784292355882553116 +cpu,cpu=cpu-total usage_guest=0,usage_guest_nice=0,usage_idle=98.79324440645692,usage_iowait=0.0320620665057134,usage_irq=0.13419615804548835,usage_nice=0.000010098288663216828,usage_softirq=0.0386057575594779,usage_steal=0,usage_system=0.40175031617741797,usage_user=0.6001311969663126 1784292355882553116 diff --git a/plugins/inputs/cpu/testcases/default/proc1/stat b/plugins/inputs/cpu/testcases/default/proc1/stat new file mode 100644 index 0000000000000..6a4a2aa8bce1d --- /dev/null +++ b/plugins/inputs/cpu/testcases/default/proc1/stat @@ -0,0 +1,24 @@ +cpu 170115 31 75832 25125520 9906 29247 7444 0 0 0 +cpu0 7600 0 3991 1572632 677 1375 2088 0 0 0 +cpu1 29604 4 12656 1540003 1309 2340 741 0 0 0 +cpu2 28475 10 12200 1541696 1479 2420 644 0 0 0 +cpu3 12014 0 6051 1565994 1059 2100 800 0 0 0 +cpu4 2776 0 1116 1584862 189 378 118 0 0 0 +cpu5 3092 0 1753 1583644 295 475 116 0 0 0 +cpu6 3911 0 3121 1581128 418 536 135 0 0 0 +cpu7 2524 0 1166 1585171 267 376 87 0 0 0 +cpu8 7634 0 3463 1575436 599 1246 192 0 0 0 +cpu9 24756 13 10483 1549626 929 1645 318 0 0 0 +cpu10 27770 0 8740 1537236 1016 12599 361 0 0 0 +cpu11 9702 0 5526 1567955 774 2476 1571 0 0 0 +cpu12 2062 0 1066 1585905 219 311 58 0 0 0 +cpu13 2605 0 1272 1585164 183 307 63 0 0 0 +cpu14 3196 0 2347 1583287 244 363 83 0 0 0 +cpu15 2385 0 875 1585774 238 292 62 0 0 0 +intr 45048657 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 123 0 1 1 1 1 0 1 0 1 0 1 0 0 77 21045 0 0 0 0 0 0 0 0 302128 0 0 0 0 0 0 0 0 177 175 71569 54574 43086 34410 14401 16556 16569 15788 19087 18385 16613 16948 63242 44624 30094 30833 143 424 457 171 34 31 223 88 460 41 52 75 1713 216 116 92 0 0 0 0 707 0 0 1365814 0 3353162 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 63952662 +btime 1784274102 +processes 37029 +procs_running 2 +procs_blocked 1 +softirq 13952814 321794 1531238 314 5602346 366 0 34044 5070960 10007 1381745 diff --git a/plugins/inputs/cpu/testcases/default/telegraf.conf b/plugins/inputs/cpu/testcases/default/telegraf.conf new file mode 100644 index 0000000000000..8658a2610202c --- /dev/null +++ b/plugins/inputs/cpu/testcases/default/telegraf.conf @@ -0,0 +1 @@ +[[inputs.cpu]]