Document and add support to input plugins for logging alias (#6357)
This commit is contained in:
@@ -5,7 +5,6 @@ package win_perf_counters
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -147,6 +146,8 @@ type Win_PerfCounters struct {
|
||||
CountersRefreshInterval internal.Duration
|
||||
UseWildcardsExpansion bool
|
||||
|
||||
Log telegraf.Logger
|
||||
|
||||
lastRefreshed time.Time
|
||||
counters []*counter
|
||||
query PerformanceQuery
|
||||
@@ -289,7 +290,7 @@ func (m *Win_PerfCounters) AddItem(counterPath string, objectName string, instan
|
||||
m.counters = append(m.counters, newItem)
|
||||
|
||||
if m.PrintValid {
|
||||
log.Printf("Valid: %s\n", counterPath)
|
||||
m.Log.Infof("Valid: %s", counterPath)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -297,7 +298,7 @@ func (m *Win_PerfCounters) AddItem(counterPath string, objectName string, instan
|
||||
includeTotal, counterHandle}
|
||||
m.counters = append(m.counters, newItem)
|
||||
if m.PrintValid {
|
||||
log.Printf("Valid: %s\n", counterPath)
|
||||
m.Log.Infof("Valid: %s", counterPath)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +324,7 @@ func (m *Win_PerfCounters) ParseConfig() error {
|
||||
|
||||
if err != nil {
|
||||
if PerfObject.FailOnMissing || PerfObject.WarnOnMissing {
|
||||
log.Printf("Invalid counterPath: '%s'. Error: %s\n", counterPath, err.Error())
|
||||
m.Log.Errorf("Invalid counterPath: '%s'. Error: %s\n", counterPath, err.Error())
|
||||
}
|
||||
if PerfObject.FailOnMissing {
|
||||
return err
|
||||
|
||||
@@ -247,13 +247,17 @@ func TestCounterPathParsing(t *testing.T) {
|
||||
func TestAddItemSimple(t *testing.T) {
|
||||
var err error
|
||||
cps1 := []string{"\\O(I)\\C"}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: nil, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1}, []uint32{0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: cps1,
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: nil,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1}, []uint32{0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: cps1,
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.AddItem(cps1[0], "O", "I", "c", "test", false)
|
||||
@@ -265,13 +269,18 @@ func TestAddItemSimple(t *testing.T) {
|
||||
func TestAddItemInvalidCountPath(t *testing.T) {
|
||||
var err error
|
||||
cps1 := []string{"\\O\\C"}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: nil, UseWildcardsExpansion: true, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1}, []uint32{0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {"\\O/C"},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: nil,
|
||||
UseWildcardsExpansion: true,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1}, []uint32{0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {"\\O/C"},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.AddItem("\\O\\C", "O", "------", "C", "test", false)
|
||||
@@ -284,16 +293,20 @@ func TestParseConfigBasic(t *testing.T) {
|
||||
var err error
|
||||
perfObjects := createPerfObject("m", "O", []string{"I1", "I2"}, []string{"C1", "C2"}, false, false)
|
||||
cps1 := []string{"\\O(I1)\\C1", "\\O(I1)\\C2", "\\O(I2)\\C1", "\\O(I2)\\C2"}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1, 1.2, 1.3, 1.4}, []uint32{0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
cps1[2]: {cps1[2]},
|
||||
cps1[3]: {cps1[3]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1, 1.2, 1.3, 1.4}, []uint32{0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
cps1[2]: {cps1[2]},
|
||||
cps1[3]: {cps1[3]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.ParseConfig()
|
||||
@@ -318,14 +331,19 @@ func TestParseConfigNoInstance(t *testing.T) {
|
||||
var err error
|
||||
perfObjects := createPerfObject("m", "O", []string{"------"}, []string{"C1", "C2"}, false, false)
|
||||
cps1 := []string{"\\O\\C1", "\\O\\C2"}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, UseWildcardsExpansion: false, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1, 1.2}, []uint32{0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
UseWildcardsExpansion: false,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1, 1.2}, []uint32{0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.ParseConfig()
|
||||
@@ -350,15 +368,19 @@ func TestParseConfigInvalidCounterError(t *testing.T) {
|
||||
var err error
|
||||
perfObjects := createPerfObject("m", "O", []string{"I1", "I2"}, []string{"C1", "C2"}, true, false)
|
||||
cps1 := []string{"\\O(I1)\\C2", "\\O(I2)\\C1", "\\O(I2)\\C2"}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1, 1.2, 1.3}, []uint32{0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
cps1[2]: {cps1[2]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1, 1.2, 1.3}, []uint32{0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
cps1[2]: {cps1[2]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.ParseConfig()
|
||||
@@ -381,15 +403,19 @@ func TestParseConfigInvalidCounterNoError(t *testing.T) {
|
||||
var err error
|
||||
perfObjects := createPerfObject("m", "O", []string{"I1", "I2"}, []string{"C1", "C2"}, false, false)
|
||||
cps1 := []string{"\\O(I1)\\C2", "\\O(I2)\\C1", "\\O(I2)\\C2"}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1, 1.2, 1.3}, []uint32{0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
cps1[2]: {cps1[2]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.1, 1.2, 1.3}, []uint32{0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
cps1[2]: {cps1[2]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.ParseConfig()
|
||||
@@ -413,13 +439,18 @@ func TestParseConfigTotalExpansion(t *testing.T) {
|
||||
var err error
|
||||
perfObjects := createPerfObject("m", "O", []string{"*"}, []string{"*"}, true, true)
|
||||
cps1 := []string{"\\O(I1)\\C1", "\\O(I1)\\C2", "\\O(_Total)\\C1", "\\O(_Total)\\C2"}
|
||||
m := Win_PerfCounters{PrintValid: false, UseWildcardsExpansion: true, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(append(cps1, "\\O(*)\\*"), []float64{1.1, 1.2, 1.3, 1.4, 0}, []uint32{0, 0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
"\\O(*)\\*": cps1,
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
UseWildcardsExpansion: true,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(append(cps1, "\\O(*)\\*"), []float64{1.1, 1.2, 1.3, 1.4, 0}, []uint32{0, 0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
"\\O(*)\\*": cps1,
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.ParseConfig()
|
||||
@@ -430,13 +461,18 @@ func TestParseConfigTotalExpansion(t *testing.T) {
|
||||
|
||||
perfObjects[0].IncludeTotal = false
|
||||
|
||||
m = Win_PerfCounters{PrintValid: false, UseWildcardsExpansion: true, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(append(cps1, "\\O(*)\\*"), []float64{1.1, 1.2, 1.3, 1.4, 0}, []uint32{0, 0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
"\\O(*)\\*": cps1,
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m = Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
UseWildcardsExpansion: true,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(append(cps1, "\\O(*)\\*"), []float64{1.1, 1.2, 1.3, 1.4, 0}, []uint32{0, 0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
"\\O(*)\\*": cps1,
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.ParseConfig()
|
||||
@@ -450,13 +486,18 @@ func TestParseConfigExpand(t *testing.T) {
|
||||
var err error
|
||||
perfObjects := createPerfObject("m", "O", []string{"*"}, []string{"*"}, false, false)
|
||||
cps1 := []string{"\\O(I1)\\C1", "\\O(I1)\\C2", "\\O(I2)\\C1", "\\O(I2)\\C2"}
|
||||
m := Win_PerfCounters{PrintValid: false, UseWildcardsExpansion: true, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(append(cps1, "\\O(*)\\*"), []float64{1.1, 1.2, 1.3, 1.4, 0}, []uint32{0, 0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
"\\O(*)\\*": cps1,
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
UseWildcardsExpansion: true,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(append(cps1, "\\O(*)\\*"), []float64{1.1, 1.2, 1.3, 1.4, 0}, []uint32{0, 0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
"\\O(*)\\*": cps1,
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
err = m.query.Open()
|
||||
require.NoError(t, err)
|
||||
err = m.ParseConfig()
|
||||
@@ -474,13 +515,17 @@ func TestSimpleGather(t *testing.T) {
|
||||
measurement := "test"
|
||||
perfObjects := createPerfObject(measurement, "O", []string{"I"}, []string{"C"}, false, false)
|
||||
cp1 := "\\O(I)\\C"
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap([]string{cp1}, []float64{1.2}, []uint32{0}),
|
||||
expandPaths: map[string][]string{
|
||||
cp1: {cp1},
|
||||
},
|
||||
vistaAndNewer: false,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap([]string{cp1}, []float64{1.2}, []uint32{0}),
|
||||
expandPaths: map[string][]string{
|
||||
cp1: {cp1},
|
||||
},
|
||||
vistaAndNewer: false,
|
||||
}}
|
||||
var acc1 testutil.Accumulator
|
||||
err = m.Gather(&acc1)
|
||||
require.NoError(t, err)
|
||||
@@ -513,13 +558,17 @@ func TestSimpleGatherNoData(t *testing.T) {
|
||||
measurement := "test"
|
||||
perfObjects := createPerfObject(measurement, "O", []string{"I"}, []string{"C"}, false, false)
|
||||
cp1 := "\\O(I)\\C"
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap([]string{cp1}, []float64{1.2}, []uint32{PDH_NO_DATA}),
|
||||
expandPaths: map[string][]string{
|
||||
cp1: {cp1},
|
||||
},
|
||||
vistaAndNewer: false,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap([]string{cp1}, []float64{1.2}, []uint32{PDH_NO_DATA}),
|
||||
expandPaths: map[string][]string{
|
||||
cp1: {cp1},
|
||||
},
|
||||
vistaAndNewer: false,
|
||||
}}
|
||||
var acc1 testutil.Accumulator
|
||||
err = m.Gather(&acc1)
|
||||
// this "PDH_NO_DATA" error should not be returned to caller, but checked, and handled
|
||||
@@ -555,13 +604,18 @@ func TestSimpleGatherWithTimestamp(t *testing.T) {
|
||||
measurement := "test"
|
||||
perfObjects := createPerfObject(measurement, "O", []string{"I"}, []string{"C"}, false, false)
|
||||
cp1 := "\\O(I)\\C"
|
||||
m := Win_PerfCounters{PrintValid: false, UsePerfCounterTime: true, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap([]string{cp1}, []float64{1.2}, []uint32{0}),
|
||||
expandPaths: map[string][]string{
|
||||
cp1: {cp1},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
UsePerfCounterTime: true,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap([]string{cp1}, []float64{1.2}, []uint32{0}),
|
||||
expandPaths: map[string][]string{
|
||||
cp1: {cp1},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
var acc1 testutil.Accumulator
|
||||
err = m.Gather(&acc1)
|
||||
require.NoError(t, err)
|
||||
@@ -586,13 +640,17 @@ func TestGatherError(t *testing.T) {
|
||||
measurement := "test"
|
||||
perfObjects := createPerfObject(measurement, "O", []string{"I"}, []string{"C"}, false, false)
|
||||
cp1 := "\\O(I)\\C"
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap([]string{cp1}, []float64{-2}, []uint32{PDH_PLA_VALIDATION_WARNING}),
|
||||
expandPaths: map[string][]string{
|
||||
cp1: {cp1},
|
||||
},
|
||||
vistaAndNewer: false,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap([]string{cp1}, []float64{-2}, []uint32{PDH_PLA_VALIDATION_WARNING}),
|
||||
expandPaths: map[string][]string{
|
||||
cp1: {cp1},
|
||||
},
|
||||
vistaAndNewer: false,
|
||||
}}
|
||||
var acc1 testutil.Accumulator
|
||||
err = m.Gather(&acc1)
|
||||
require.Error(t, err)
|
||||
@@ -617,15 +675,19 @@ func TestGatherInvalidDataIgnore(t *testing.T) {
|
||||
measurement := "test"
|
||||
perfObjects := createPerfObject(measurement, "O", []string{"I"}, []string{"C1", "C2", "C3"}, false, false)
|
||||
cps1 := []string{"\\O(I)\\C1", "\\O(I)\\C2", "\\O(I)\\C3"}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.2, 1, 0}, []uint32{0, PDH_INVALID_DATA, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
cps1[2]: {cps1[2]},
|
||||
},
|
||||
vistaAndNewer: false,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(cps1, []float64{1.2, 1, 0}, []uint32{0, PDH_INVALID_DATA, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
cps1[0]: {cps1[0]},
|
||||
cps1[1]: {cps1[1]},
|
||||
cps1[2]: {cps1[2]},
|
||||
},
|
||||
vistaAndNewer: false,
|
||||
}}
|
||||
var acc1 testutil.Accumulator
|
||||
err = m.Gather(&acc1)
|
||||
require.NoError(t, err)
|
||||
@@ -666,7 +728,14 @@ func TestGatherRefreshingWithExpansion(t *testing.T) {
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, UseWildcardsExpansion: true, query: fpm, CountersRefreshInterval: internal.Duration{Duration: time.Second * 10}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
UseWildcardsExpansion: true,
|
||||
query: fpm,
|
||||
CountersRefreshInterval: internal.Duration{Duration: time.Second * 10},
|
||||
}
|
||||
var acc1 testutil.Accumulator
|
||||
err = m.Gather(&acc1)
|
||||
assert.Len(t, m.counters, 4)
|
||||
@@ -752,7 +821,13 @@ func TestGatherRefreshingWithoutExpansion(t *testing.T) {
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}
|
||||
m := Win_PerfCounters{PrintValid: false, Object: perfObjects, UseWildcardsExpansion: false, query: fpm, CountersRefreshInterval: internal.Duration{Duration: time.Second * 10}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
Object: perfObjects,
|
||||
UseWildcardsExpansion: false,
|
||||
query: fpm,
|
||||
CountersRefreshInterval: internal.Duration{Duration: time.Second * 10}}
|
||||
var acc1 testutil.Accumulator
|
||||
err = m.Gather(&acc1)
|
||||
assert.Len(t, m.counters, 2)
|
||||
@@ -862,14 +937,19 @@ func TestGatherTotalNoExpansion(t *testing.T) {
|
||||
measurement := "m"
|
||||
perfObjects := createPerfObject(measurement, "O", []string{"*"}, []string{"C1", "C2"}, true, true)
|
||||
cps1 := []string{"\\O(I1)\\C1", "\\O(I1)\\C2", "\\O(_Total)\\C1", "\\O(_Total)\\C2"}
|
||||
m := Win_PerfCounters{PrintValid: false, UseWildcardsExpansion: false, Object: perfObjects, query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(append([]string{"\\O(*)\\C1", "\\O(*)\\C2"}, cps1...), []float64{0, 0, 1.1, 1.2, 1.3, 1.4}, []uint32{0, 0, 0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
"\\O(*)\\C1": {cps1[0], cps1[2]},
|
||||
"\\O(*)\\C2": {cps1[1], cps1[3]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
m := Win_PerfCounters{
|
||||
Log: testutil.Logger{},
|
||||
PrintValid: false,
|
||||
UseWildcardsExpansion: false,
|
||||
Object: perfObjects,
|
||||
query: &FakePerformanceQuery{
|
||||
counters: createCounterMap(append([]string{"\\O(*)\\C1", "\\O(*)\\C2"}, cps1...), []float64{0, 0, 1.1, 1.2, 1.3, 1.4}, []uint32{0, 0, 0, 0, 0, 0}),
|
||||
expandPaths: map[string][]string{
|
||||
"\\O(*)\\C1": {cps1[0], cps1[2]},
|
||||
"\\O(*)\\C2": {cps1[1], cps1[3]},
|
||||
},
|
||||
vistaAndNewer: true,
|
||||
}}
|
||||
var acc1 testutil.Accumulator
|
||||
err = m.Gather(&acc1)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user