Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(inputs.cgroup): Added support for cpu.stat #12798

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/inputs/cgroup/cgroup_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ type fileFormat struct {
parser func(measurement string, fields map[string]interface{}, b []byte)
}

const keyPattern = "[[:alnum:]:_]+"
const keyPattern = "[[:alnum:]:_.]+"
const valuePattern = "[\\d-]+"

var fileFormats = [...]fileFormat{
Expand Down
17 changes: 12 additions & 5 deletions plugins/inputs/cgroup/cgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ func TestCgroupStatistics_2(t *testing.T) {

var cg = &CGroup{
Paths: []string{"testdata/cpu"},
Files: []string{"cpuacct.usage_percpu"},
Files: []string{
"cpuacct.usage_percpu",
"cpu.stat",
},
}

require.NoError(t, acc.GatherError(cg.Gather))
Expand All @@ -70,10 +73,14 @@ func TestCgroupStatistics_2(t *testing.T) {
"path": "testdata/cpu",
},
map[string]interface{}{
"cpuacct.usage_percpu.0": int64(-1452543795404),
"cpuacct.usage_percpu.1": int64(1376681271659),
"cpuacct.usage_percpu.2": int64(1450950799997),
"cpuacct.usage_percpu.3": int64(-1473113374257),
"cpu.stat.core_sched.force_idle_usec": int64(0),
"cpu.stat.system_usec": int64(103537582650),
"cpu.stat.usage_usec": int64(614953149468),
"cpu.stat.user_usec": int64(511415566817),
"cpuacct.usage_percpu.0": int64(-1452543795404),
"cpuacct.usage_percpu.1": int64(1376681271659),
"cpuacct.usage_percpu.2": int64(1450950799997),
"cpuacct.usage_percpu.3": int64(-1473113374257),
},
time.Unix(0, 0),
),
Expand Down
4 changes: 4 additions & 0 deletions plugins/inputs/cgroup/testdata/cpu/cpu.stat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
usage_usec 614953149468
user_usec 511415566817
system_usec 103537582650
core_sched.force_idle_usec 0