Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #16692 to 7.x: Fix diskio struct alignment for windows 32 bit versions #16830

Merged
merged 4 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Made `logstash-xpack` module once again have parity with internally-collected Logstash monitoring data. {pull}16198[16198]
- Change sqs metricset to use average as statistic method. {pull}16438[16438]
- Revert changes in `docker` module: add size flag to docker.container. {pull}16600[16600]
- Fix diskio issue for windows 32 bit on disk_performance struct alignment. {issue}16680[16680]
- Fix detection and logging of some error cases with light modules. {pull}14706[14706]
- Add dashboard for `redisenterprise` module. {pull}16752[16752]
- Convert increments of 100 nanoseconds/ticks to milliseconds for WriteTime and ReadTime in diskio metricset (Windows) for consistency. {issue}14233[14233]
Expand Down
42 changes: 42 additions & 0 deletions metricbeat/module/system/diskio/disk_performance_386.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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

// diskPerformance struct provides disk performance information. It is used by the IOCTL_DISK_PERFORMANCE control code.
// DeviceIoControl() will fail with ERROR_INSUFFICIENT_BUFFER (The data area passed to a system call is too small) on 32 bit systems.
// The memory layout is different for 32 bit vs 64 bit so an alignment (AlignmentPadding) is necessary in order to increase the buffer size
type diskPerformance struct {
BytesRead int64
BytesWritten int64
// Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
ReadTime int64
// Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
WriteTime int64
//Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
IdleTime int64
ReadCount uint32
WriteCount uint32
QueueDepth uint32
SplitCount uint32
QueryTime int64
StorageDeviceNumber uint32
StorageManagerName [8]uint16
AlignmentPadding uint32
}
39 changes: 39 additions & 0 deletions metricbeat/module/system/diskio/disk_performance_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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

// diskPerformance struct provides disk performance information. It is used by the IOCTL_DISK_PERFORMANCE control code.
type diskPerformance struct {
BytesRead int64
BytesWritten int64
// Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
ReadTime int64
// Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
WriteTime int64
//Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
IdleTime int64
ReadCount uint32
WriteCount uint32
QueueDepth uint32
SplitCount uint32
QueryTime int64
StorageDeviceNumber uint32
StorageManagerName [8]uint16
}
26 changes: 5 additions & 21 deletions metricbeat/module/system/diskio/diskstat_windows_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ import (
)

const (
errorSuccess syscall.Errno = 0
ioctlDiskPerformance = 0x70020
ioctlDiskPerformanceOff = 0x70060
errorSuccess syscall.Errno = 0
// ioctlDiskPerformance is used to enable performance counters that provide disk performance information.
ioctlDiskPerformance = 0x70020
// ioctlDiskPerformanceOff used to disable performance counters that provide disk performance information.
ioctlDiskPerformanceOff = 0x70060
)

var (
Expand All @@ -49,24 +51,6 @@ type logicalDrive struct {
UNCPath string
}

type diskPerformance struct {
BytesRead int64
BytesWritten int64
// Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
ReadTime int64
// Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
WriteTime int64
//Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks).
IdleTime int64
ReadCount uint32
WriteCount uint32
QueueDepth uint32
SplitCount uint32
QueryTime int64
StorageDeviceNumber uint32
StorageManagerName [8]uint16
}

// ioCounters gets the diskio counters and maps them to the list of counterstat objects.
func ioCounters(names ...string) (map[string]disk.IOCountersStat, error) {
if err := enablePerformanceCounters(); err != nil {
Expand Down