-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace WMI query to get the system/diskio metrics for Windows (#11635)
* Replace using WMI query to get the system/diskio metrics for Windows (SELECT * FROM Win32_PerfFormattedData_PerfDisk_LogicalDisk) with DeviceIOControl Win32 API method using IOCTL_DISK_PERFORMANCE control code. Fixes: #3798 and #2842 * Fixed cross platform build, added tests and include_devices filter Added: - include_devices filter to the IOCounters - test file to assert get stats on C: returns data - addressed houndci-bot style violations * Fix goimports style * Fix goimports styling * Fix goimports and houndci-bot requests * Fix support for osx * Re-run build, address houndci-bot messages * Update changelog file * Addressed PR comments * Addressing review notes * Enrich test and implement separate function to enable the performance counters * Add disable performance counters functionality for testing * Log meesage when the EnableCounterForIoctl is added/updated in the registry * Check for registry key value before updating it * Address new code reviews * small refactoring of deviceiocontrol functions
- Loading branch information
Showing
8 changed files
with
399 additions
and
27 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
// +build windows | ||
|
||
package diskio | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"github.com/shirou/gopsutil/disk" | ||
) | ||
|
||
// NewDiskIOStat :init DiskIOStat object. | ||
func NewDiskIOStat() *DiskIOStat { | ||
return &DiskIOStat{ | ||
lastDiskIOCounters: map[string]disk.IOCountersStat{}, | ||
} | ||
} | ||
|
||
// OpenSampling stub for linux implementation. | ||
func (stat *DiskIOStat) OpenSampling() error { | ||
return nil | ||
} | ||
|
||
// CalIOStatistics stub for linux implementation. | ||
func (stat *DiskIOStat) CalIOStatistics(result *DiskIOMetric, counter disk.IOCountersStat) error { | ||
return errors.New("iostat is not implement for Windows") | ||
} | ||
|
||
// CloseSampling stub for linux implementation. | ||
func (stat *DiskIOStat) CloseSampling() {} | ||
|
||
// IOCounters should map functionality to disk package for linux os. | ||
func IOCounters(names ...string) (map[string]disk.IOCountersStat, error) { | ||
return ioCounters(names...) | ||
} |
Oops, something went wrong.