mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
mi: replace all WMI calls with MI calls (#1700)
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
package mscluster
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
@@ -10,22 +14,22 @@ const nameResourceGroup = Name + "_resourcegroup"
|
||||
// msClusterResourceGroup represents the MSCluster_ResourceGroup WMI class
|
||||
// - https://docs.microsoft.com/en-us/previous-versions/windows/desktop/cluswmi/mscluster-resourcegroup
|
||||
type msClusterResourceGroup struct {
|
||||
Name string
|
||||
Name string `mi:"Name"`
|
||||
|
||||
AutoFailbackType uint
|
||||
Characteristics uint
|
||||
ColdStartSetting uint
|
||||
DefaultOwner uint
|
||||
FailbackWindowEnd int
|
||||
FailbackWindowStart int
|
||||
FailoverPeriod uint
|
||||
FailoverThreshold uint
|
||||
Flags uint
|
||||
GroupType uint
|
||||
OwnerNode string
|
||||
Priority uint
|
||||
ResiliencyPeriod uint
|
||||
State uint
|
||||
AutoFailbackType uint `mi:"AutoFailbackType"`
|
||||
Characteristics uint `mi:"Characteristics"`
|
||||
ColdStartSetting uint `mi:"ColdStartSetting"`
|
||||
DefaultOwner uint `mi:"DefaultOwner"`
|
||||
FailbackWindowEnd int `mi:"FailbackWindowEnd"`
|
||||
FailbackWindowStart int `mi:"FailbackWindowStart"`
|
||||
FailoverPeriod uint `mi:"FailoverPeriod"`
|
||||
FailoverThreshold uint `mi:"FailoverThreshold"`
|
||||
Flags uint `mi:"Flags"`
|
||||
GroupType uint `mi:"GroupType"`
|
||||
OwnerNode string `mi:"OwnerNode"`
|
||||
Priority uint `mi:"Priority"`
|
||||
ResiliencyPeriod uint `mi:"ResiliencyPeriod"`
|
||||
State uint `mi:"State"`
|
||||
}
|
||||
|
||||
func (c *Collector) buildResourceGroup() {
|
||||
@@ -126,8 +130,8 @@ func (c *Collector) buildResourceGroup() {
|
||||
func (c *Collector) collectResourceGroup(ch chan<- prometheus.Metric, nodeNames []string) error {
|
||||
var dst []msClusterResourceGroup
|
||||
|
||||
if err := c.wmiClient.Query("SELECT * FROM MSCluster_ResourceGroup", &dst, nil, "root/MSCluster"); err != nil {
|
||||
return err
|
||||
if err := c.miSession.Query(&dst, mi.NamespaceRootMSCluster, utils.Must(mi.NewQuery("SELECT * FROM MSCluster_ResourceGroup"))); err != nil {
|
||||
return fmt.Errorf("WMI query failed: %w", err)
|
||||
}
|
||||
|
||||
for _, v := range dst {
|
||||
|
||||
Reference in New Issue
Block a user