mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-12 05:26:37 +00:00
@@ -201,7 +201,7 @@ func isWindowsService() (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ; ; parentProcess = (*windows.SYSTEM_PROCESS_INFORMATION)(unsafe.Pointer(uintptr(unsafe.Pointer(parentProcess)) + uintptr(parentProcess.NextEntryOffset))) {
|
for ; ; parentProcess = (*windows.SYSTEM_PROCESS_INFORMATION)(unsafe.Add(unsafe.Pointer(parentProcess), uintptr(parentProcess.NextEntryOffset))) {
|
||||||
if parentProcess.UniqueProcessID == currentProcess.InheritedFromUniqueProcessId {
|
if parentProcess.UniqueProcessID == currentProcess.InheritedFromUniqueProcessId {
|
||||||
return strings.EqualFold("services.exe", parentProcess.ImageName.String()), nil
|
return strings.EqualFold("services.exe", parentProcess.ImageName.String()), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,10 +136,10 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sb := strings.Builder{}
|
sb := strings.Builder{}
|
||||||
sb.WriteString(fmt.Sprintf("%-32s %-32s\n", "Collector Name", "[PerfID] Perflib Object"))
|
_, _ = fmt.Fprintf(&sb, "%-32s %-32s\n", "Collector Name", "[PerfID] Perflib Object")
|
||||||
|
|
||||||
for _, cname := range ConfigDefaults.CollectorsEnabled {
|
for _, cname := range ConfigDefaults.CollectorsEnabled {
|
||||||
sb.WriteString(fmt.Sprintf("%-32s %-32s\n", cname, collectorDesc[cname]))
|
_, _ = fmt.Fprintf(&sb, "%-32s %-32s\n", cname, collectorDesc[cname])
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UsageTemplate(sb.String()).Usage(nil)
|
app.UsageTemplate(sb.String()).Usage(nil)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ func TestDuplicateMetricEntry(t *testing.T) {
|
|||||||
Metric: []*dto.Metric{&metric1, &metric2},
|
Metric: []*dto.Metric{&metric1, &metric2},
|
||||||
}
|
}
|
||||||
|
|
||||||
var duplicateFamily []*dto.MetricFamily
|
duplicateFamily := make([]*dto.MetricFamily, 0, 1)
|
||||||
|
|
||||||
duplicateFamily = append(duplicateFamily, &duplicate)
|
duplicateFamily = append(duplicateFamily, &duplicate)
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ func TestDuplicateMetricEntry(t *testing.T) {
|
|||||||
Metric: []*dto.Metric{&metric1, &metric3},
|
Metric: []*dto.Metric{&metric1, &metric3},
|
||||||
}
|
}
|
||||||
|
|
||||||
duplicateFamily = []*dto.MetricFamily{}
|
duplicateFamily = make([]*dto.MetricFamily, 0, 1)
|
||||||
duplicateFamily = append(duplicateFamily, &differentLabels)
|
duplicateFamily = append(duplicateFamily, &differentLabels)
|
||||||
|
|
||||||
// Additional label on second metric should not be cause for duplicate detection
|
// Additional label on second metric should not be cause for duplicate detection
|
||||||
@@ -171,7 +171,7 @@ func TestDuplicateMetricEntry(t *testing.T) {
|
|||||||
Type: &metric_type,
|
Type: &metric_type,
|
||||||
Metric: []*dto.Metric{&metric3, &metric4},
|
Metric: []*dto.Metric{&metric3, &metric4},
|
||||||
}
|
}
|
||||||
duplicateFamily = []*dto.MetricFamily{}
|
duplicateFamily = make([]*dto.MetricFamily, 0, 1)
|
||||||
duplicateFamily = append(duplicateFamily, &differentValues)
|
duplicateFamily = append(duplicateFamily, &differentValues)
|
||||||
|
|
||||||
// Additional label with different values metric should not be cause for duplicate detection
|
// Additional label with different values metric should not be cause for duplicate detection
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ func GetDHCPV4ScopeStatistics() ([]DHCPV4Scope, error) {
|
|||||||
for _, subnet := range subnets {
|
for _, subnet := range subnets {
|
||||||
if err := (func() error {
|
if err := (func() error {
|
||||||
var subnetInfo *DHCP_SUBNET_INFO
|
var subnetInfo *DHCP_SUBNET_INFO
|
||||||
|
|
||||||
err := dhcpGetSubnetInfo(subnet.SubnetAddress, &subnetInfo)
|
err := dhcpGetSubnetInfo(subnet.SubnetAddress, &subnetInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get subnet info: %w", err)
|
return fmt.Errorf("failed to get subnet info: %w", err)
|
||||||
@@ -109,6 +110,7 @@ func GetDHCPV4ScopeStatistics() ([]DHCPV4Scope, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subnetStatistics *DHCP_FAILOVER_STATISTICS
|
var subnetStatistics *DHCP_FAILOVER_STATISTICS
|
||||||
|
|
||||||
err = dhcpV4FailoverGetScopeStatistics(subnet.SubnetAddress, &subnetStatistics)
|
err = dhcpV4FailoverGetScopeStatistics(subnet.SubnetAddress, &subnetStatistics)
|
||||||
|
|
||||||
defer dhcpRpcFreeMemory(unsafe.Pointer(subnetStatistics))
|
defer dhcpRpcFreeMemory(unsafe.Pointer(subnetStatistics))
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ func (c *ClassDecl) Properties() []*PropertyDecl {
|
|||||||
// Iterate over the number of properties and fetch each property
|
// Iterate over the number of properties and fetch each property
|
||||||
for i := range c.NumProperties {
|
for i := range c.NumProperties {
|
||||||
// Get the property pointer at index i
|
// Get the property pointer at index i
|
||||||
propertyPtr := *(**PropertyDecl)(unsafe.Pointer(uintptr(unsafe.Pointer(propertiesArray)) + uintptr(i)*unsafe.Sizeof(uintptr(0))))
|
propertyPtr := *(**PropertyDecl)(unsafe.Add(unsafe.Pointer(propertiesArray), uintptr(i)*unsafe.Sizeof(uintptr(0))))
|
||||||
|
|
||||||
// Append the property to the slice
|
// Append the property to the slice
|
||||||
properties[i] = propertyPtr
|
properties[i] = propertyPtr
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
package testutils
|
package testutils
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user