feat(inputs.win_perf_counters): add remote system support (#12556)
This commit is contained in:
parent
d3e1f95b87
commit
2529d5fa16
|
|
@ -26,6 +26,20 @@ For more information on concepts and terminology including object,
|
|||
counter, and instance names, see the help in the Windows Performance
|
||||
Monitor app.
|
||||
|
||||
### Schema
|
||||
|
||||
*Measurement name* is specified per performance object
|
||||
or `win_perf_counters` by default.
|
||||
|
||||
*Tags:*
|
||||
|
||||
- source - computer name, as specified in the `Sources` parameter. Name `localhost` is translated into the host name
|
||||
- objectname - normalized name of the performance object
|
||||
- instance - instance name, if performance object supports multiple instances, otherwise omitted
|
||||
|
||||
*Fields* are counters of the performance object.
|
||||
The field name is normalized counter name.
|
||||
|
||||
### Plugin wide
|
||||
|
||||
Plugin wide entries are underneath `[[inputs.win_perf_counters]]`.
|
||||
|
|
@ -124,6 +138,27 @@ errors](pdh.go).
|
|||
Example:
|
||||
`IgnoredErrors=["PDH_NO_DATA"]`
|
||||
|
||||
#### Sources
|
||||
|
||||
(Optional)
|
||||
|
||||
Host names or ip addresses of computers to gather all performance counters from.
|
||||
The user running Telegraf must be authenticated to the remote computer(s).
|
||||
E.g. via Windows sharing `net use \\SQL-SERVER-01`.
|
||||
Use either localhost (`"localhost"`) or real local computer name to gather
|
||||
counters also from localhost among other computers. Skip, if gather only from
|
||||
localhost.
|
||||
|
||||
If a performance counter is present only on specific hosts set `Sources` param
|
||||
on the specific counter level configuration to override global (plugin wide)
|
||||
sources.
|
||||
|
||||
Example:
|
||||
`Sources = ["localhost", "SQL-SERVER-01", "SQL-SERVER-02", "SQL-SERVER-03"]`
|
||||
|
||||
Default:
|
||||
`Sources = ["localhost"]`
|
||||
|
||||
### Object
|
||||
|
||||
See Entry below.
|
||||
|
|
@ -181,6 +216,13 @@ This must be specified for every counter you want the results of, or use
|
|||
`["*"]` for all the counters of the object, if the `UseWildcardsExpansion` param
|
||||
is set to `true`.
|
||||
|
||||
#### Sources (Object)
|
||||
|
||||
(Optional)
|
||||
|
||||
Overrides the [Sources](#sources) global parameter for current performance
|
||||
object. See [Sources](#sources) description for more details.
|
||||
|
||||
#### Measurement
|
||||
|
||||
(Optional)
|
||||
|
|
@ -204,8 +246,17 @@ as seen in the Windows Performance Monitor.
|
|||
A field representing raw counter value has the `_Raw` suffix. Raw values should
|
||||
be further used in a calculation,
|
||||
e.g. `100-(non_negative_derivative("Percent_Processor_Time_Raw",1s)/100000`
|
||||
Note: Time based counters (i.e. _% Processor Time_) are reported in hundredths
|
||||
Note: Time based counters (i.e. *% Processor Time*) are reported in hundredths
|
||||
of nanoseconds.
|
||||
This key is optional. It is a simple bool.
|
||||
If set to `true`, counter values will be provided in the raw, integer, form.
|
||||
This is in contrast with the default behavior, where values are returned in a
|
||||
formatted, displayable, form as seen in the Windows Performance Monitor.
|
||||
A field representing raw counter value has the `_Raw` suffix.
|
||||
Raw values should be further used in a calculation,
|
||||
e.g. `100-(non_negative_derivative("Percent_Processor_Time_Raw",1s)/100000`
|
||||
Note: Time based counters (i.e. `% Processor Time`)
|
||||
are reported in hundredths of nanoseconds.
|
||||
|
||||
Example: `UseRawValues = true`
|
||||
|
||||
|
|
@ -623,11 +674,17 @@ to check the counter path on the command line. E.g. `typeperf
|
|||
If no metrics are emitted even with the default config, you may need to repair
|
||||
your performance counters.
|
||||
|
||||
1. Launch the Command Prompt as Administrator (right click Runs As Administrator).
|
||||
1. Drop into the C:\WINDOWS\System32 directory by typing `C:` then `cd \Windows\System32`
|
||||
1. Launch the Command Prompt as Administrator
|
||||
(right click "Runs As Administrator").
|
||||
1. Drop into the C:\WINDOWS\System32 directory by typing `C:` then
|
||||
`cd \Windows\System32`
|
||||
1. Rebuild your counter values, which may take a few moments so please be
|
||||
patient, by running:
|
||||
|
||||
```batchfile
|
||||
lodctr /r
|
||||
```
|
||||
|
||||
## Metrics
|
||||
|
||||
## Example Output
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ type PerformanceQuery interface {
|
|||
IsVistaOrNewer() bool
|
||||
}
|
||||
|
||||
type PerformanceQueryCreator interface {
|
||||
NewPerformanceQuery(string) PerformanceQuery
|
||||
}
|
||||
|
||||
// PdhError represents error returned from Performance Counters API
|
||||
type PdhError struct {
|
||||
ErrorCode uint32
|
||||
|
|
@ -55,6 +59,13 @@ type PerformanceQueryImpl struct {
|
|||
query PDH_HQUERY
|
||||
}
|
||||
|
||||
type PerformanceQueryCreatorImpl struct {
|
||||
}
|
||||
|
||||
func (m PerformanceQueryCreatorImpl) NewPerformanceQuery(string) PerformanceQuery {
|
||||
return &PerformanceQueryImpl{}
|
||||
}
|
||||
|
||||
// Open creates a new counterPath that is used to manage the collection of performance data.
|
||||
// It returns counterPath handle used for subsequent calls for adding counters and querying data
|
||||
func (m *PerformanceQueryImpl) Open() error {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ import (
|
|||
_ "embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
|
|
@ -18,7 +20,7 @@ import (
|
|||
//go:embed sample.conf
|
||||
var sampleConfig string
|
||||
|
||||
type Win_PerfCounters struct {
|
||||
type WinPerfCounters struct {
|
||||
PrintValid bool `toml:"PrintValid"`
|
||||
PreVistaSupport bool `toml:"PreVistaSupport" deprecated:"1.7.0;determined dynamically"`
|
||||
UsePerfCounterTime bool
|
||||
|
|
@ -27,15 +29,29 @@ type Win_PerfCounters struct {
|
|||
UseWildcardsExpansion bool
|
||||
LocalizeWildcardsExpansion bool
|
||||
IgnoredErrors []string `toml:"IgnoredErrors"`
|
||||
Sources []string
|
||||
|
||||
Log telegraf.Logger
|
||||
|
||||
lastRefreshed time.Time
|
||||
counters []*counter
|
||||
query PerformanceQuery
|
||||
queryCreator PerformanceQueryCreator
|
||||
hostCounters map[string]*hostCountersInfo
|
||||
// cached os.Hostname()
|
||||
cachedHostname string
|
||||
}
|
||||
|
||||
type hostCountersInfo struct {
|
||||
// computer name used as key and for printing
|
||||
computer string
|
||||
// computer name used in tag
|
||||
tag string
|
||||
counters []*counter
|
||||
query PerformanceQuery
|
||||
timestamp time.Time
|
||||
}
|
||||
|
||||
type perfobject struct {
|
||||
Sources []string
|
||||
ObjectName string
|
||||
Counters []string
|
||||
Instances []string
|
||||
|
|
@ -48,6 +64,7 @@ type perfobject struct {
|
|||
|
||||
type counter struct {
|
||||
counterPath string
|
||||
computer string
|
||||
objectName string
|
||||
counter string
|
||||
instance string
|
||||
|
|
@ -63,20 +80,22 @@ type instanceGrouping struct {
|
|||
objectname string
|
||||
}
|
||||
|
||||
type fieldGrouping map[instanceGrouping]map[string]interface{}
|
||||
|
||||
var sanitizedChars = strings.NewReplacer("/sec", "_persec", "/Sec", "_persec",
|
||||
" ", "_", "%", "Percent", `\`, "")
|
||||
|
||||
// extractCounterInfoFromCounterPath gets object name, instance name (if available) and counter name from counter path
|
||||
// General Counter path pattern is: \\computer\object(parent/instance#index)\counter
|
||||
// parent/instance#index part is skipped in single instance objects (e.g. Memory): \\computer\object\counter
|
||||
func extractCounterInfoFromCounterPath(counterPath string) (object string, instance string, counter string, err error) {
|
||||
|
||||
func extractCounterInfoFromCounterPath(counterPath string) (string, string, string, string, error) {
|
||||
leftComputerBorderIndex := -1
|
||||
rightObjectBorderIndex := -1
|
||||
leftObjectBorderIndex := -1
|
||||
leftCounterBorderIndex := -1
|
||||
rightInstanceBorderIndex := -1
|
||||
leftInstanceBorderIndex := -1
|
||||
bracketLevel := 0
|
||||
var bracketLevel int
|
||||
|
||||
for i := len(counterPath) - 1; i >= 0; i-- {
|
||||
switch counterPath[i] {
|
||||
|
|
@ -86,6 +105,8 @@ func extractCounterInfoFromCounterPath(counterPath string) (object string, insta
|
|||
leftCounterBorderIndex = i
|
||||
} else if leftObjectBorderIndex == -1 {
|
||||
leftObjectBorderIndex = i
|
||||
} else if leftComputerBorderIndex == -1 {
|
||||
leftComputerBorderIndex = i
|
||||
}
|
||||
}
|
||||
case '(':
|
||||
|
|
@ -105,31 +126,46 @@ func extractCounterInfoFromCounterPath(counterPath string) (object string, insta
|
|||
rightObjectBorderIndex = leftCounterBorderIndex
|
||||
}
|
||||
if rightObjectBorderIndex == -1 || leftObjectBorderIndex == -1 {
|
||||
err = errors.New("cannot parse object from: " + counterPath)
|
||||
return
|
||||
return "", "", "", "", errors.New("cannot parse object from: " + counterPath)
|
||||
}
|
||||
|
||||
var computer, object, instance, counter string
|
||||
if leftComputerBorderIndex > -1 {
|
||||
// validate there is leading \\ and not empty computer (\\\O)
|
||||
if leftComputerBorderIndex != 1 || leftComputerBorderIndex == leftObjectBorderIndex-1 {
|
||||
return "", "", "", "", errors.New("cannot parse computer from: " + counterPath)
|
||||
}
|
||||
computer = counterPath[leftComputerBorderIndex+1 : leftObjectBorderIndex]
|
||||
}
|
||||
|
||||
if leftInstanceBorderIndex > -1 && rightInstanceBorderIndex > -1 {
|
||||
instance = counterPath[leftInstanceBorderIndex+1 : rightInstanceBorderIndex]
|
||||
} else if (leftInstanceBorderIndex == -1 && rightInstanceBorderIndex > -1) || (leftInstanceBorderIndex > -1 && rightInstanceBorderIndex == -1) {
|
||||
err = errors.New("cannot parse instance from: " + counterPath)
|
||||
return
|
||||
return "", "", "", "", errors.New("cannot parse instance from: " + counterPath)
|
||||
}
|
||||
object = counterPath[leftObjectBorderIndex+1 : rightObjectBorderIndex]
|
||||
counter = counterPath[leftCounterBorderIndex+1:]
|
||||
return
|
||||
return computer, object, instance, counter, nil
|
||||
}
|
||||
|
||||
func newCounter(
|
||||
counterHandle PDH_HCOUNTER,
|
||||
counterPath string,
|
||||
objectName string,
|
||||
instance string,
|
||||
counterName string,
|
||||
measurement string,
|
||||
includeTotal bool,
|
||||
useRawValue bool,
|
||||
) *counter {
|
||||
func (m *WinPerfCounters) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (m *WinPerfCounters) hostname() string {
|
||||
if m.cachedHostname != "" {
|
||||
return m.cachedHostname
|
||||
}
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
m.cachedHostname = "localhost"
|
||||
} else {
|
||||
m.cachedHostname = hostname
|
||||
}
|
||||
return m.cachedHostname
|
||||
}
|
||||
|
||||
func newCounter(counterHandle PDH_HCOUNTER, counterPath string, computer string, objectName string, instance string, counterName string, measurement string, includeTotal bool, useRawValue bool) *counter {
|
||||
measurementName := sanitizedChars.Replace(measurement)
|
||||
if measurementName == "" {
|
||||
measurementName = "win_perf_counters"
|
||||
|
|
@ -138,59 +174,68 @@ func newCounter(
|
|||
if useRawValue {
|
||||
newCounterName += "_Raw"
|
||||
}
|
||||
return &counter{counterPath, objectName, newCounterName, instance, measurementName,
|
||||
return &counter{counterPath, computer, objectName, newCounterName, instance, measurementName,
|
||||
includeTotal, useRawValue, counterHandle}
|
||||
}
|
||||
|
||||
func (*Win_PerfCounters) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (m *Win_PerfCounters) AddItem(
|
||||
counterPath string,
|
||||
objectName string,
|
||||
instance string,
|
||||
counterName string,
|
||||
measurement string,
|
||||
includeTotal bool,
|
||||
useRawValue bool,
|
||||
) error {
|
||||
func (m *WinPerfCounters) AddItem(counterPath, computer, objectName, instance, counterName, measurement string, includeTotal bool, useRawValue bool) error {
|
||||
origCounterPath := counterPath
|
||||
var err error
|
||||
var counterHandle PDH_HCOUNTER
|
||||
if !m.query.IsVistaOrNewer() {
|
||||
counterHandle, err = m.query.AddCounterToQuery(counterPath)
|
||||
|
||||
sourceTag := computer
|
||||
if computer == "localhost" {
|
||||
sourceTag = m.hostname()
|
||||
}
|
||||
if m.hostCounters == nil {
|
||||
m.hostCounters = make(map[string]*hostCountersInfo)
|
||||
}
|
||||
hostCounter, ok := m.hostCounters[computer]
|
||||
if !ok {
|
||||
hostCounter = &hostCountersInfo{computer: computer, tag: sourceTag}
|
||||
m.hostCounters[computer] = hostCounter
|
||||
hostCounter.query = m.queryCreator.NewPerformanceQuery(computer)
|
||||
if err = hostCounter.query.Open(); err != nil {
|
||||
return err
|
||||
}
|
||||
hostCounter.counters = make([]*counter, 0)
|
||||
}
|
||||
|
||||
if !hostCounter.query.IsVistaOrNewer() {
|
||||
counterHandle, err = hostCounter.query.AddCounterToQuery(counterPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
counterHandle, err = m.query.AddEnglishCounterToQuery(counterPath)
|
||||
counterHandle, err = hostCounter.query.AddEnglishCounterToQuery(counterPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if m.UseWildcardsExpansion {
|
||||
origInstance := instance
|
||||
counterPath, err = m.query.GetCounterPath(counterHandle)
|
||||
counterPath, err = hostCounter.query.GetCounterPath(counterHandle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
counters, err := m.query.ExpandWildCardPath(counterPath)
|
||||
counters, err := hostCounter.query.ExpandWildCardPath(counterPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
origObjectName, _, origCounterName, err := extractCounterInfoFromCounterPath(origCounterPath)
|
||||
_, origObjectName, _, origCounterName, err := extractCounterInfoFromCounterPath(origCounterPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, counterPath := range counters {
|
||||
var err error
|
||||
_, err := hostCounter.query.AddCounterToQuery(counterPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
objectName, instance, counterName, err = extractCounterInfoFromCounterPath(counterPath)
|
||||
computer, objectName, instance, counterName, err = extractCounterInfoFromCounterPath(counterPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -209,11 +254,15 @@ func (m *Win_PerfCounters) AddItem(
|
|||
} else {
|
||||
newInstance = instance
|
||||
}
|
||||
counterPath = formatPath(origObjectName, newInstance, origCounterName)
|
||||
counterHandle, err = m.query.AddEnglishCounterToQuery(counterPath)
|
||||
counterPath = formatPath(computer, origObjectName, newInstance, origCounterName)
|
||||
counterHandle, err = hostCounter.query.AddEnglishCounterToQuery(counterPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newItem = newCounter(
|
||||
counterHandle,
|
||||
counterPath,
|
||||
computer,
|
||||
origObjectName, instance,
|
||||
origCounterName,
|
||||
measurement,
|
||||
|
|
@ -221,10 +270,14 @@ func (m *Win_PerfCounters) AddItem(
|
|||
useRawValue,
|
||||
)
|
||||
} else {
|
||||
counterHandle, err = m.query.AddCounterToQuery(counterPath)
|
||||
counterHandle, err = hostCounter.query.AddCounterToQuery(counterPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newItem = newCounter(
|
||||
counterHandle,
|
||||
counterPath,
|
||||
computer,
|
||||
objectName,
|
||||
instance,
|
||||
counterName,
|
||||
|
|
@ -238,7 +291,7 @@ func (m *Win_PerfCounters) AddItem(
|
|||
continue
|
||||
}
|
||||
|
||||
m.counters = append(m.counters, newItem)
|
||||
hostCounter.counters = append(hostCounter.counters, newItem)
|
||||
|
||||
if m.PrintValid {
|
||||
m.Log.Infof("Valid: %s", counterPath)
|
||||
|
|
@ -248,6 +301,7 @@ func (m *Win_PerfCounters) AddItem(
|
|||
newItem := newCounter(
|
||||
counterHandle,
|
||||
counterPath,
|
||||
computer,
|
||||
objectName,
|
||||
instance,
|
||||
counterName,
|
||||
|
|
@ -255,7 +309,7 @@ func (m *Win_PerfCounters) AddItem(
|
|||
includeTotal,
|
||||
useRawValue,
|
||||
)
|
||||
m.counters = append(m.counters, newItem)
|
||||
hostCounter.counters = append(hostCounter.counters, newItem)
|
||||
if m.PrintValid {
|
||||
m.Log.Infof("Valid: %s", counterPath)
|
||||
}
|
||||
|
|
@ -266,19 +320,41 @@ func (m *Win_PerfCounters) AddItem(
|
|||
|
||||
const emptyInstance = "------"
|
||||
|
||||
func formatPath(objectname string, instance string, counter string) string {
|
||||
func formatPath(computer, objectname, instance, counter string) string {
|
||||
path := ""
|
||||
if instance == emptyInstance {
|
||||
return "\\" + objectname + "\\" + counter
|
||||
path = fmt.Sprintf(`\%s\%s`, objectname, counter)
|
||||
} else {
|
||||
return "\\" + objectname + "(" + instance + ")\\" + counter
|
||||
path = fmt.Sprintf(`\%s(%s)\%s`, objectname, instance, counter)
|
||||
}
|
||||
if computer != "" && computer != "localhost" {
|
||||
path = fmt.Sprintf(`\\%s%s`, computer, path)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func (m *Win_PerfCounters) ParseConfig() error {
|
||||
func (m *WinPerfCounters) ParseConfig() error {
|
||||
var counterPath string
|
||||
|
||||
if len(m.Object) > 0 {
|
||||
for _, PerfObject := range m.Object {
|
||||
if len(m.Sources) == 0 {
|
||||
m.Sources = []string{"localhost"}
|
||||
}
|
||||
|
||||
if len(m.Object) <= 0 {
|
||||
err := errors.New("no performance objects configured")
|
||||
return err
|
||||
}
|
||||
|
||||
for _, PerfObject := range m.Object {
|
||||
computers := PerfObject.Sources
|
||||
if len(computers) == 0 {
|
||||
computers = m.Sources
|
||||
}
|
||||
for _, computer := range computers {
|
||||
if computer == "" {
|
||||
// localhost as a computer name in counter path doesn't work
|
||||
computer = "localhost"
|
||||
}
|
||||
for _, counter := range PerfObject.Counters {
|
||||
if len(PerfObject.Instances) == 0 {
|
||||
m.Log.Warnf("Missing 'Instances' param for object '%s'\n", PerfObject.ObjectName)
|
||||
|
|
@ -286,13 +362,12 @@ func (m *Win_PerfCounters) ParseConfig() error {
|
|||
for _, instance := range PerfObject.Instances {
|
||||
objectname := PerfObject.ObjectName
|
||||
|
||||
counterPath = formatPath(objectname, instance, counter)
|
||||
|
||||
err := m.AddItem(counterPath, objectname, instance, counter, PerfObject.Measurement, PerfObject.IncludeTotal, PerfObject.UseRawValues)
|
||||
counterPath = formatPath(computer, objectname, instance, counter)
|
||||
|
||||
err := m.AddItem(counterPath, computer, objectname, instance, counter, PerfObject.Measurement, PerfObject.IncludeTotal, PerfObject.UseRawValues)
|
||||
if err != nil {
|
||||
if PerfObject.FailOnMissing || PerfObject.WarnOnMissing {
|
||||
m.Log.Errorf("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
|
||||
|
|
@ -301,15 +376,12 @@ func (m *Win_PerfCounters) ParseConfig() error {
|
|||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
} else {
|
||||
err := errors.New("no performance objects configured")
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Win_PerfCounters) checkError(err error) error {
|
||||
func (m *WinPerfCounters) checkError(err error) error {
|
||||
if pdhErr, ok := err.(*PdhError); ok {
|
||||
for _, ignoredErrors := range m.IgnoredErrors {
|
||||
if PDHErrors[pdhErr.ErrorCode] == ignoredErrors {
|
||||
|
|
@ -322,54 +394,74 @@ func (m *Win_PerfCounters) checkError(err error) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (m *Win_PerfCounters) Gather(acc telegraf.Accumulator) error {
|
||||
func (m *WinPerfCounters) Gather(acc telegraf.Accumulator) error {
|
||||
// Parse the config once
|
||||
var err error
|
||||
|
||||
if m.lastRefreshed.IsZero() || (m.CountersRefreshInterval > 0 && m.lastRefreshed.Add(time.Duration(m.CountersRefreshInterval)).Before(time.Now())) {
|
||||
if m.counters != nil {
|
||||
m.counters = m.counters[:0]
|
||||
}
|
||||
|
||||
if err = m.query.Open(); err != nil {
|
||||
if err = m.cleanQueries(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = m.ParseConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
//some counters need two data samples before computing a value
|
||||
if err = m.query.CollectData(); err != nil {
|
||||
return m.checkError(err)
|
||||
for _, hostCounterSet := range m.hostCounters {
|
||||
//some counters need two data samples before computing a value
|
||||
if err = hostCounterSet.query.CollectData(); err != nil {
|
||||
return m.checkError(err)
|
||||
}
|
||||
}
|
||||
m.lastRefreshed = time.Now()
|
||||
|
||||
// minimum time between collecting two samples
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
var collectFields = make(map[instanceGrouping]map[string]interface{})
|
||||
|
||||
var timestamp time.Time
|
||||
if m.UsePerfCounterTime && m.query.IsVistaOrNewer() {
|
||||
timestamp, err = m.query.CollectDataWithTime()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
timestamp = time.Now()
|
||||
if err = m.query.CollectData(); err != nil {
|
||||
return err
|
||||
for _, hostCounterSet := range m.hostCounters {
|
||||
if m.UsePerfCounterTime && hostCounterSet.query.IsVistaOrNewer() {
|
||||
hostCounterSet.timestamp, err = hostCounterSet.query.CollectDataWithTime()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
hostCounterSet.timestamp = time.Now()
|
||||
if err = hostCounterSet.query.CollectData(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
//iterate over computers
|
||||
for _, hostCounterInfo := range m.hostCounters {
|
||||
wg.Add(1)
|
||||
go func(hostInfo *hostCountersInfo) {
|
||||
m.Log.Debugf("gathering from %s", hostInfo.computer)
|
||||
start := time.Now()
|
||||
err := m.gatherComputerCounters(hostInfo, acc)
|
||||
m.Log.Debugf("gathering from %s finished in %.3fs", hostInfo.computer, time.Since(start))
|
||||
if err != nil {
|
||||
acc.AddError(fmt.Errorf("error during collecting data on host '%s': %s", hostInfo.computer, err.Error()))
|
||||
}
|
||||
wg.Done()
|
||||
}(hostCounterInfo)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *WinPerfCounters) gatherComputerCounters(hostCounterInfo *hostCountersInfo, acc telegraf.Accumulator) error {
|
||||
var value interface{}
|
||||
var err error
|
||||
collectedFields := make(fieldGrouping)
|
||||
// For iterate over the known metrics and get the samples.
|
||||
for _, metric := range m.counters {
|
||||
for _, metric := range hostCounterInfo.counters {
|
||||
// collect
|
||||
if m.UseWildcardsExpansion {
|
||||
if metric.useRawValue {
|
||||
value, err = m.query.GetRawCounterValue(metric.counterHandle)
|
||||
value, err = hostCounterInfo.query.GetRawCounterValue(metric.counterHandle)
|
||||
} else {
|
||||
value, err = m.query.GetFormattedCounterValueDouble(metric.counterHandle)
|
||||
value, err = hostCounterInfo.query.GetFormattedCounterValueDouble(metric.counterHandle)
|
||||
}
|
||||
if err != nil {
|
||||
//ignore invalid data as some counters from process instances returns this sometimes
|
||||
|
|
@ -379,13 +471,13 @@ func (m *Win_PerfCounters) Gather(acc telegraf.Accumulator) error {
|
|||
m.Log.Warnf("error while getting value for counter %q, instance: %s, will skip metric: %v", metric.counterPath, metric.instance, err)
|
||||
continue
|
||||
}
|
||||
addCounterMeasurement(metric, metric.instance, value, collectFields)
|
||||
addCounterMeasurement(metric, metric.instance, value, collectedFields)
|
||||
} else {
|
||||
var counterValues []CounterValue
|
||||
if metric.useRawValue {
|
||||
counterValues, err = m.query.GetRawCounterArray(metric.counterHandle)
|
||||
counterValues, err = hostCounterInfo.query.GetRawCounterArray(metric.counterHandle)
|
||||
} else {
|
||||
counterValues, err = m.query.GetFormattedCounterArrayDouble(metric.counterHandle)
|
||||
counterValues, err = hostCounterInfo.query.GetFormattedCounterArrayDouble(metric.counterHandle)
|
||||
}
|
||||
if err != nil {
|
||||
//ignore invalid data as some counters from process instances returns this sometimes
|
||||
|
|
@ -404,22 +496,34 @@ func (m *Win_PerfCounters) Gather(acc telegraf.Accumulator) error {
|
|||
}
|
||||
|
||||
if shouldIncludeMetric(metric, cValue) {
|
||||
addCounterMeasurement(metric, cValue.InstanceName, cValue.Value, collectFields)
|
||||
addCounterMeasurement(metric, cValue.InstanceName, cValue.Value, collectedFields)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for instance, fields := range collectFields {
|
||||
for instance, fields := range collectedFields {
|
||||
var tags = map[string]string{
|
||||
"objectname": instance.objectname,
|
||||
}
|
||||
if len(instance.instance) > 0 {
|
||||
tags["instance"] = instance.instance
|
||||
}
|
||||
acc.AddFields(instance.name, fields, tags, timestamp)
|
||||
if len(hostCounterInfo.tag) > 0 {
|
||||
tags["source"] = hostCounterInfo.tag
|
||||
}
|
||||
acc.AddFields(instance.name, fields, tags, hostCounterInfo.timestamp)
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (m *WinPerfCounters) cleanQueries() error {
|
||||
for _, hostCounterInfo := range m.hostCounters {
|
||||
if err := hostCounterInfo.query.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.hostCounters = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -442,7 +546,7 @@ func shouldIncludeMetric(metric *counter, cValue CounterValue) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func addCounterMeasurement(metric *counter, instanceName string, value interface{}, collectFields map[instanceGrouping]map[string]interface{}) {
|
||||
func addCounterMeasurement(metric *counter, instanceName string, value interface{}, collectFields fieldGrouping) {
|
||||
var instance = instanceGrouping{metric.measurement, instanceName, metric.objectName}
|
||||
if collectFields[instance] == nil {
|
||||
collectFields[instance] = make(map[string]interface{})
|
||||
|
|
@ -461,7 +565,7 @@ func isKnownCounterDataError(err error) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (m *Win_PerfCounters) Init() error {
|
||||
func (m *WinPerfCounters) Init() error {
|
||||
if m.UseWildcardsExpansion && !m.LocalizeWildcardsExpansion {
|
||||
// Counters must not have wildcards with this option
|
||||
|
||||
|
|
@ -494,10 +598,10 @@ func (m *Win_PerfCounters) Init() error {
|
|||
|
||||
func init() {
|
||||
inputs.Add("win_perf_counters", func() telegraf.Input {
|
||||
return &Win_PerfCounters{
|
||||
query: &PerformanceQueryImpl{},
|
||||
return &WinPerfCounters{
|
||||
CountersRefreshInterval: config.Duration(time.Second * 60),
|
||||
LocalizeWildcardsExpansion: true,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,13 @@
|
|||
package win_perf_counters
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestWinPerformanceQueryImplIntegration(t *testing.T) {
|
||||
|
|
@ -152,13 +150,12 @@ func TestWinPerfcountersConfigGet1Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.NoError(t, err)
|
||||
|
|
@ -191,26 +188,26 @@ func TestWinPerfcountersConfigGet2Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
if len(m.counters) == 1 {
|
||||
hostCounters, ok := m.hostCounters["localhost"]
|
||||
require.True(t, ok)
|
||||
|
||||
if len(hostCounters.counters) == 1 {
|
||||
require.NoError(t, nil)
|
||||
} else if len(m.counters) == 0 {
|
||||
var errorstring1 = "No results returned from the counterPath"
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) == 0 {
|
||||
err2 := fmt.Errorf("no results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
} else if len(m.counters) > 1 {
|
||||
var errorstring1 = fmt.Sprintf("Too many results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) > 1 {
|
||||
err2 := fmt.Errorf("too many results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
}
|
||||
}
|
||||
|
|
@ -220,6 +217,7 @@ func TestWinPerfcountersConfigGet3Integration(t *testing.T) {
|
|||
t.Skip("Skipping integration test in short mode")
|
||||
}
|
||||
|
||||
var sources = make([]string, 1)
|
||||
var instances = make([]string, 1)
|
||||
var counters = make([]string, 2)
|
||||
var perfobjects = make([]perfobject, 1)
|
||||
|
|
@ -228,10 +226,12 @@ func TestWinPerfcountersConfigGet3Integration(t *testing.T) {
|
|||
instances[0] = "_Total"
|
||||
counters[0] = "% Processor Time"
|
||||
counters[1] = "% Idle Time"
|
||||
sources[0] = "localhost"
|
||||
|
||||
var measurement = "test"
|
||||
|
||||
PerfObject := perfobject{
|
||||
Sources: sources,
|
||||
ObjectName: objectname,
|
||||
Instances: instances,
|
||||
Counters: counters,
|
||||
|
|
@ -243,28 +243,26 @@ func TestWinPerfcountersConfigGet3Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
if len(m.counters) == 2 {
|
||||
hostCounters, ok := m.hostCounters["localhost"]
|
||||
require.True(t, ok)
|
||||
|
||||
if len(hostCounters.counters) == 2 {
|
||||
require.NoError(t, nil)
|
||||
} else if len(m.counters) < 2 {
|
||||
|
||||
var errorstring1 = fmt.Sprintf("Too few results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) < 2 {
|
||||
err2 := fmt.Errorf("too few results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
} else if len(m.counters) > 2 {
|
||||
|
||||
var errorstring1 = fmt.Sprintf("Too many results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) > 2 {
|
||||
err2 := fmt.Errorf("too many results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
}
|
||||
}
|
||||
|
|
@ -297,28 +295,26 @@ func TestWinPerfcountersConfigGet4Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
if len(m.counters) == 2 {
|
||||
hostCounters, ok := m.hostCounters["localhost"]
|
||||
require.True(t, ok)
|
||||
|
||||
if len(hostCounters.counters) == 2 {
|
||||
require.NoError(t, nil)
|
||||
} else if len(m.counters) < 2 {
|
||||
|
||||
var errorstring1 = fmt.Sprintf("Too few results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) < 2 {
|
||||
err2 := fmt.Errorf("too few results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
} else if len(m.counters) > 2 {
|
||||
|
||||
var errorstring1 = fmt.Sprintf("Too many results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) > 2 {
|
||||
err2 := fmt.Errorf("too many results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
}
|
||||
}
|
||||
|
|
@ -352,26 +348,26 @@ func TestWinPerfcountersConfigGet5Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
if len(m.counters) == 4 {
|
||||
hostCounters, ok := m.hostCounters["localhost"]
|
||||
require.True(t, ok)
|
||||
|
||||
if len(hostCounters.counters) == 4 {
|
||||
require.NoError(t, nil)
|
||||
} else if len(m.counters) < 4 {
|
||||
var errorstring1 = fmt.Sprintf("Too few results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) < 4 {
|
||||
err2 := fmt.Errorf("too few results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
} else if len(m.counters) > 4 {
|
||||
var errorstring1 = fmt.Sprintf("Too many results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) > 4 {
|
||||
err2 := fmt.Errorf("too many results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
}
|
||||
}
|
||||
|
|
@ -403,16 +399,18 @@ func TestWinPerfcountersConfigGet6Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
_, ok := m.hostCounters["localhost"]
|
||||
require.True(t, ok)
|
||||
}
|
||||
|
||||
func TestWinPerfcountersConfigGet7Integration(t *testing.T) {
|
||||
|
|
@ -433,38 +431,34 @@ func TestWinPerfcountersConfigGet7Integration(t *testing.T) {
|
|||
var measurement = "test"
|
||||
|
||||
PerfObject := perfobject{
|
||||
objectname,
|
||||
counters,
|
||||
instances,
|
||||
measurement,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
ObjectName: objectname,
|
||||
Counters: counters,
|
||||
Instances: instances,
|
||||
Measurement: measurement,
|
||||
}
|
||||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
if len(m.counters) == 2 {
|
||||
hostCounters, ok := m.hostCounters["localhost"]
|
||||
require.True(t, ok)
|
||||
|
||||
if len(hostCounters.counters) == 2 {
|
||||
require.NoError(t, nil)
|
||||
} else if len(m.counters) < 2 {
|
||||
var errorstring1 = fmt.Sprintf("Too few results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) < 2 {
|
||||
err2 := fmt.Errorf("too few results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
} else if len(m.counters) > 2 {
|
||||
var errorstring1 = fmt.Sprintf("Too many results returned from the counterPath: %v", len(m.counters))
|
||||
err2 := errors.New(errorstring1)
|
||||
} else if len(hostCounters.counters) > 2 {
|
||||
err2 := fmt.Errorf("too many results returned from the counterPath: %v", len(hostCounters.counters))
|
||||
require.NoError(t, err2)
|
||||
}
|
||||
}
|
||||
|
|
@ -496,13 +490,12 @@ func TestWinPerfcountersConfigError1Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.Error(t, err)
|
||||
|
|
@ -535,13 +528,12 @@ func TestWinPerfcountersConfigError2Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
var acc testutil.Accumulator
|
||||
|
|
@ -576,13 +568,12 @@ func TestWinPerfcountersConfigError3Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
_ = m.query.Open()
|
||||
|
||||
err := m.ParseConfig()
|
||||
require.Error(t, err)
|
||||
|
|
@ -616,11 +607,11 @@ func TestWinPerfcountersCollect1Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
var acc testutil.Accumulator
|
||||
err := m.Gather(&acc)
|
||||
|
|
@ -667,14 +658,15 @@ func TestWinPerfcountersCollect2Integration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
UsePerfCounterTime: true,
|
||||
Object: perfobjects,
|
||||
query: &PerformanceQueryImpl{},
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
UseWildcardsExpansion: true,
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
||||
var acc testutil.Accumulator
|
||||
err := m.Gather(&acc)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -721,11 +713,11 @@ func TestWinPerfcountersCollectRawIntegration(t *testing.T) {
|
|||
|
||||
perfobjects[0] = PerfObject
|
||||
|
||||
m := Win_PerfCounters{
|
||||
m := WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
UseWildcardsExpansion: true,
|
||||
query: &PerformanceQueryImpl{},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
var acc testutil.Accumulator
|
||||
|
|
@ -746,7 +738,13 @@ func TestWinPerfcountersCollectRawIntegration(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test *Array way
|
||||
m = Win_PerfCounters{PrintValid: false, Object: perfobjects, UseWildcardsExpansion: false, query: &PerformanceQueryImpl{}, Log: testutil.Logger{}}
|
||||
m = WinPerfCounters{
|
||||
PrintValid: false,
|
||||
Object: perfobjects,
|
||||
queryCreator: &PerformanceQueryCreatorImpl{},
|
||||
UseWildcardsExpansion: false,
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
var acc2 testutil.Accumulator
|
||||
err = m.Gather(&acc)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue