Skip to content

Commit

Permalink
Perfmon wildcard queries (#4502)
Browse files Browse the repository at this point in the history
* Add PDH wildcard queries

* Add example

* Add integration test
  • Loading branch information
martinscholz83 authored and andrewkroh committed Jul 11, 2017
1 parent 539df96 commit 5f959cd
Show file tree
Hide file tree
Showing 9 changed files with 514 additions and 315 deletions.
8 changes: 5 additions & 3 deletions metricbeat/module/windows/perfmon/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ With `format` you can set the output format for a specific counter. Possible val
metricsets: ["perfmon"]
period: 10s
perfmon.counters:
- alias: "processor.time.total.pct"
- instance_label: "processor.name"
measurement_label: "processor.time.total.pct"
query: '\Processor Information(_Total)\% Processor Time'
- alias: "diskio.write.bytes"
query: '\PhysicalDisk(_Total)\Disk Writes/sec'
- instance_label: "diskio.name"
measurement_label: "diskio.write.bytes"
query: '\PhysicalDisk(*)\Disk Writes/sec'
format: "long"
----
176 changes: 90 additions & 86 deletions metricbeat/module/windows/perfmon/defs_pdh_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,92 +105,92 @@ const (
)

var pdhErrors = map[PdhErrno]struct{}{
PDH_CSTATUS_VALID_DATA: {},
PDH_CSTATUS_NEW_DATA: {},
PDH_CSTATUS_NO_MACHINE: {},
PDH_CSTATUS_NO_INSTANCE: {},
PDH_MORE_DATA: {},
PDH_CSTATUS_ITEM_NOT_VALIDATED: {},
PDH_RETRY: {},
PDH_NO_DATA: {},
PDH_CALC_NEGATIVE_DENOMINATOR: {},
PDH_CALC_NEGATIVE_TIMEBASE: {},
PDH_CALC_NEGATIVE_VALUE: {},
PDH_DIALOG_CANCELLED: {},
PDH_END_OF_LOG_FILE: {},
PDH_ASYNC_QUERY_TIMEOUT: {},
PDH_CANNOT_SET_DEFAULT_REALTIME_DATASOURCE: {},
PDH_CSTATUS_NO_OBJECT: {},
PDH_CSTATUS_NO_COUNTER: {},
PDH_CSTATUS_INVALID_DATA: {},
PDH_MEMORY_ALLOCATION_FAILURE: {},
PDH_INVALID_HANDLE: {},
PDH_INVALID_ARGUMENT: {},
PDH_FUNCTION_NOT_FOUND: {},
PDH_CSTATUS_NO_COUNTERNAME: {},
PDH_CSTATUS_BAD_COUNTERNAME: {},
PDH_INVALID_BUFFER: {},
PDH_INSUFFICIENT_BUFFER: {},
PDH_CANNOT_CONNECT_MACHINE: {},
PDH_INVALID_PATH: {},
PDH_INVALID_INSTANCE: {},
PDH_INVALID_DATA: {},
PDH_NO_DIALOG_DATA: {},
PDH_CANNOT_READ_NAME_STRINGS: {},
PDH_LOG_FILE_CREATE_ERROR: {},
PDH_LOG_FILE_OPEN_ERROR: {},
PDH_LOG_TYPE_NOT_FOUND: {},
PDH_NO_MORE_DATA: {},
PDH_ENTRY_NOT_IN_LOG_FILE: {},
PDH_DATA_SOURCE_IS_LOG_FILE: {},
PDH_DATA_SOURCE_IS_REAL_TIME: {},
PDH_UNABLE_READ_LOG_HEADER: {},
PDH_FILE_NOT_FOUND: {},
PDH_FILE_ALREADY_EXISTS: {},
PDH_NOT_IMPLEMENTED: {},
PDH_STRING_NOT_FOUND: {},
PDH_UNABLE_MAP_NAME_FILES: {},
PDH_UNKNOWN_LOG_FORMAT: {},
PDH_UNKNOWN_LOGSVC_COMMAND: {},
PDH_LOGSVC_QUERY_NOT_FOUND: {},
PDH_LOGSVC_NOT_OPENED: {},
PDH_WBEM_ERROR: {},
PDH_ACCESS_DENIED: {},
PDH_LOG_FILE_TOO_SMALL: {},
PDH_INVALID_DATASOURCE: {},
PDH_INVALID_SQLDB: {},
PDH_NO_COUNTERS: {},
PDH_SQL_ALLOC_FAILED: {},
PDH_SQL_ALLOCCON_FAILED: {},
PDH_SQL_EXEC_DIRECT_FAILED: {},
PDH_SQL_FETCH_FAILED: {},
PDH_SQL_ROWCOUNT_FAILED: {},
PDH_SQL_MORE_RESULTS_FAILED: {},
PDH_SQL_CONNECT_FAILED: {},
PDH_SQL_BIND_FAILED: {},
PDH_CANNOT_CONNECT_WMI_SERVER: {},
PDH_PLA_COLLECTION_ALREADY_RUNNING: {},
PDH_PLA_ERROR_SCHEDULE_OVERLAP: {},
PDH_PLA_COLLECTION_NOT_FOUND: {},
PDH_PLA_ERROR_SCHEDULE_ELAPSED: {},
PDH_PLA_ERROR_NOSTART: {},
PDH_PLA_ERROR_ALREADY_EXISTS: {},
PDH_PLA_ERROR_TYPE_MISMATCH: {},
PDH_PLA_ERROR_FILEPATH: {},
PDH_PLA_SERVICE_ERROR: {},
PDH_PLA_VALIDATION_ERROR: {},
PDH_PLA_VALIDATION_WARNING: {},
PDH_PLA_ERROR_NAME_TOO_LONG: {},
PDH_INVALID_SQL_LOG_FORMAT: {},
PDH_COUNTER_ALREADY_IN_QUERY: {},
PDH_BINARY_LOG_CORRUPT: {},
PDH_LOG_SAMPLE_TOO_SMALL: {},
PDH_OS_LATER_VERSION: {},
PDH_OS_EARLIER_VERSION: {},
PDH_INCORRECT_APPEND_TIME: {},
PDH_UNMATCHED_APPEND_COUNTER: {},
PDH_SQL_ALTER_DETAIL_FAILED: {},
PDH_QUERY_PERF_DATA_TIMEOUT: {},
PDH_CSTATUS_VALID_DATA: struct{}{},
PDH_CSTATUS_NEW_DATA: struct{}{},
PDH_CSTATUS_NO_MACHINE: struct{}{},
PDH_CSTATUS_NO_INSTANCE: struct{}{},
PDH_MORE_DATA: struct{}{},
PDH_CSTATUS_ITEM_NOT_VALIDATED: struct{}{},
PDH_RETRY: struct{}{},
PDH_NO_DATA: struct{}{},
PDH_CALC_NEGATIVE_DENOMINATOR: struct{}{},
PDH_CALC_NEGATIVE_TIMEBASE: struct{}{},
PDH_CALC_NEGATIVE_VALUE: struct{}{},
PDH_DIALOG_CANCELLED: struct{}{},
PDH_END_OF_LOG_FILE: struct{}{},
PDH_ASYNC_QUERY_TIMEOUT: struct{}{},
PDH_CANNOT_SET_DEFAULT_REALTIME_DATASOURCE: struct{}{},
PDH_CSTATUS_NO_OBJECT: struct{}{},
PDH_CSTATUS_NO_COUNTER: struct{}{},
PDH_CSTATUS_INVALID_DATA: struct{}{},
PDH_MEMORY_ALLOCATION_FAILURE: struct{}{},
PDH_INVALID_HANDLE: struct{}{},
PDH_INVALID_ARGUMENT: struct{}{},
PDH_FUNCTION_NOT_FOUND: struct{}{},
PDH_CSTATUS_NO_COUNTERNAME: struct{}{},
PDH_CSTATUS_BAD_COUNTERNAME: struct{}{},
PDH_INVALID_BUFFER: struct{}{},
PDH_INSUFFICIENT_BUFFER: struct{}{},
PDH_CANNOT_CONNECT_MACHINE: struct{}{},
PDH_INVALID_PATH: struct{}{},
PDH_INVALID_INSTANCE: struct{}{},
PDH_INVALID_DATA: struct{}{},
PDH_NO_DIALOG_DATA: struct{}{},
PDH_CANNOT_READ_NAME_STRINGS: struct{}{},
PDH_LOG_FILE_CREATE_ERROR: struct{}{},
PDH_LOG_FILE_OPEN_ERROR: struct{}{},
PDH_LOG_TYPE_NOT_FOUND: struct{}{},
PDH_NO_MORE_DATA: struct{}{},
PDH_ENTRY_NOT_IN_LOG_FILE: struct{}{},
PDH_DATA_SOURCE_IS_LOG_FILE: struct{}{},
PDH_DATA_SOURCE_IS_REAL_TIME: struct{}{},
PDH_UNABLE_READ_LOG_HEADER: struct{}{},
PDH_FILE_NOT_FOUND: struct{}{},
PDH_FILE_ALREADY_EXISTS: struct{}{},
PDH_NOT_IMPLEMENTED: struct{}{},
PDH_STRING_NOT_FOUND: struct{}{},
PDH_UNABLE_MAP_NAME_FILES: struct{}{},
PDH_UNKNOWN_LOG_FORMAT: struct{}{},
PDH_UNKNOWN_LOGSVC_COMMAND: struct{}{},
PDH_LOGSVC_QUERY_NOT_FOUND: struct{}{},
PDH_LOGSVC_NOT_OPENED: struct{}{},
PDH_WBEM_ERROR: struct{}{},
PDH_ACCESS_DENIED: struct{}{},
PDH_LOG_FILE_TOO_SMALL: struct{}{},
PDH_INVALID_DATASOURCE: struct{}{},
PDH_INVALID_SQLDB: struct{}{},
PDH_NO_COUNTERS: struct{}{},
PDH_SQL_ALLOC_FAILED: struct{}{},
PDH_SQL_ALLOCCON_FAILED: struct{}{},
PDH_SQL_EXEC_DIRECT_FAILED: struct{}{},
PDH_SQL_FETCH_FAILED: struct{}{},
PDH_SQL_ROWCOUNT_FAILED: struct{}{},
PDH_SQL_MORE_RESULTS_FAILED: struct{}{},
PDH_SQL_CONNECT_FAILED: struct{}{},
PDH_SQL_BIND_FAILED: struct{}{},
PDH_CANNOT_CONNECT_WMI_SERVER: struct{}{},
PDH_PLA_COLLECTION_ALREADY_RUNNING: struct{}{},
PDH_PLA_ERROR_SCHEDULE_OVERLAP: struct{}{},
PDH_PLA_COLLECTION_NOT_FOUND: struct{}{},
PDH_PLA_ERROR_SCHEDULE_ELAPSED: struct{}{},
PDH_PLA_ERROR_NOSTART: struct{}{},
PDH_PLA_ERROR_ALREADY_EXISTS: struct{}{},
PDH_PLA_ERROR_TYPE_MISMATCH: struct{}{},
PDH_PLA_ERROR_FILEPATH: struct{}{},
PDH_PLA_SERVICE_ERROR: struct{}{},
PDH_PLA_VALIDATION_ERROR: struct{}{},
PDH_PLA_VALIDATION_WARNING: struct{}{},
PDH_PLA_ERROR_NAME_TOO_LONG: struct{}{},
PDH_INVALID_SQL_LOG_FORMAT: struct{}{},
PDH_COUNTER_ALREADY_IN_QUERY: struct{}{},
PDH_BINARY_LOG_CORRUPT: struct{}{},
PDH_LOG_SAMPLE_TOO_SMALL: struct{}{},
PDH_OS_LATER_VERSION: struct{}{},
PDH_OS_EARLIER_VERSION: struct{}{},
PDH_INCORRECT_APPEND_TIME: struct{}{},
PDH_UNMATCHED_APPEND_COUNTER: struct{}{},
PDH_SQL_ALTER_DETAIL_FAILED: struct{}{},
PDH_QUERY_PERF_DATA_TIMEOUT: struct{}{},
}

type PdhCounterFormat uint32
Expand Down Expand Up @@ -219,6 +219,10 @@ const (
// PdhCounterValue is the structure that receives the counter value.
type PdhCounterValue C.PDH_FMT_COUNTERVALUE

type PdhCounterValueItem C.PDH_FMT_COUNTERVALUE_ITEM

type PdhRawCounterItem C.PDH_RAW_COUNTER_ITEM

// PdhRawCounter is the structure that receives the raw counter.
type PdhRawCounter C.PDH_RAW_COUNTER

Expand Down
Loading

0 comments on commit 5f959cd

Please sign in to comment.