2018-05-30 02:34:00 +08:00
// Copyright (c) 2010 The win Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// This is the official list of 'win' authors for copyright purposes.
//
// Alexander Neumann <an2048@googlemail.com>
// Joseph Watson <jtwatson@linux-consulting.us>
// Kevin Pors <krpors@gmail.com>
2021-08-24 04:37:44 +08:00
//go:build windows
2018-05-30 02:34:00 +08:00
package win_perf_counters
2024-09-17 00:59:39 +08:00
// pdhFmtCountervalueDouble is a union specialization for double values
type pdhFmtCountervalueDouble struct {
2018-05-30 02:34:00 +08:00
CStatus uint32
DoubleValue float64
}
2025-01-28 02:34:59 +08:00
// pdhFmtCountervalueItemDouble is a union specialization for double values, used by pdhGetFormattedCounterArrayDouble
2024-09-17 00:59:39 +08:00
type pdhFmtCountervalueItemDouble struct {
2018-05-30 02:34:00 +08:00
SzName * uint16
2024-09-17 00:59:39 +08:00
FmtValue pdhFmtCountervalueDouble
2018-05-30 02:34:00 +08:00
}
2024-09-17 00:59:39 +08:00
// pdhCounterInfo structure contains information describing the properties of a counter. This information also includes the counter path.
type pdhCounterInfo struct {
2024-09-19 17:03:28 +08:00
// Size of the structure, including the appended strings, in bytes.
2018-05-30 02:34:00 +08:00
DwLength uint32
2024-09-19 17:03:28 +08:00
// Counter type. For a list of counter types,
// see the Counter Types section of the <a "href=http://go.microsoft.com/fwlink/p/?linkid=84422">Windows Server 2003 Deployment Kit</a>.
// The counter type constants are defined in Winperf.h.
2018-05-30 02:34:00 +08:00
DwType uint32
2024-09-19 17:03:28 +08:00
// Counter version information. Not used.
2018-05-30 02:34:00 +08:00
CVersion uint32
2024-09-19 17:03:28 +08:00
// Counter status that indicates if the counter value is valid. For a list of possible values,
// see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa371894(v=vs.85).aspx">Checking PDH Interface Return Values</a>.
2018-05-30 02:34:00 +08:00
CStatus uint32
2024-09-19 17:03:28 +08:00
// Scale factor to use when computing the displayable value of the counter. The scale factor is a power of ten.
// The valid range of this parameter is PDH_MIN_SCALE (– 7) (the returned value is the actual value times 10– ⁷) to
// PDH_MAX_SCALE (+7) (the returned value is the actual value times 10⁺⁷). A value of zero will set the scale to one, so that the actual value is returned
2018-05-30 02:34:00 +08:00
LScale int32
2024-09-19 17:03:28 +08:00
// Default scale factor as suggested by the counter's provider.
2018-05-30 02:34:00 +08:00
LDefaultScale int32
2025-01-28 02:34:59 +08:00
// The value passed in the dwUserData parameter when calling pdhAddCounter.
2018-05-30 02:34:00 +08:00
DwUserData * uint32
2025-01-28 02:34:59 +08:00
// The value passed in the dwUserData parameter when calling pdhOpenQuery.
2018-05-30 02:34:00 +08:00
DwQueryUserData * uint32
2024-09-19 17:03:28 +08:00
// Null-terminated string that specifies the full counter path. The string follows this structure in memory.
2018-05-30 02:34:00 +08:00
SzFullPath * uint16 // pointer to a string
2024-09-19 17:03:28 +08:00
// Null-terminated string that contains the name of the computer specified in the counter path. Is NULL, if the path does not specify a computer.
// The string follows this structure in memory.
2018-05-30 02:34:00 +08:00
SzMachineName * uint16 // pointer to a string
2024-09-19 17:03:28 +08:00
// Null-terminated string that contains the name of the performance object specified in the counter path. The string follows this structure in memory.
2018-05-30 02:34:00 +08:00
SzObjectName * uint16 // pointer to a string
2024-09-19 17:03:28 +08:00
// Null-terminated string that contains the name of the object instance specified in the counter path. Is NULL, if the path does not specify an instance.
// The string follows this structure in memory.
2018-05-30 02:34:00 +08:00
SzInstanceName * uint16 // pointer to a string
2024-09-19 17:03:28 +08:00
// Null-terminated string that contains the name of the parent instance specified in the counter path.
// Is NULL, if the path does not specify a parent instance. The string follows this structure in memory.
2018-05-30 02:34:00 +08:00
SzParentInstance * uint16 // pointer to a string
2024-09-19 17:03:28 +08:00
// Instance index specified in the counter path. Is 0, if the path does not specify an instance index.
2018-05-30 02:34:00 +08:00
DwInstanceIndex uint32 // pointer to a string
2024-09-19 17:03:28 +08:00
// Null-terminated string that contains the counter name. The string follows this structure in memory.
2018-05-30 02:34:00 +08:00
SzCounterName * uint16 // pointer to a string
2024-09-19 17:03:28 +08:00
// Help text that describes the counter. Is NULL if the source is a log file.
2018-05-30 02:34:00 +08:00
SzExplainText * uint16 // pointer to a string
2024-09-19 17:03:28 +08:00
// Start of the string data that is appended to the structure.
2018-05-30 02:34:00 +08:00
DataBuffer [ 1 ] uint32 // pointer to an extra space
}
2022-02-11 06:03:52 +08:00
2024-09-17 00:59:39 +08:00
// The pdhRawCounter structure returns the data as it was collected from the counter provider.
2023-04-25 17:29:23 +08:00
// No translation, formatting, or other interpretation is performed on the data
2024-09-17 00:59:39 +08:00
type pdhRawCounter struct {
2023-04-25 17:29:23 +08:00
// Counter status that indicates if the counter value is valid. Check this member before using the data in a calculation or displaying its value.
// For a list of possible values, see https://docs.microsoft.com/windows/desktop/PerfCtrs/checking-pdh-interface-return-values
2022-02-11 06:03:52 +08:00
CStatus uint32
// Local time for when the data was collected
2023-05-05 00:14:36 +08:00
TimeStamp fileTime
2022-02-11 06:03:52 +08:00
// First raw counter value.
FirstValue int64
// Second raw counter value. Rate counters require two values in order to compute a displayable value.
SecondValue int64
// If the counter type contains the PERF_MULTI_COUNTER flag, this member contains the additional counter data used in the calculation.
// For example, the PERF_100NSEC_MULTI_TIMER counter type contains the PERF_MULTI_COUNTER flag.
MultiCount uint32
}
2024-09-17 00:59:39 +08:00
type pdhRawCounterItem struct {
2022-02-11 06:03:52 +08:00
// Pointer to a null-terminated string that specifies the instance name of the counter. The string is appended to the end of this structure.
SzName * uint16
2024-09-19 17:03:28 +08:00
// A pdhRawCounter structure that contains the raw counter value of the instance
2024-09-17 00:59:39 +08:00
RawValue pdhRawCounter
2022-02-11 06:03:52 +08:00
}