Add Linux NUMA "numastat" metrics (#249)
* Add Linux NUMA "numastat" metrics Read the `numastat` metrics from /sys/devices/system/node/node* when reading NUMA meminfo metrics. * Update end-to-end test output. * Add `numastat` metrics as counters. * Add tests for error conditions. * Refactor meminfo numa metrics struct * Refactor meminfoKey into a simple struct of metric data. This makes it easier to pass slices of metrics around. * Refactor tests. * Fixup: Add suggested fixes. * Fixup: More fixes * Add another scanner.Err() return * Add "_total" to counter metrics.
This commit is contained in:
parent
081ecc5db0
commit
c6162312f2
5 changed files with 158 additions and 26 deletions
|
|
@ -30,11 +30,15 @@ func TestMemInfoNuma(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := 707915776.0, memInfo[meminfoKey{"Active_anon", "0"}]; want != got {
|
||||
t.Errorf("want memory Active(anon) %f, got %f", want, got)
|
||||
if want, got := 707915776.0, memInfo[5].value; want != got {
|
||||
t.Errorf("want memory Active(anon) value %f, got %f", want, got)
|
||||
}
|
||||
|
||||
if want, got := 150994944.0, memInfo[meminfoKey{"AnonHugePages", "0"}]; want != got {
|
||||
if want, got := "Active_anon", memInfo[5].metricName; want != got {
|
||||
t.Errorf("want metric Active(anon) metricName %s, got %s", want, got)
|
||||
}
|
||||
|
||||
if want, got := 150994944.0, memInfo[25].value; want != got {
|
||||
t.Errorf("want memory AnonHugePages %f, got %f", want, got)
|
||||
}
|
||||
|
||||
|
|
@ -49,11 +53,55 @@ func TestMemInfoNuma(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := 291930112.0, memInfo[meminfoKey{"Inactive_anon", "1"}]; want != got {
|
||||
if want, got := 291930112.0, memInfo[6].value; want != got {
|
||||
t.Errorf("want memory Inactive(anon) %f, got %f", want, got)
|
||||
}
|
||||
|
||||
if want, got := 85585088512.0, memInfo[meminfoKey{"FilePages", "1"}]; want != got {
|
||||
if want, got := 85585088512.0, memInfo[13].value; want != got {
|
||||
t.Errorf("want memory FilePages %f, got %f", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMemInfoNumaStat(t *testing.T) {
|
||||
file, err := os.Open("fixtures/sys/devices/system/node/node0/numastat")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
numaStat, err := parseMemInfoNumaStat(file, "0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := 193460335812.0, numaStat[0].value; want != got {
|
||||
t.Errorf("want numa stat numa_hit value %f, got %f", want, got)
|
||||
}
|
||||
|
||||
if want, got := "numa_hit_total", numaStat[0].metricName; want != got {
|
||||
t.Errorf("want numa stat numa_hit metricName %s, got %s", want, got)
|
||||
}
|
||||
|
||||
if want, got := 193454780853.0, numaStat[4].value; want != got {
|
||||
t.Errorf("want numa stat local_node %f, got %f", want, got)
|
||||
}
|
||||
|
||||
file, err = os.Open("fixtures/sys/devices/system/node/node1/numastat")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
numaStat, err = parseMemInfoNumaStat(file, "1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := 59858626709.0, numaStat[1].value; want != got {
|
||||
t.Errorf("want numa stat numa_miss %f, got %f", want, got)
|
||||
}
|
||||
|
||||
if want, got := 59860526920.0, numaStat[5].value; want != got {
|
||||
t.Errorf("want numa stat other_node %f, got %f", want, got)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue