mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-21 03:59:04 +02:00
headers: fail Build on missing native exports and assert MI/COM layouts (#2739)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -233,9 +233,11 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
||||
close: func() { c.perfDataCollectorDynamicMemoryVM.Close() },
|
||||
},
|
||||
subCollectorHost: {
|
||||
build: c.buildHost,
|
||||
collect: c.collectHost,
|
||||
close: func() { c.perfDataCollectorLogicalProcessor.Close() },
|
||||
// The Host Compute Service API (computecore.dll) exists since 1809.
|
||||
minBuildNumber: osversion.LTSC2019,
|
||||
build: c.buildHost,
|
||||
collect: c.collectHost,
|
||||
close: func() { c.perfDataCollectorLogicalProcessor.Close() },
|
||||
},
|
||||
subCollectorHypervisorLogicalProcessor: {
|
||||
build: c.buildHypervisorLogicalProcessor,
|
||||
|
||||
@@ -70,6 +70,10 @@ type vmVirtualNode struct {
|
||||
}
|
||||
|
||||
func (c *Collector) buildHost() error {
|
||||
if err := hcs.Load(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
c.perfDataCollectorLogicalProcessor, err = pdh.NewCollector[perfDataCounterValuesHost](c.logger, pdh.CounterTypeRaw, "Hyper-V Hypervisor Logical Processor", pdh.InstancesAll)
|
||||
|
||||
@@ -52,6 +52,10 @@ func (c *Collector) buildWMIHealth() error {
|
||||
return mi.ErrNotInitialized
|
||||
}
|
||||
|
||||
if err := sysinfoapi.Load(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// The host's Msvm_ComputerSystem is named after the physical NetBIOS name.
|
||||
// Caption is localized, so it can't be used to select the host.
|
||||
hostname, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNamePhysicalNetBIOS)
|
||||
|
||||
Reference in New Issue
Block a user