Added support for Windows operating systems pre-Vista.

This commit is contained in:
Rune Darrud 2016-01-31 17:40:50 +01:00 committed by Cameron Sparr
parent a11e07e250
commit 0d391b66a3
2 changed files with 40 additions and 12 deletions

View File

@ -18,6 +18,30 @@ as counters used when performance monitoring
This file is likely to be updated in the future with more examples for This file is likely to be updated in the future with more examples for
useful configurations for separate scenarios. useful configurations for separate scenarios.
### Plugin wide
Plugin wide entries are underneath `[[inputs.win_perf_counters]]`.
#### PrintValid
Bool, if set to `true` will print out all matching performance objects.
Example:
`PrintValid=true`
#### PreVistaSupport
Bool, if set to `true` will use the localized PerfCounter interface that is present before Vista for backwards compatability.
It is recommended NOT to use this on OSes starting with Vista and newer because it requires more configuration to use this than the newer interface present since Vista.
Example for Windows Server 2003, this would be set to true:
`PreVistaSupport=true`
### Object
See Entry below.
### Entry ### Entry
A new configuration entry consists of the TOML header to start with, A new configuration entry consists of the TOML header to start with,
`[[inputs.win_perf_counters.object]]`. `[[inputs.win_perf_counters.object]]`.
@ -26,14 +50,14 @@ beneath the main win_perf_counters entry, `[[inputs.win_perf_counters]]`.
Following this is 3 required key/value pairs and the three optional parameters and their usage. Following this is 3 required key/value pairs and the three optional parameters and their usage.
### ObjectName #### ObjectName
**Required** **Required**
ObjectName is the Object to query for, like Processor, DirectoryServices, LogicalDisk or similar. ObjectName is the Object to query for, like Processor, DirectoryServices, LogicalDisk or similar.
Example: `ObjectName = "LogicalDisk"` Example: `ObjectName = "LogicalDisk"`
### Instances #### Instances
**Required** **Required**
Instances (this is an array) is the instances of a counter you would like returned, Instances (this is an array) is the instances of a counter you would like returned,
@ -49,7 +73,7 @@ Some Objects does not have instances to select from at all,
here only one option is valid if you want data back, here only one option is valid if you want data back,
and that is to specify `Instances = ["------"]`. and that is to specify `Instances = ["------"]`.
### Counters #### Counters
**Required** **Required**
Counters (this is an array) is the counters of the ObjectName Counters (this is an array) is the counters of the ObjectName
@ -59,7 +83,7 @@ Example: `Counters = ["% Idle Time", "% Disk Read Time", "% Disk Write Time"]`
This must be specified for every counter you want the results of, This must be specified for every counter you want the results of,
it is not possible to ask for all counters in the ObjectName. it is not possible to ask for all counters in the ObjectName.
### Measurement #### Measurement
*Optional* *Optional*
This key is optional, if it is not set it will be win_perf_counters. This key is optional, if it is not set it will be win_perf_counters.
@ -70,7 +94,7 @@ separate from Processor results.
Example: `Measurement = "win_disk" Example: `Measurement = "win_disk"
### IncludeTotal #### IncludeTotal
*Optional* *Optional*
This key is optional, it is a simple bool. This key is optional, it is a simple bool.
@ -80,7 +104,7 @@ and you would also like all instances containg _Total returned,
like "_Total", "0,_Total" and so on where applicable like "_Total", "0,_Total" and so on where applicable
(Processor Information is one example). (Processor Information is one example).
### WarnOnMissing #### WarnOnMissing
*Optional* *Optional*
This key is optional, it is a simple bool. This key is optional, it is a simple bool.
@ -89,7 +113,7 @@ This only has an effect on the first execution of the plugin,
it will print out any ObjectName/Instance/Counter combinations it will print out any ObjectName/Instance/Counter combinations
asked for that does not match. Useful when debugging new configurations. asked for that does not match. Useful when debugging new configurations.
### FailOnMissing #### FailOnMissing
*Internal* *Internal*
This key should not be used, it is for testing purposes only. This key should not be used, it is for testing purposes only.

View File

@ -74,9 +74,10 @@ var testConfigParsed bool
var testObject string var testObject string
type Win_PerfCounters struct { type Win_PerfCounters struct {
PrintValid bool PrintValid bool
TestName string TestName string
Object []perfobject PreVistaSupport bool
Object []perfobject
} }
type perfobject struct { type perfobject struct {
@ -112,8 +113,11 @@ func (m *Win_PerfCounters) AddItem(metrics *itemList, query string, objectName s
var handle win.PDH_HQUERY var handle win.PDH_HQUERY
var counterHandle win.PDH_HCOUNTER var counterHandle win.PDH_HCOUNTER
ret := win.PdhOpenQuery(0, 0, &handle) ret := win.PdhOpenQuery(0, 0, &handle)
ret = win.PdhAddEnglishCounter(handle, query, 0, &counterHandle) if m.PreVistaSupport {
ret = win.PdhAddCounter(handle, query, 0, &counterHandle)
} else {
ret = win.PdhAddEnglishCounter(handle, query, 0, &counterHandle)
}
_ = ret _ = ret
temp := &item{query, objectName, counter, instance, measurement, temp := &item{query, objectName, counter, instance, measurement,