-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd01aef
commit 36e74db
Showing
4 changed files
with
180 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
plugins/inputs/win_perfcounters/win_perfcounters_notwindows.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
package win_perfcounters | ||
|
||
// +build !windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package win_perfcounters | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/influxdata/telegraf/testutil" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestWinPerfcountersGet(t *testing.T) { | ||
var instances []string | ||
var counters []string | ||
|
||
objectname := "Processor Information" | ||
instances[0] = "_Total" | ||
counters[0] = "% Processor Time" | ||
|
||
var measurement string = "none" | ||
var warnonmissing bool = false | ||
var failonmissing bool = true | ||
var includetotal bool = false | ||
|
||
p := perfobject{ObjectName: objectname, Instances: instances, Measurement: "none", WarnOnMissing: warnonmissing, FailOnMissing: failonmissing, IncludeTotal: includetotal} | ||
|
||
m := Win_PerfCounters{PrintValid: true, Object: &s} | ||
|
||
var acc testutil.Accumulator | ||
err := m.Gather(&acc) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestWinPerfcountersError1(t *testing.T) { | ||
|
||
var instances []string | ||
var counters []string | ||
|
||
objectname := "Processor InformationERROR" | ||
instances[0] = "_Total" | ||
counters[0] = "% Processor Time" | ||
|
||
var measurement string = "none" | ||
var warnonmissing bool = false | ||
var failonmissing bool = true | ||
var includetotal bool = false | ||
|
||
p := perfobject{ObjectName: objectname, Instances: instances, Measurement: "none", WarnOnMissing: warnonmissing, FailOnMissing: failonmissing, IncludeTotal: includetotal} | ||
|
||
m := Win_PerfCounters{PrintValid: true, Object: &s} | ||
|
||
var acc testutil.Accumulator | ||
err := m.Gather(&acc) | ||
require.Error(t, err) | ||
} | ||
|
||
func TestWinPerfcountersError2(t *testing.T) { | ||
var instances []string | ||
var counters []string | ||
|
||
objectname := "Processor Information" | ||
instances[0] = "_TotalERROR" | ||
counters[0] = "% Processor Time" | ||
|
||
var measurement string = "none" | ||
var warnonmissing bool = false | ||
var failonmissing bool = true | ||
var includetotal bool = false | ||
|
||
p := perfobject{ObjectName: objectname, Instances: instances, Measurement: "none", WarnOnMissing: warnonmissing, FailOnMissing: failonmissing, IncludeTotal: includetotal} | ||
|
||
m := Win_PerfCounters{PrintValid: true, Object: &s} | ||
|
||
var acc testutil.Accumulator | ||
err := m.Gather(&acc) | ||
require.Error(t, err) | ||
} | ||
|
||
func TestWinPerfcountersError3(t *testing.T) { | ||
var instances []string | ||
var counters []string | ||
|
||
objectname := "Processor Information" | ||
instances[0] = "_Total" | ||
counters[0] = "% Processor TimeERROR" | ||
|
||
var measurement string = "none" | ||
var warnonmissing bool = false | ||
var failonmissing bool = true | ||
var includetotal bool = false | ||
|
||
p := perfobject{ObjectName: objectname, Instances: instances, Measurement: "none", WarnOnMissing: warnonmissing, FailOnMissing: failonmissing, IncludeTotal: includetotal} | ||
|
||
m := Win_PerfCounters{PrintValid: true, Object: &s} | ||
|
||
var acc testutil.Accumulator | ||
err := m.Gather(&acc) | ||
require.Error(t, err) | ||
} |