netframework: merge multiple collector into one (Click here for more information) (#1633)

This commit is contained in:
Jan-Otto Kröpke
2024-09-20 10:02:57 +02:00
committed by GitHub
parent 41ff5729df
commit 2635e5d8eb
32 changed files with 536 additions and 1192 deletions

View File

@@ -34,14 +34,7 @@ import (
"github.com/prometheus-community/windows_exporter/pkg/collector/msmq"
"github.com/prometheus-community/windows_exporter/pkg/collector/mssql"
"github.com/prometheus-community/windows_exporter/pkg/collector/net"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrexceptions"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrinterop"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrjit"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrloading"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrlocksandthreads"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrmemory"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrremoting"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrsecurity"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework"
"github.com/prometheus-community/windows_exporter/pkg/collector/nps"
"github.com/prometheus-community/windows_exporter/pkg/collector/os"
"github.com/prometheus-community/windows_exporter/pkg/collector/perfdata"
@@ -108,14 +101,7 @@ func NewWithConfig(config Config) *MetricCollectors {
collectors[msmq.Name] = msmq.New(&config.Msmq)
collectors[mssql.Name] = mssql.New(&config.Mssql)
collectors[net.Name] = net.New(&config.Net)
collectors[netframework_clrexceptions.Name] = netframework_clrexceptions.New(&config.NetframeworkClrexceptions)
collectors[netframework_clrinterop.Name] = netframework_clrinterop.New(&config.NetframeworkClrinterop)
collectors[netframework_clrjit.Name] = netframework_clrjit.New(&config.NetframeworkClrjit)
collectors[netframework_clrloading.Name] = netframework_clrloading.New(&config.NetframeworkClrloading)
collectors[netframework_clrlocksandthreads.Name] = netframework_clrlocksandthreads.New(&config.NetframeworkClrlocksandthreads)
collectors[netframework_clrmemory.Name] = netframework_clrmemory.New(&config.NetframeworkClrmemory)
collectors[netframework_clrremoting.Name] = netframework_clrremoting.New(&config.NetframeworkClrremoting)
collectors[netframework_clrsecurity.Name] = netframework_clrsecurity.New(&config.NetframeworkClrsecurity)
collectors[netframework.Name] = netframework.New(&config.NetFramework)
collectors[nps.Name] = nps.New(&config.Nps)
collectors[os.Name] = os.New(&config.Os)
collectors[perfdata.Name] = perfdata.New(&config.PerfData)

View File

@@ -25,14 +25,7 @@ import (
"github.com/prometheus-community/windows_exporter/pkg/collector/msmq"
"github.com/prometheus-community/windows_exporter/pkg/collector/mssql"
"github.com/prometheus-community/windows_exporter/pkg/collector/net"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrexceptions"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrinterop"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrjit"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrloading"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrlocksandthreads"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrmemory"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrremoting"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrsecurity"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework"
"github.com/prometheus-community/windows_exporter/pkg/collector/nps"
"github.com/prometheus-community/windows_exporter/pkg/collector/os"
"github.com/prometheus-community/windows_exporter/pkg/collector/perfdata"
@@ -57,116 +50,102 @@ import (
)
type Config struct {
AD ad.Config `yaml:"ad"`
ADCS adcs.Config `yaml:"adcs"`
ADFS adfs.Config `yaml:"adfs"`
Cache cache.Config `yaml:"cache"`
Container container.Config `yaml:"container"`
CPU cpu.Config `yaml:"cpu"`
CPUInfo cpu_info.Config `yaml:"cpu_info"`
Cs cs.Config `yaml:"cs"`
DFSR dfsr.Config `yaml:"dfsr"`
Dhcp dhcp.Config `yaml:"dhcp"`
DiskDrive diskdrive.Config `yaml:"diskdrive"` //nolint:tagliatelle
DNS dns.Config `yaml:"dns"`
Exchange exchange.Config `yaml:"exchange"`
Fsrmquota fsrmquota.Config `yaml:"fsrmquota"`
Hyperv hyperv.Config `yaml:"hyperv"`
IIS iis.Config `yaml:"iis"`
License license.Config `yaml:"license"`
LogicalDisk logical_disk.Config `yaml:"logical_disk"`
Logon logon.Config `yaml:"logon"`
Memory memory.Config `yaml:"memory"`
Mscluster mscluster.Config `yaml:"mscluster"`
Msmq msmq.Config `yaml:"msmq"`
Mssql mssql.Config `yaml:"mssql"`
Net net.Config `yaml:"net"`
NetframeworkClrexceptions netframework_clrexceptions.Config `yaml:"netframework_clrexceptions"`
NetframeworkClrinterop netframework_clrinterop.Config `yaml:"netframework_clrinterop"`
NetframeworkClrjit netframework_clrjit.Config `yaml:"netframework_clrjit"`
NetframeworkClrloading netframework_clrloading.Config `yaml:"netframework_clrloading"`
NetframeworkClrlocksandthreads netframework_clrlocksandthreads.Config `yaml:"netframework_clrlocksandthreads"`
NetframeworkClrmemory netframework_clrmemory.Config `yaml:"netframework_clrmemory"`
NetframeworkClrremoting netframework_clrremoting.Config `yaml:"netframework_clrremoting"`
NetframeworkClrsecurity netframework_clrsecurity.Config `yaml:"netframework_clrsecurity"`
Nps nps.Config `yaml:"nps"`
Os os.Config `yaml:"os"`
PerfData perfdata.Config `yaml:"perf_data"`
PhysicalDisk physical_disk.Config `yaml:"physical_disk"`
Printer printer.Config `yaml:"printer"`
Process process.Config `yaml:"process"`
RemoteFx remote_fx.Config `yaml:"remote_fx"`
ScheduledTask scheduled_task.Config `yaml:"scheduled_task"`
Service service.Config `yaml:"service"`
SMB smb.Config `yaml:"smb"`
SMBClient smbclient.Config `yaml:"smbclient"` //nolint:tagliatelle
SMTP smtp.Config `yaml:"smtp"`
System system.Config `yaml:"system"`
TeradiciPcoip teradici_pcoip.Config `yaml:"teradici_pcoip"`
TCP tcp.Config `yaml:"tcp"`
TerminalServices terminal_services.Config `yaml:"terminal_services"`
Textfile textfile.Config `yaml:"textfile"`
Thermalzone thermalzone.Config `yaml:"thermalzone"`
Time time.Config `yaml:"time"`
Vmware vmware.Config `yaml:"vmware"`
VmwareBlast vmware_blast.Config `yaml:"vmware_blast"`
AD ad.Config `yaml:"ad"`
ADCS adcs.Config `yaml:"adcs"`
ADFS adfs.Config `yaml:"adfs"`
Cache cache.Config `yaml:"cache"`
Container container.Config `yaml:"container"`
CPU cpu.Config `yaml:"cpu"`
CPUInfo cpu_info.Config `yaml:"cpu_info"`
Cs cs.Config `yaml:"cs"`
DFSR dfsr.Config `yaml:"dfsr"`
Dhcp dhcp.Config `yaml:"dhcp"`
DiskDrive diskdrive.Config `yaml:"diskdrive"` //nolint:tagliatelle
DNS dns.Config `yaml:"dns"`
Exchange exchange.Config `yaml:"exchange"`
Fsrmquota fsrmquota.Config `yaml:"fsrmquota"`
Hyperv hyperv.Config `yaml:"hyperv"`
IIS iis.Config `yaml:"iis"`
License license.Config `yaml:"license"`
LogicalDisk logical_disk.Config `yaml:"logical_disk"`
Logon logon.Config `yaml:"logon"`
Memory memory.Config `yaml:"memory"`
Mscluster mscluster.Config `yaml:"mscluster"`
Msmq msmq.Config `yaml:"msmq"`
Mssql mssql.Config `yaml:"mssql"`
Net net.Config `yaml:"net"`
NetFramework netframework.Config `yaml:"net_framework"`
Nps nps.Config `yaml:"nps"`
Os os.Config `yaml:"os"`
PerfData perfdata.Config `yaml:"perf_data"`
PhysicalDisk physical_disk.Config `yaml:"physical_disk"`
Printer printer.Config `yaml:"printer"`
Process process.Config `yaml:"process"`
RemoteFx remote_fx.Config `yaml:"remote_fx"`
ScheduledTask scheduled_task.Config `yaml:"scheduled_task"`
Service service.Config `yaml:"service"`
SMB smb.Config `yaml:"smb"`
SMBClient smbclient.Config `yaml:"smbclient"` //nolint:tagliatelle
SMTP smtp.Config `yaml:"smtp"`
System system.Config `yaml:"system"`
TeradiciPcoip teradici_pcoip.Config `yaml:"teradici_pcoip"`
TCP tcp.Config `yaml:"tcp"`
TerminalServices terminal_services.Config `yaml:"terminal_services"`
Textfile textfile.Config `yaml:"textfile"`
Thermalzone thermalzone.Config `yaml:"thermalzone"`
Time time.Config `yaml:"time"`
Vmware vmware.Config `yaml:"vmware"`
VmwareBlast vmware_blast.Config `yaml:"vmware_blast"`
}
// ConfigDefaults Is an interface to be used by the external libraries. It holds all ConfigDefaults form all collectors
//
//goland:noinspection GoUnusedGlobalVariable
var ConfigDefaults = Config{
AD: ad.ConfigDefaults,
ADCS: adcs.ConfigDefaults,
ADFS: adfs.ConfigDefaults,
Cache: cache.ConfigDefaults,
Container: container.ConfigDefaults,
CPU: cpu.ConfigDefaults,
CPUInfo: cpu_info.ConfigDefaults,
Cs: cs.ConfigDefaults,
DFSR: dfsr.ConfigDefaults,
Dhcp: dhcp.ConfigDefaults,
DiskDrive: diskdrive.ConfigDefaults,
DNS: dns.ConfigDefaults,
Exchange: exchange.ConfigDefaults,
Fsrmquota: fsrmquota.ConfigDefaults,
Hyperv: hyperv.ConfigDefaults,
IIS: iis.ConfigDefaults,
License: license.ConfigDefaults,
LogicalDisk: logical_disk.ConfigDefaults,
Logon: logon.ConfigDefaults,
Memory: memory.ConfigDefaults,
Mscluster: mscluster.ConfigDefaults,
Msmq: msmq.ConfigDefaults,
Mssql: mssql.ConfigDefaults,
Net: net.ConfigDefaults,
NetframeworkClrexceptions: netframework_clrexceptions.ConfigDefaults,
NetframeworkClrinterop: netframework_clrinterop.ConfigDefaults,
NetframeworkClrjit: netframework_clrjit.ConfigDefaults,
NetframeworkClrloading: netframework_clrloading.ConfigDefaults,
NetframeworkClrlocksandthreads: netframework_clrlocksandthreads.ConfigDefaults,
NetframeworkClrmemory: netframework_clrmemory.ConfigDefaults,
NetframeworkClrremoting: netframework_clrremoting.ConfigDefaults,
NetframeworkClrsecurity: netframework_clrsecurity.ConfigDefaults,
Nps: nps.ConfigDefaults,
Os: os.ConfigDefaults,
PerfData: perfdata.ConfigDefaults,
PhysicalDisk: physical_disk.ConfigDefaults,
Printer: printer.ConfigDefaults,
Process: process.ConfigDefaults,
RemoteFx: remote_fx.ConfigDefaults,
ScheduledTask: scheduled_task.ConfigDefaults,
Service: service.ConfigDefaults,
SMB: smb.ConfigDefaults,
SMBClient: smbclient.ConfigDefaults,
SMTP: smtp.ConfigDefaults,
System: system.ConfigDefaults,
TeradiciPcoip: teradici_pcoip.ConfigDefaults,
TCP: tcp.ConfigDefaults,
TerminalServices: terminal_services.ConfigDefaults,
Textfile: textfile.ConfigDefaults,
Thermalzone: thermalzone.ConfigDefaults,
Time: time.ConfigDefaults,
Vmware: vmware.ConfigDefaults,
VmwareBlast: vmware_blast.ConfigDefaults,
AD: ad.ConfigDefaults,
ADCS: adcs.ConfigDefaults,
ADFS: adfs.ConfigDefaults,
Cache: cache.ConfigDefaults,
Container: container.ConfigDefaults,
CPU: cpu.ConfigDefaults,
CPUInfo: cpu_info.ConfigDefaults,
Cs: cs.ConfigDefaults,
DFSR: dfsr.ConfigDefaults,
Dhcp: dhcp.ConfigDefaults,
DiskDrive: diskdrive.ConfigDefaults,
DNS: dns.ConfigDefaults,
Exchange: exchange.ConfigDefaults,
Fsrmquota: fsrmquota.ConfigDefaults,
Hyperv: hyperv.ConfigDefaults,
IIS: iis.ConfigDefaults,
License: license.ConfigDefaults,
LogicalDisk: logical_disk.ConfigDefaults,
Logon: logon.ConfigDefaults,
Memory: memory.ConfigDefaults,
Mscluster: mscluster.ConfigDefaults,
Msmq: msmq.ConfigDefaults,
Mssql: mssql.ConfigDefaults,
Net: net.ConfigDefaults,
NetFramework: netframework.ConfigDefaults,
Nps: nps.ConfigDefaults,
Os: os.ConfigDefaults,
PerfData: perfdata.ConfigDefaults,
PhysicalDisk: physical_disk.ConfigDefaults,
Printer: printer.ConfigDefaults,
Process: process.ConfigDefaults,
RemoteFx: remote_fx.ConfigDefaults,
ScheduledTask: scheduled_task.ConfigDefaults,
Service: service.ConfigDefaults,
SMB: smb.ConfigDefaults,
SMBClient: smbclient.ConfigDefaults,
SMTP: smtp.ConfigDefaults,
System: system.ConfigDefaults,
TeradiciPcoip: teradici_pcoip.ConfigDefaults,
TCP: tcp.ConfigDefaults,
TerminalServices: terminal_services.ConfigDefaults,
Textfile: textfile.ConfigDefaults,
Thermalzone: thermalzone.ConfigDefaults,
Time: time.ConfigDefaults,
Vmware: vmware.ConfigDefaults,
VmwareBlast: vmware_blast.ConfigDefaults,
}

View File

@@ -29,14 +29,7 @@ import (
"github.com/prometheus-community/windows_exporter/pkg/collector/msmq"
"github.com/prometheus-community/windows_exporter/pkg/collector/mssql"
"github.com/prometheus-community/windows_exporter/pkg/collector/net"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrexceptions"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrinterop"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrjit"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrloading"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrlocksandthreads"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrmemory"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrremoting"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrsecurity"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework"
"github.com/prometheus-community/windows_exporter/pkg/collector/nps"
"github.com/prometheus-community/windows_exporter/pkg/collector/os"
"github.com/prometheus-community/windows_exporter/pkg/collector/perfdata"
@@ -67,59 +60,52 @@ func NewBuilderWithFlags[C Collector](fn BuilderWithFlags[C]) BuilderWithFlags[C
}
var BuildersWithFlags = map[string]BuilderWithFlags[Collector]{
ad.Name: NewBuilderWithFlags(ad.NewWithFlags),
adcs.Name: NewBuilderWithFlags(adcs.NewWithFlags),
adfs.Name: NewBuilderWithFlags(adfs.NewWithFlags),
cache.Name: NewBuilderWithFlags(cache.NewWithFlags),
container.Name: NewBuilderWithFlags(container.NewWithFlags),
cpu.Name: NewBuilderWithFlags(cpu.NewWithFlags),
cpu_info.Name: NewBuilderWithFlags(cpu_info.NewWithFlags),
cs.Name: NewBuilderWithFlags(cs.NewWithFlags),
dfsr.Name: NewBuilderWithFlags(dfsr.NewWithFlags),
dhcp.Name: NewBuilderWithFlags(dhcp.NewWithFlags),
diskdrive.Name: NewBuilderWithFlags(diskdrive.NewWithFlags),
dns.Name: NewBuilderWithFlags(dns.NewWithFlags),
exchange.Name: NewBuilderWithFlags(exchange.NewWithFlags),
fsrmquota.Name: NewBuilderWithFlags(fsrmquota.NewWithFlags),
hyperv.Name: NewBuilderWithFlags(hyperv.NewWithFlags),
iis.Name: NewBuilderWithFlags(iis.NewWithFlags),
license.Name: NewBuilderWithFlags(license.NewWithFlags),
logical_disk.Name: NewBuilderWithFlags(logical_disk.NewWithFlags),
logon.Name: NewBuilderWithFlags(logon.NewWithFlags),
memory.Name: NewBuilderWithFlags(memory.NewWithFlags),
mscluster.Name: NewBuilderWithFlags(mscluster.NewWithFlags),
msmq.Name: NewBuilderWithFlags(msmq.NewWithFlags),
mssql.Name: NewBuilderWithFlags(mssql.NewWithFlags),
net.Name: NewBuilderWithFlags(net.NewWithFlags),
netframework_clrexceptions.Name: NewBuilderWithFlags(netframework_clrexceptions.NewWithFlags),
netframework_clrinterop.Name: NewBuilderWithFlags(netframework_clrinterop.NewWithFlags),
netframework_clrjit.Name: NewBuilderWithFlags(netframework_clrjit.NewWithFlags),
netframework_clrloading.Name: NewBuilderWithFlags(netframework_clrloading.NewWithFlags),
netframework_clrlocksandthreads.Name: NewBuilderWithFlags(netframework_clrlocksandthreads.NewWithFlags),
netframework_clrmemory.Name: NewBuilderWithFlags(netframework_clrmemory.NewWithFlags),
netframework_clrremoting.Name: NewBuilderWithFlags(netframework_clrremoting.NewWithFlags),
netframework_clrsecurity.Name: NewBuilderWithFlags(netframework_clrsecurity.NewWithFlags),
nps.Name: NewBuilderWithFlags(nps.NewWithFlags),
os.Name: NewBuilderWithFlags(os.NewWithFlags),
perfdata.Name: NewBuilderWithFlags(perfdata.NewWithFlags),
physical_disk.Name: NewBuilderWithFlags(physical_disk.NewWithFlags),
printer.Name: NewBuilderWithFlags(printer.NewWithFlags),
process.Name: NewBuilderWithFlags(process.NewWithFlags),
remote_fx.Name: NewBuilderWithFlags(remote_fx.NewWithFlags),
scheduled_task.Name: NewBuilderWithFlags(scheduled_task.NewWithFlags),
service.Name: NewBuilderWithFlags(service.NewWithFlags),
smb.Name: NewBuilderWithFlags(smb.NewWithFlags),
smbclient.Name: NewBuilderWithFlags(smbclient.NewWithFlags),
smtp.Name: NewBuilderWithFlags(smtp.NewWithFlags),
system.Name: NewBuilderWithFlags(system.NewWithFlags),
teradici_pcoip.Name: NewBuilderWithFlags(teradici_pcoip.NewWithFlags),
tcp.Name: NewBuilderWithFlags(tcp.NewWithFlags),
terminal_services.Name: NewBuilderWithFlags(terminal_services.NewWithFlags),
textfile.Name: NewBuilderWithFlags(textfile.NewWithFlags),
thermalzone.Name: NewBuilderWithFlags(thermalzone.NewWithFlags),
time.Name: NewBuilderWithFlags(time.NewWithFlags),
vmware.Name: NewBuilderWithFlags(vmware.NewWithFlags),
vmware_blast.Name: NewBuilderWithFlags(vmware_blast.NewWithFlags),
ad.Name: NewBuilderWithFlags(ad.NewWithFlags),
adcs.Name: NewBuilderWithFlags(adcs.NewWithFlags),
adfs.Name: NewBuilderWithFlags(adfs.NewWithFlags),
cache.Name: NewBuilderWithFlags(cache.NewWithFlags),
container.Name: NewBuilderWithFlags(container.NewWithFlags),
cpu.Name: NewBuilderWithFlags(cpu.NewWithFlags),
cpu_info.Name: NewBuilderWithFlags(cpu_info.NewWithFlags),
cs.Name: NewBuilderWithFlags(cs.NewWithFlags),
dfsr.Name: NewBuilderWithFlags(dfsr.NewWithFlags),
dhcp.Name: NewBuilderWithFlags(dhcp.NewWithFlags),
diskdrive.Name: NewBuilderWithFlags(diskdrive.NewWithFlags),
dns.Name: NewBuilderWithFlags(dns.NewWithFlags),
exchange.Name: NewBuilderWithFlags(exchange.NewWithFlags),
fsrmquota.Name: NewBuilderWithFlags(fsrmquota.NewWithFlags),
hyperv.Name: NewBuilderWithFlags(hyperv.NewWithFlags),
iis.Name: NewBuilderWithFlags(iis.NewWithFlags),
license.Name: NewBuilderWithFlags(license.NewWithFlags),
logical_disk.Name: NewBuilderWithFlags(logical_disk.NewWithFlags),
logon.Name: NewBuilderWithFlags(logon.NewWithFlags),
memory.Name: NewBuilderWithFlags(memory.NewWithFlags),
mscluster.Name: NewBuilderWithFlags(mscluster.NewWithFlags),
msmq.Name: NewBuilderWithFlags(msmq.NewWithFlags),
mssql.Name: NewBuilderWithFlags(mssql.NewWithFlags),
net.Name: NewBuilderWithFlags(net.NewWithFlags),
netframework.Name: NewBuilderWithFlags(netframework.NewWithFlags),
nps.Name: NewBuilderWithFlags(nps.NewWithFlags),
os.Name: NewBuilderWithFlags(os.NewWithFlags),
perfdata.Name: NewBuilderWithFlags(perfdata.NewWithFlags),
physical_disk.Name: NewBuilderWithFlags(physical_disk.NewWithFlags),
printer.Name: NewBuilderWithFlags(printer.NewWithFlags),
process.Name: NewBuilderWithFlags(process.NewWithFlags),
remote_fx.Name: NewBuilderWithFlags(remote_fx.NewWithFlags),
scheduled_task.Name: NewBuilderWithFlags(scheduled_task.NewWithFlags),
service.Name: NewBuilderWithFlags(service.NewWithFlags),
smb.Name: NewBuilderWithFlags(smb.NewWithFlags),
smbclient.Name: NewBuilderWithFlags(smbclient.NewWithFlags),
smtp.Name: NewBuilderWithFlags(smtp.NewWithFlags),
system.Name: NewBuilderWithFlags(system.NewWithFlags),
teradici_pcoip.Name: NewBuilderWithFlags(teradici_pcoip.NewWithFlags),
tcp.Name: NewBuilderWithFlags(tcp.NewWithFlags),
terminal_services.Name: NewBuilderWithFlags(terminal_services.NewWithFlags),
textfile.Name: NewBuilderWithFlags(textfile.NewWithFlags),
thermalzone.Name: NewBuilderWithFlags(thermalzone.NewWithFlags),
time.Name: NewBuilderWithFlags(time.NewWithFlags),
vmware.Name: NewBuilderWithFlags(vmware.NewWithFlags),
vmware_blast.Name: NewBuilderWithFlags(vmware_blast.NewWithFlags),
}
func Available() []string {

View File

@@ -298,9 +298,5 @@ func (c *Collector) Collect(_ *types.ScrapeContext, _ *slog.Logger, ch chan<- pr
}
}
if len(errs) > 0 {
return errors.Join(errs...)
}
return nil
return errors.Join(errs...)
}

View File

@@ -0,0 +1,245 @@
//go:build windows
package netframework
import (
"errors"
"fmt"
"log/slog"
"slices"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework"
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
}
var ConfigDefaults = Config{
CollectorsEnabled: []string{
collectorClrExceptions,
collectorClrInterop,
collectorClrJIT,
collectorClrLoading,
collectorClrLocksAndThreads,
collectorClrMemory,
collectorClrRemoting,
collectorClrSecurity,
},
}
const (
collectorClrExceptions = "clrexceptions"
collectorClrInterop = "clrinterop"
collectorClrJIT = "clrjit"
collectorClrLoading = "clrloading"
collectorClrLocksAndThreads = "clrlocksandthreads"
collectorClrMemory = "clrmemory"
collectorClrRemoting = "clrremoting"
collectorClrSecurity = "clrsecurity"
)
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRExceptions metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
// clrexceptions
numberOfExceptionsThrown *prometheus.Desc
numberOfFilters *prometheus.Desc
numberOfFinally *prometheus.Desc
throwToCatchDepth *prometheus.Desc
// clrinterop
numberOfCCWs *prometheus.Desc
numberOfMarshalling *prometheus.Desc
numberOfStubs *prometheus.Desc
// clrjit
numberOfMethodsJitted *prometheus.Desc
timeInJit *prometheus.Desc
standardJitFailures *prometheus.Desc
totalNumberOfILBytesJitted *prometheus.Desc
// clrloading
bytesInLoaderHeap *prometheus.Desc
currentAppDomains *prometheus.Desc
currentAssemblies *prometheus.Desc
currentClassesLoaded *prometheus.Desc
totalAppDomains *prometheus.Desc
totalAppDomainsUnloaded *prometheus.Desc
totalAssemblies *prometheus.Desc
totalClassesLoaded *prometheus.Desc
totalNumberOfLoadFailures *prometheus.Desc
// clrlocksandthreads
currentQueueLength *prometheus.Desc
numberOfCurrentLogicalThreads *prometheus.Desc
numberOfCurrentPhysicalThreads *prometheus.Desc
numberOfCurrentRecognizedThreads *prometheus.Desc
numberOfTotalRecognizedThreads *prometheus.Desc
queueLengthPeak *prometheus.Desc
totalNumberOfContentions *prometheus.Desc
// clrmemory
allocatedBytes *prometheus.Desc
finalizationSurvivors *prometheus.Desc
heapSize *prometheus.Desc
promotedBytes *prometheus.Desc
numberGCHandles *prometheus.Desc
numberCollections *prometheus.Desc
numberInducedGC *prometheus.Desc
numberOfPinnedObjects *prometheus.Desc
numberOfSinkBlocksInUse *prometheus.Desc
numberTotalCommittedBytes *prometheus.Desc
numberTotalReservedBytes *prometheus.Desc
timeInGC *prometheus.Desc
// clrremoting
channels *prometheus.Desc
contextBoundClassesLoaded *prometheus.Desc
contextBoundObjects *prometheus.Desc
contextProxies *prometheus.Desc
contexts *prometheus.Desc
totalRemoteCalls *prometheus.Desc
// clrsecurity
numberLinkTimeChecks *prometheus.Desc
timeInRTChecks *prometheus.Desc
stackWalkDepth *prometheus.Desc
totalRuntimeChecks *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
return errors.New("wmiClient or SWbemServicesClient is nil")
}
c.wmiClient = wmiClient
if slices.Contains(c.config.CollectorsEnabled, collectorClrExceptions) {
c.buildClrExceptions()
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrInterop) {
c.buildClrInterop()
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrJIT) {
c.buildClrJIT()
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrLoading) {
c.buildClrLoading()
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrLocksAndThreads) {
c.buildClrLocksAndThreads()
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrMemory) {
c.buildClrMemory()
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrRemoting) {
c.buildClrRemoting()
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrSecurity) {
c.buildClrSecurity()
}
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, _ *slog.Logger, ch chan<- prometheus.Metric) error {
var (
err error
errs []error
)
if slices.Contains(c.config.CollectorsEnabled, collectorClrExceptions) {
if err = c.collectClrExceptions(ch); err != nil {
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrExceptions, err))
}
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrInterop) {
if err = c.collectClrInterop(ch); err != nil {
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrInterop, err))
}
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrJIT) {
if err = c.collectClrJIT(ch); err != nil {
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrJIT, err))
}
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrLoading) {
if err = c.collectClrLoading(ch); err != nil {
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrLoading, err))
}
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrLocksAndThreads) {
if err = c.collectClrLocksAndThreads(ch); err != nil {
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrLocksAndThreads, err))
}
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrMemory) {
if err = c.collectClrMemory(ch); err != nil {
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrMemory, err))
}
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrRemoting) {
if err = c.collectClrRemoting(ch); err != nil {
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrRemoting, err))
}
}
if slices.Contains(c.config.CollectorsEnabled, collectorClrSecurity) {
if err = c.collectClrSecurity(ch); err != nil {
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrSecurity, err))
}
}
return errors.Join(errs...)
}

View File

@@ -1,68 +1,13 @@
//go:build windows
package netframework_clrexceptions
package netframework
import (
"errors"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework_clrexceptions"
type Config struct{}
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRExceptions metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
numberOfExceptionsThrown *prometheus.Desc
numberOfFilters *prometheus.Desc
numberOfFinally *prometheus.Desc
throwToCatchDepth *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
return errors.New("wmiClient or SWbemServicesClient is nil")
}
c.wmiClient = wmiClient
func (c *Collector) buildClrExceptions() {
c.numberOfExceptionsThrown = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "exceptions_thrown_total"),
"Displays the total number of exceptions thrown since the application started. This includes both .NET exceptions and unmanaged exceptions that are converted into .NET exceptions.",
@@ -87,23 +32,6 @@ func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
[]string{"process"},
nil,
)
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
if err := c.collect(ch); err != nil {
logger.Error("failed collecting win32_perfrawdata_netframework_netclrexceptions metrics",
slog.Any("err", err),
)
return err
}
return nil
}
type Win32_PerfRawData_NETFramework_NETCLRExceptions struct {
@@ -116,7 +44,7 @@ type Win32_PerfRawData_NETFramework_NETCLRExceptions struct {
ThrowToCatchDepthPersec uint32
}
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
func (c *Collector) collectClrExceptions(ch chan<- prometheus.Metric) error {
var dst []Win32_PerfRawData_NETFramework_NETCLRExceptions
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRExceptions", &dst); err != nil {
return err

View File

@@ -1,67 +1,13 @@
//go:build windows
package netframework_clrinterop
package netframework
import (
"errors"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework_clrinterop"
type Config struct{}
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRInterop metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
numberOfCCWs *prometheus.Desc
numberOfMarshalling *prometheus.Desc
numberOfStubs *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
return errors.New("wmiClient or SWbemServicesClient is nil")
}
c.wmiClient = wmiClient
func (c *Collector) buildClrInterop() {
c.numberOfCCWs = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "com_callable_wrappers_total"),
"Displays the current number of COM callable wrappers (CCWs). A CCW is a proxy for a managed object being referenced from an unmanaged COM client.",
@@ -80,23 +26,6 @@ func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
[]string{"process"},
nil,
)
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
if err := c.collect(ch); err != nil {
logger.Error("failed collecting win32_perfrawdata_netframework_netclrinterop metrics",
slog.Any("err", err),
)
return err
}
return nil
}
type Win32_PerfRawData_NETFramework_NETCLRInterop struct {
@@ -109,7 +38,7 @@ type Win32_PerfRawData_NETFramework_NETCLRInterop struct {
NumberofTLBimportsPersec uint32
}
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
func (c *Collector) collectClrInterop(ch chan<- prometheus.Metric) error {
var dst []Win32_PerfRawData_NETFramework_NETCLRInterop
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRInterop", &dst); err != nil {
return err

View File

@@ -1,62 +1,13 @@
//go:build windows
package netframework_clrjit
package netframework
import (
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework_clrjit"
type Config struct{}
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRJit metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
numberOfMethodsJitted *prometheus.Desc
timeInJit *prometheus.Desc
standardJitFailures *prometheus.Desc
totalNumberOfILBytesJitted *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
func (c *Collector) buildClrJIT() {
c.numberOfMethodsJitted = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "jit_methods_total"),
"Displays the total number of methods JIT-compiled since the application started. This counter does not include pre-JIT-compiled methods.",
@@ -81,23 +32,6 @@ func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
[]string{"process"},
nil,
)
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
if err := c.collect(ch); err != nil {
logger.Error("failed collecting win32_perfrawdata_netframework_netclrjit metrics",
slog.Any("err", err),
)
return err
}
return nil
}
type Win32_PerfRawData_NETFramework_NETCLRJit struct {
@@ -112,7 +46,7 @@ type Win32_PerfRawData_NETFramework_NETCLRJit struct {
TotalNumberofILBytesJitted uint32
}
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
func (c *Collector) collectClrJIT(ch chan<- prometheus.Metric) error {
var dst []Win32_PerfRawData_NETFramework_NETCLRJit
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRJit", &dst); err != nil {
return err

View File

@@ -1,74 +1,13 @@
//go:build windows
package netframework_clrloading
package netframework
import (
"errors"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework_clrloading"
type Config struct{}
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRLoading metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
bytesInLoaderHeap *prometheus.Desc
currentAppDomains *prometheus.Desc
currentAssemblies *prometheus.Desc
currentClassesLoaded *prometheus.Desc
totalAppDomains *prometheus.Desc
totalAppDomainsUnloaded *prometheus.Desc
totalAssemblies *prometheus.Desc
totalClassesLoaded *prometheus.Desc
totalNumberOfLoadFailures *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
return errors.New("wmiClient or SWbemServicesClient is nil")
}
c.wmiClient = wmiClient
func (c *Collector) buildClrLoading() {
c.bytesInLoaderHeap = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "loader_heap_size_bytes"),
"Displays the current size, in bytes, of the memory committed by the class loader across all application domains. Committed memory is the physical space reserved in the disk paging file.",
@@ -123,23 +62,6 @@ func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
[]string{"process"},
nil,
)
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
if err := c.collect(ch); err != nil {
logger.Error("failed collecting win32_perfrawdata_netframework_netclrloading metrics",
slog.Any("err", err),
)
return err
}
return nil
}
type Win32_PerfRawData_NETFramework_NETCLRLoading struct {
@@ -163,7 +85,7 @@ type Win32_PerfRawData_NETFramework_NETCLRLoading struct {
TotalNumberofLoadFailures uint32
}
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
func (c *Collector) collectClrLoading(ch chan<- prometheus.Metric) error {
var dst []Win32_PerfRawData_NETFramework_NETCLRLoading
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRLoading", &dst); err != nil {
return err

View File

@@ -1,72 +1,13 @@
//go:build windows
package netframework_clrlocksandthreads
package netframework
import (
"errors"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework_clrlocksandthreads"
type Config struct{}
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
currentQueueLength *prometheus.Desc
numberOfCurrentLogicalThreads *prometheus.Desc
numberOfCurrentPhysicalThreads *prometheus.Desc
numberOfCurrentRecognizedThreads *prometheus.Desc
numberOfTotalRecognizedThreads *prometheus.Desc
queueLengthPeak *prometheus.Desc
totalNumberOfContentions *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
return errors.New("wmiClient or SWbemServicesClient is nil")
}
c.wmiClient = wmiClient
func (c *Collector) buildClrLocksAndThreads() {
c.currentQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "current_queue_length"),
"Displays the total number of threads that are currently waiting to acquire a managed lock in the application.",
@@ -109,23 +50,6 @@ func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
[]string{"process"},
nil,
)
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
if err := c.collect(ch); err != nil {
logger.Error("failed collecting win32_perfrawdata_netframework_netclrlocksandthreads metrics",
slog.Any("err", err),
)
return err
}
return nil
}
type Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads struct {
@@ -143,7 +67,7 @@ type Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads struct {
TotalNumberofContentions uint32
}
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
func (c *Collector) collectClrLocksAndThreads(ch chan<- prometheus.Metric) error {
var dst []Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads", &dst); err != nil {
return err

View File

@@ -1,77 +1,13 @@
//go:build windows
package netframework_clrmemory
package netframework
import (
"errors"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework_clrmemory"
type Config struct{}
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRMemory metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
allocatedBytes *prometheus.Desc
finalizationSurvivors *prometheus.Desc
heapSize *prometheus.Desc
promotedBytes *prometheus.Desc
numberGCHandles *prometheus.Desc
numberCollections *prometheus.Desc
numberInducedGC *prometheus.Desc
numberOfPinnedObjects *prometheus.Desc
numberOfSinkBlocksInUse *prometheus.Desc
numberTotalCommittedBytes *prometheus.Desc
numberTotalReservedBytes *prometheus.Desc
timeInGC *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
return errors.New("wmiClient or SWbemServicesClient is nil")
}
c.wmiClient = wmiClient
func (c *Collector) buildClrMemory() {
c.allocatedBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "allocated_bytes_total"),
"Displays the total number of bytes allocated on the garbage collection heap.",
@@ -144,23 +80,6 @@ func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
[]string{"process"},
nil,
)
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
if err := c.collect(ch); err != nil {
logger.Error("failed collecting win32_perfrawdata_netframework_netclrmemory metrics",
slog.Any("err", err),
)
return err
}
return nil
}
type Win32_PerfRawData_NETFramework_NETCLRMemory struct {
@@ -197,7 +116,7 @@ type Win32_PerfRawData_NETFramework_NETCLRMemory struct {
PromotedMemoryfromGen1 uint64
}
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
func (c *Collector) collectClrMemory(ch chan<- prometheus.Metric) error {
var dst []Win32_PerfRawData_NETFramework_NETCLRMemory
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRMemory", &dst); err != nil {
return err

View File

@@ -1,71 +1,13 @@
//go:build windows
package netframework_clrremoting
package netframework
import (
"errors"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework_clrremoting"
type Config struct{}
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRRemoting metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
channels *prometheus.Desc
contextBoundClassesLoaded *prometheus.Desc
contextBoundObjects *prometheus.Desc
contextProxies *prometheus.Desc
contexts *prometheus.Desc
totalRemoteCalls *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
return errors.New("wmiClient or SWbemServicesClient is nil")
}
c.wmiClient = wmiClient
func (c *Collector) buildClrRemoting() {
c.channels = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "channels_total"),
"Displays the total number of remoting channels registered across all application domains since application started.",
@@ -102,23 +44,6 @@ func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
[]string{"process"},
nil,
)
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
if err := c.collect(ch); err != nil {
logger.Error("failed collecting win32_perfrawdata_netframework_netclrremoting metrics",
slog.Any("err", err),
)
return err
}
return nil
}
type Win32_PerfRawData_NETFramework_NETCLRRemoting struct {
@@ -133,7 +58,7 @@ type Win32_PerfRawData_NETFramework_NETCLRRemoting struct {
TotalRemoteCalls uint32
}
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
func (c *Collector) collectClrRemoting(ch chan<- prometheus.Metric) error {
var dst []Win32_PerfRawData_NETFramework_NETCLRRemoting
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRRemoting", &dst); err != nil {
return err

View File

@@ -1,68 +1,13 @@
//go:build windows
package netframework_clrsecurity
package netframework
import (
"errors"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/pkg/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusufpapurcu/wmi"
)
const Name = "netframework_clrsecurity"
type Config struct{}
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRSecurity metrics.
type Collector struct {
config Config
wmiClient *wmi.Client
numberLinkTimeChecks *prometheus.Desc
timeInRTChecks *prometheus.Desc
stackWalkDepth *prometheus.Desc
totalRuntimeChecks *prometheus.Desc
}
func New(config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
}
c := &Collector{
config: *config,
}
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
}
func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
return errors.New("wmiClient or SWbemServicesClient is nil")
}
c.wmiClient = wmiClient
func (c *Collector) buildClrSecurity() {
c.numberLinkTimeChecks = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "link_time_checks_total"),
"Displays the total number of link-time code access security checks since the application started.",
@@ -87,23 +32,6 @@ func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
[]string{"process"},
nil,
)
return nil
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
if err := c.collect(ch); err != nil {
logger.Error("failed collecting win32_perfrawdata_netframework_netclrsecurity metrics",
slog.Any("err", err),
)
return err
}
return nil
}
type Win32_PerfRawData_NETFramework_NETCLRSecurity struct {
@@ -117,7 +45,7 @@ type Win32_PerfRawData_NETFramework_NETCLRSecurity struct {
TotalRuntimeChecks uint32
}
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
func (c *Collector) collectClrSecurity(ch chan<- prometheus.Metric) error {
var dst []Win32_PerfRawData_NETFramework_NETCLRSecurity
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRSecurity", &dst); err != nil {
return err

View File

@@ -1,13 +1,13 @@
package netframework_clrexceptions_test
package netframework_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrexceptions"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework"
"github.com/prometheus-community/windows_exporter/pkg/testutils"
)
func BenchmarkCollector(b *testing.B) {
// No context name required as Collector source is WMI
testutils.FuncBenchmarkCollector(b, netframework_clrexceptions.Name, netframework_clrexceptions.NewWithFlags)
testutils.FuncBenchmarkCollector(b, netframework.Name, netframework.NewWithFlags)
}

View File

@@ -1,13 +0,0 @@
package netframework_clrinterop_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrinterop"
"github.com/prometheus-community/windows_exporter/pkg/testutils"
)
func BenchmarkCollector(b *testing.B) {
// No context name required as collector source is WMI
testutils.FuncBenchmarkCollector(b, netframework_clrinterop.Name, netframework_clrinterop.NewWithFlags)
}

View File

@@ -1,13 +0,0 @@
package netframework_clrjit_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrjit"
"github.com/prometheus-community/windows_exporter/pkg/testutils"
)
func BenchmarkCollector(b *testing.B) {
// No context name required as collector source is WMI
testutils.FuncBenchmarkCollector(b, netframework_clrjit.Name, netframework_clrjit.NewWithFlags)
}

View File

@@ -1,13 +0,0 @@
package netframework_clrloading_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrloading"
"github.com/prometheus-community/windows_exporter/pkg/testutils"
)
func BenchmarkCollector(b *testing.B) {
// No context name required as collector source is WMI
testutils.FuncBenchmarkCollector(b, netframework_clrloading.Name, netframework_clrloading.NewWithFlags)
}

View File

@@ -1,13 +0,0 @@
package netframework_clrlocksandthreads_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrlocksandthreads"
"github.com/prometheus-community/windows_exporter/pkg/testutils"
)
func BenchmarkCollector(b *testing.B) {
// No context name required as collector source is WMI
testutils.FuncBenchmarkCollector(b, netframework_clrlocksandthreads.Name, netframework_clrlocksandthreads.NewWithFlags)
}

View File

@@ -1,13 +0,0 @@
package netframework_clrmemory_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrmemory"
"github.com/prometheus-community/windows_exporter/pkg/testutils"
)
func BenchmarkCollector(b *testing.B) {
// No context name required as collector source is WMI
testutils.FuncBenchmarkCollector(b, netframework_clrmemory.Name, netframework_clrmemory.NewWithFlags)
}

View File

@@ -1,13 +0,0 @@
package netframework_clrremoting_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrremoting"
"github.com/prometheus-community/windows_exporter/pkg/testutils"
)
func BenchmarkCollector(b *testing.B) {
// No context name required as collector source is WMI
testutils.FuncBenchmarkCollector(b, netframework_clrremoting.Name, netframework_clrremoting.NewWithFlags)
}

View File

@@ -1,13 +0,0 @@
package netframework_clrsecurity_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrsecurity"
"github.com/prometheus-community/windows_exporter/pkg/testutils"
)
func BenchmarkCollector(b *testing.B) {
// No context name required as collector source is WMI
testutils.FuncBenchmarkCollector(b, netframework_clrsecurity.Name, netframework_clrsecurity.NewWithFlags)
}