Merge pull request #1112 from breed808/remove_init

Remove init functions from collectors
This commit is contained in:
Ben Reedy
2023-04-01 18:17:27 +10:00
committed by GitHub
84 changed files with 406 additions and 317 deletions

View File

@@ -11,10 +11,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("ad", NewADCollector)
}
// A ADCollector is a Prometheus collector for WMI Win32_PerfRawData_DirectoryServices_DirectoryServices metrics // A ADCollector is a Prometheus collector for WMI Win32_PerfRawData_DirectoryServices_DirectoryServices metrics
type ADCollector struct { type ADCollector struct {
AddressBookOperationsTotal *prometheus.Desc AddressBookOperationsTotal *prometheus.Desc
@@ -80,8 +76,8 @@ type ADCollector struct {
TombstonedObjectsVisitedTotal *prometheus.Desc TombstonedObjectsVisitedTotal *prometheus.Desc
} }
// NewADCollector ... // newADCollector ...
func NewADCollector() (Collector, error) { func newADCollector() (Collector, error) {
const subsystem = "ad" const subsystem = "ad"
return &ADCollector{ return &ADCollector{
AddressBookOperationsTotal: prometheus.NewDesc( AddressBookOperationsTotal: prometheus.NewDesc(

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkADCollector(b *testing.B) { func BenchmarkADCollector(b *testing.B) {
benchmarkCollector(b, "ad", NewADCollector) benchmarkCollector(b, "ad", newADCollector)
} }

View File

@@ -10,10 +10,6 @@ import (
"strings" "strings"
) )
func init() {
registerCollector("adcs", adcsCollectorMethod, "Certification Authority")
}
type adcsCollector struct { type adcsCollector struct {
RequestsPerSecond *prometheus.Desc RequestsPerSecond *prometheus.Desc
RequestProcessingTime *prometheus.Desc RequestProcessingTime *prometheus.Desc

View File

@@ -8,10 +8,6 @@ import (
"math" "math"
) )
func init() {
registerCollector("adfs", newADFSCollector, "AD FS")
}
type adfsCollector struct { type adfsCollector struct {
adLoginConnectionFailures *prometheus.Desc adLoginConnectionFailures *prometheus.Desc
certificateAuthentications *prometheus.Desc certificateAuthentications *prometheus.Desc

View File

@@ -8,10 +8,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("cache", newCacheCollector, "Cache")
}
// A CacheCollector is a Prometheus collector for Perflib Cache metrics // A CacheCollector is a Prometheus collector for Perflib Cache metrics
type CacheCollector struct { type CacheCollector struct {
AsyncCopyReadsTotal *prometheus.Desc AsyncCopyReadsTotal *prometheus.Desc

View File

@@ -9,10 +9,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("container", NewContainerMetricsCollector)
}
// A ContainerMetricsCollector is a Prometheus collector for containers metrics // A ContainerMetricsCollector is a Prometheus collector for containers metrics
type ContainerMetricsCollector struct { type ContainerMetricsCollector struct {
// Presence // Presence
@@ -45,8 +41,8 @@ type ContainerMetricsCollector struct {
WriteSizeBytes *prometheus.Desc WriteSizeBytes *prometheus.Desc
} }
// NewContainerMetricsCollector constructs a new ContainerMetricsCollector // newContainerMetricsCollector constructs a new ContainerMetricsCollector
func NewContainerMetricsCollector() (Collector, error) { func newContainerMetricsCollector() (Collector, error) {
const subsystem = "container" const subsystem = "container"
return &ContainerMetricsCollector{ return &ContainerMetricsCollector{
ContainerAvailable: prometheus.NewDesc( ContainerAvailable: prometheus.NewDesc(

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkContainerCollector(b *testing.B) { func BenchmarkContainerCollector(b *testing.B) {
benchmarkCollector(b, "container", NewContainerMetricsCollector) benchmarkCollector(b, "container", newContainerMetricsCollector)
} }

View File

@@ -9,17 +9,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
var deps string
// See below for 6.05 magic value
if getWindowsVersion() > 6.05 {
deps = "Processor Information"
} else {
deps = "Processor"
}
registerCollector("cpu", newCPUCollector, deps)
}
type cpuCollectorBasic struct { type cpuCollectorBasic struct {
CStateSecondsTotal *prometheus.Desc CStateSecondsTotal *prometheus.Desc
TimeTotal *prometheus.Desc TimeTotal *prometheus.Desc

View File

@@ -13,10 +13,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("cpu_info", newCpuInfoCollector)
}
// If you are adding additional labels to the metric, make sure that they get added in here as well. See below for explanation. // If you are adding additional labels to the metric, make sure that they get added in here as well. See below for explanation.
const ( const (
win32ProcessorQuery = "SELECT Architecture, DeviceId, Description, Family, L2CacheSize, L3CacheSize, Name FROM Win32_Processor" win32ProcessorQuery = "SELECT Architecture, DeviceId, Description, Family, L2CacheSize, L3CacheSize, Name FROM Win32_Processor"

View File

@@ -10,10 +10,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("cs", NewCSCollector)
}
// A CSCollector is a Prometheus collector for WMI metrics // A CSCollector is a Prometheus collector for WMI metrics
type CSCollector struct { type CSCollector struct {
PhysicalMemoryBytes *prometheus.Desc PhysicalMemoryBytes *prometheus.Desc
@@ -21,8 +17,8 @@ type CSCollector struct {
Hostname *prometheus.Desc Hostname *prometheus.Desc
} }
// NewCSCollector ... // newCSCollector ...
func NewCSCollector() (Collector, error) { func newCSCollector() (Collector, error) {
const subsystem = "cs" const subsystem = "cs"
return &CSCollector{ return &CSCollector{

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkCsCollector(b *testing.B) { func BenchmarkCsCollector(b *testing.B) {
benchmarkCollector(b, "cs", NewCSCollector) benchmarkCollector(b, "cs", newCSCollector)
} }

View File

@@ -11,16 +11,6 @@ import (
var dfsrEnabledCollectors = kingpin.Flag("collectors.dfsr.sources-enabled", "Comma-seperated list of DFSR Perflib sources to use.").Default("connection,folder,volume").String() var dfsrEnabledCollectors = kingpin.Flag("collectors.dfsr.sources-enabled", "Comma-seperated list of DFSR Perflib sources to use.").Default("connection,folder,volume").String()
func init() {
// Perflib sources are dynamic, depending on the enabled child collectors
var perflibDependencies []string
for _, source := range expandEnabledChildCollectors(*dfsrEnabledCollectors) {
perflibDependencies = append(perflibDependencies, dfsrGetPerfObjectName(source))
}
registerCollector("dfsr", NewDFSRCollector, perflibDependencies...)
}
// DFSRCollector contains the metric and state data of the DFSR collectors. // DFSRCollector contains the metric and state data of the DFSR collectors.
type DFSRCollector struct { type DFSRCollector struct {
// Connection source // Connection source
@@ -92,8 +82,8 @@ func dfsrGetPerfObjectName(collector string) string {
return (prefix + suffix) return (prefix + suffix)
} }
// NewDFSRCollector is registered // newDFSRCollector is registered
func NewDFSRCollector() (Collector, error) { func newDFSRCollector() (Collector, error) {
log.Info("dfsr collector is in an experimental state! Metrics for this collector have not been tested.") log.Info("dfsr collector is in an experimental state! Metrics for this collector have not been tested.")
const subsystem = "dfsr" const subsystem = "dfsr"

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkDFSRCollector(b *testing.B) { func BenchmarkDFSRCollector(b *testing.B) {
benchmarkCollector(b, "dfsr", NewDFSRCollector) benchmarkCollector(b, "dfsr", newDFSRCollector)
} }

View File

@@ -7,10 +7,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("dhcp", NewDhcpCollector, "DHCP Server")
}
// A DhcpCollector is a Prometheus collector perflib DHCP metrics // A DhcpCollector is a Prometheus collector perflib DHCP metrics
type DhcpCollector struct { type DhcpCollector struct {
PacketsReceivedTotal *prometheus.Desc PacketsReceivedTotal *prometheus.Desc
@@ -40,7 +36,7 @@ type DhcpCollector struct {
FailoverBndupdDropped *prometheus.Desc FailoverBndupdDropped *prometheus.Desc
} }
func NewDhcpCollector() (Collector, error) { func newDhcpCollector() (Collector, error) {
const subsystem = "dhcp" const subsystem = "dhcp"
return &DhcpCollector{ return &DhcpCollector{

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkDHCPCollector(b *testing.B) { func BenchmarkDHCPCollector(b *testing.B) {
benchmarkCollector(b, "dhcp", NewDhcpCollector) benchmarkCollector(b, "dhcp", newDhcpCollector)
} }

View File

@@ -12,10 +12,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("disk_drive", newDiskDriveInfoCollector)
}
const ( const (
win32DiskQuery = "SELECT DeviceID, Model, Caption, Name, Partitions, Size, Status, Availability FROM WIN32_DiskDrive" win32DiskQuery = "SELECT DeviceID, Model, Caption, Name, Partitions, Size, Status, Availability FROM WIN32_DiskDrive"
) )

View File

@@ -11,10 +11,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("dns", NewDNSCollector)
}
// A DNSCollector is a Prometheus collector for WMI Win32_PerfRawData_DNS_DNS metrics // A DNSCollector is a Prometheus collector for WMI Win32_PerfRawData_DNS_DNS metrics
type DNSCollector struct { type DNSCollector struct {
ZoneTransferRequestsReceived *prometheus.Desc ZoneTransferRequestsReceived *prometheus.Desc
@@ -41,8 +37,8 @@ type DNSCollector struct {
UnmatchedResponsesReceived *prometheus.Desc UnmatchedResponsesReceived *prometheus.Desc
} }
// NewDNSCollector ... // newDNSCollector ...
func NewDNSCollector() (Collector, error) { func newDNSCollector() (Collector, error) {
const subsystem = "dns" const subsystem = "dns"
return &DNSCollector{ return &DNSCollector{
ZoneTransferRequestsReceived: prometheus.NewDesc( ZoneTransferRequestsReceived: prometheus.NewDesc(

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkDNSCollector(b *testing.B) { func BenchmarkDNSCollector(b *testing.B) {
benchmarkCollector(b, "dns", NewDNSCollector) benchmarkCollector(b, "dns", newDNSCollector)
} }

View File

@@ -13,20 +13,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("exchange", newExchangeCollector,
"MSExchange ADAccess Processes",
"MSExchangeTransport Queues",
"MSExchange HttpProxy",
"MSExchange ActiveSync",
"MSExchange Availability Service",
"MSExchange OWA",
"MSExchangeAutodiscover",
"MSExchange WorkloadManagement Workloads",
"MSExchange RpcClientAccess",
)
}
type exchangeCollector struct { type exchangeCollector struct {
LDAPReadTime *prometheus.Desc LDAPReadTime *prometheus.Desc
LDAPSearchTime *prometheus.Desc LDAPSearchTime *prometheus.Desc

View File

@@ -6,10 +6,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("fsrmquota", newFSRMQuotaCollector)
}
type FSRMQuotaCollector struct { type FSRMQuotaCollector struct {
QuotasCount *prometheus.Desc QuotasCount *prometheus.Desc
Path *prometheus.Desc Path *prometheus.Desc

View File

@@ -11,10 +11,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("hyperv", NewHyperVCollector)
}
// HyperVCollector is a Prometheus collector for hyper-v // HyperVCollector is a Prometheus collector for hyper-v
type HyperVCollector struct { type HyperVCollector struct {
// Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary // Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary
@@ -130,8 +126,8 @@ type HyperVCollector struct {
VMMemoryRemovedMemory *prometheus.Desc VMMemoryRemovedMemory *prometheus.Desc
} }
// NewHyperVCollector ... // newHyperVCollector ...
func NewHyperVCollector() (Collector, error) { func newHyperVCollector() (Collector, error) {
buildSubsystemName := func(component string) string { return "hyperv_" + component } buildSubsystemName := func(component string) string { return "hyperv_" + component }
return &HyperVCollector{ return &HyperVCollector{
HealthCritical: prometheus.NewDesc( HealthCritical: prometheus.NewDesc(

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkHypervCollector(b *testing.B) { func BenchmarkHypervCollector(b *testing.B) {
benchmarkCollector(b, "hyperv", NewHyperVCollector) benchmarkCollector(b, "hyperv", newHyperVCollector)
} }

View File

@@ -13,10 +13,6 @@ import (
"golang.org/x/sys/windows/registry" "golang.org/x/sys/windows/registry"
) )
func init() {
registerCollector("iis", NewIISCollector, "Web Service", "APP_POOL_WAS", "Web Service Cache", "W3SVC_W3WP")
}
var ( var (
siteWhitelist = kingpin.Flag("collector.iis.site-whitelist", "Regexp of sites to whitelist. Site name must both match whitelist and not match blacklist to be included.").Default(".+").String() siteWhitelist = kingpin.Flag("collector.iis.site-whitelist", "Regexp of sites to whitelist. Site name must both match whitelist and not match blacklist to be included.").Default(".+").String()
siteBlacklist = kingpin.Flag("collector.iis.site-blacklist", "Regexp of sites to blacklist. Site name must both match whitelist and not match blacklist to be included.").String() siteBlacklist = kingpin.Flag("collector.iis.site-blacklist", "Regexp of sites to blacklist. Site name must both match whitelist and not match blacklist to be included.").String()
@@ -195,7 +191,7 @@ type IISCollector struct {
iis_version simple_version iis_version simple_version
} }
func NewIISCollector() (Collector, error) { func newIISCollector() (Collector, error) {
const subsystem = "iis" const subsystem = "iis"
return &IISCollector{ return &IISCollector{

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkIISCollector(b *testing.B) { func BenchmarkIISCollector(b *testing.B) {
benchmarkCollector(b, "iis", NewIISCollector) benchmarkCollector(b, "iis", newIISCollector)
} }

309
collector/init.go Normal file
View File

@@ -0,0 +1,309 @@
package collector
// collectorInit represents the required initialisation config for a collector.
type collectorInit struct {
// Name of collector to be initialised
name string
// Builder function for the collector
builder collectorBuilder
// Perflib counter names for the collector.
// These will be included in the Perflib scrape scope by the exporter.
perfCounterNames []string
}
func getCPUCollectorDeps() string {
// See below for 6.05 magic value
if getWindowsVersion() > 6.05 {
return "Processor Information"
}
return "Processor"
}
func getDFSRCollectorDeps() []string {
// Perflib sources are dynamic, depending on the enabled child collectors
var perflibDependencies []string
for _, source := range expandEnabledChildCollectors(*dfsrEnabledCollectors) {
perflibDependencies = append(perflibDependencies, dfsrGetPerfObjectName(source))
}
return perflibDependencies
}
var collectors = []collectorInit{
{
name: "ad",
builder: newADCollector,
perfCounterNames: nil,
},
{
name: "adcs",
builder: adcsCollectorMethod,
perfCounterNames: []string{"Certification Authority"},
},
{
name: "adfs",
builder: newADFSCollector,
perfCounterNames: []string{"AD FS"},
},
{
name: "cache",
builder: newCacheCollector,
perfCounterNames: []string{"Cache"},
},
{
name: "container",
builder: newContainerMetricsCollector,
perfCounterNames: nil,
},
{
name: "cpu",
builder: newCPUCollector,
perfCounterNames: []string{getCPUCollectorDeps()},
},
{
name: "cpu_info",
builder: newCpuInfoCollector,
perfCounterNames: nil,
},
{
name: "cs",
builder: newCSCollector,
perfCounterNames: nil,
},
{
name: "dfsr",
builder: newDFSRCollector,
perfCounterNames: getDFSRCollectorDeps(),
},
{
name: "dhcp",
builder: newDhcpCollector,
perfCounterNames: nil,
},
{
name: "disk_drive",
builder: newDiskDriveInfoCollector,
perfCounterNames: nil,
},
{
name: "dns",
builder: newDNSCollector,
perfCounterNames: nil,
},
{
name: "exchange",
builder: newExchangeCollector,
perfCounterNames: []string{
"MSExchange ADAccess Processes",
"MSExchangeTransport Queues",
"MSExchange HttpProxy",
"MSExchange ActiveSync",
"MSExchange Availability Service",
"MSExchange OWA",
"MSExchangeAutodiscover",
"MSExchange WorkloadManagement Workloads",
"MSExchange RpcClientAccess",
},
},
{
name: "fsrmquota",
builder: newFSRMQuotaCollector,
perfCounterNames: nil,
},
{
name: "hyperv",
builder: newHyperVCollector,
perfCounterNames: nil,
},
{
name: "iis",
builder: newIISCollector,
perfCounterNames: []string{"Web Service",
"APP_POOL_WAS",
"Web Service Cache",
"W3SVC_W3WP",
},
},
{
name: "logical_disk",
builder: newLogicalDiskCollector,
perfCounterNames: []string{"LogicalDisk"},
},
{
name: "logon",
builder: newLogonCollector,
perfCounterNames: nil,
},
{
name: "memory",
builder: newMemoryCollector,
perfCounterNames: []string{"Memory"},
},
{
name: "mscluster_cluster",
builder: newMSCluster_ClusterCollector,
perfCounterNames: nil,
},
{
name: "mscluster_network",
builder: newMSCluster_NetworkCollector,
perfCounterNames: nil,
},
{
name: "mscluster_node",
builder: newMSCluster_NodeCollector,
perfCounterNames: nil,
},
{
name: "mscluster_resource",
builder: newMSCluster_ResourceCollector,
perfCounterNames: nil,
},
{
name: "mscluster_resourcegroup",
builder: newMSCluster_ResourceGroupCollector,
perfCounterNames: nil,
},
{
name: "msmq",
builder: newMSMQCollector,
perfCounterNames: nil,
},
{
name: "mssql",
builder: newMSSQLCollector,
perfCounterNames: nil,
},
{
name: "net",
builder: newNetworkCollector,
perfCounterNames: []string{"Network Interface"},
},
{
name: "netframework_clrexceptions",
builder: newNETFramework_NETCLRExceptionsCollector,
perfCounterNames: nil,
},
{
name: "netframework_clrinterop",
builder: newNETFramework_NETCLRInteropCollector,
perfCounterNames: nil,
},
{
name: "netframework_clrjit",
builder: newNETFramework_NETCLRJitCollector,
perfCounterNames: nil,
},
{
name: "netframework_clrloading",
builder: newNETFramework_NETCLRLoadingCollector,
perfCounterNames: nil,
},
{
name: "netframework_clrlocksandthreads",
builder: newNETFramework_NETCLRLocksAndThreadsCollector,
perfCounterNames: nil,
},
{
name: "netframework_clrmemory",
builder: newNETFramework_NETCLRMemoryCollector,
perfCounterNames: nil,
},
{
name: "netframework_clrremoting",
builder: newNETFramework_NETCLRRemotingCollector,
perfCounterNames: nil,
},
{
name: "netframework_clrsecurity",
builder: newNETFramework_NETCLRSecurityCollector,
perfCounterNames: nil,
},
{
name: "os",
builder: newOSCollector,
perfCounterNames: []string{"Paging File"},
},
{
name: "process",
builder: newProcessCollector,
perfCounterNames: []string{"Process"},
},
{
name: "remote_fx",
builder: newRemoteFx,
perfCounterNames: []string{"RemoteFX Network"},
},
{
name: "scheduled_task",
builder: newScheduledTask,
perfCounterNames: nil,
},
{
name: "service",
builder: newserviceCollector,
perfCounterNames: nil,
},
{
name: "smtp",
builder: newSMTPCollector,
perfCounterNames: []string{"SMTP Server"},
},
{
name: "system",
builder: newSystemCollector,
perfCounterNames: []string{"System"},
},
{
name: "teradici_pcoip",
builder: newTeradiciPcoipCollector,
perfCounterNames: nil,
},
{
name: "tcp",
builder: newTCPCollector,
perfCounterNames: []string{"TCPv4"},
},
{
name: "terminal_services",
builder: newTerminalServicesCollector,
perfCounterNames: []string{
"Terminal Services",
"Terminal Services Session",
"Remote Desktop Connection Broker Counterset",
},
},
{
name: "textfile",
builder: newTextFileCollector,
perfCounterNames: nil,
},
{
name: "thermalzone",
builder: newThermalZoneCollector,
perfCounterNames: nil,
},
{
name: "time",
builder: newTimeCollector,
perfCounterNames: []string{"Windows Time Service"},
},
{
name: "vmware",
builder: newVmwareCollector,
perfCounterNames: nil,
},
{
name: "vmware_blast",
builder: newVmwareBlastCollector,
perfCounterNames: nil,
},
}
// To be called by the exporter for collector initialisation
func RegisterCollectors() {
for _, v := range collectors {
registerCollector(v.name, v.builder, v.perfCounterNames...)
}
}

View File

@@ -12,10 +12,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("logical_disk", NewLogicalDiskCollector, "LogicalDisk")
}
var ( var (
volumeWhitelist = kingpin.Flag( volumeWhitelist = kingpin.Flag(
"collector.logical_disk.volume-whitelist", "collector.logical_disk.volume-whitelist",
@@ -50,8 +46,8 @@ type LogicalDiskCollector struct {
volumeBlacklistPattern *regexp.Regexp volumeBlacklistPattern *regexp.Regexp
} }
// NewLogicalDiskCollector ... // newLogicalDiskCollector ...
func NewLogicalDiskCollector() (Collector, error) { func newLogicalDiskCollector() (Collector, error) {
const subsystem = "logical_disk" const subsystem = "logical_disk"
return &LogicalDiskCollector{ return &LogicalDiskCollector{

View File

@@ -9,5 +9,5 @@ func BenchmarkLogicalDiskCollector(b *testing.B) {
localVolumeWhitelist := ".+" localVolumeWhitelist := ".+"
volumeWhitelist = &localVolumeWhitelist volumeWhitelist = &localVolumeWhitelist
benchmarkCollector(b, "logical_disk", NewLogicalDiskCollector) benchmarkCollector(b, "logical_disk", newLogicalDiskCollector)
} }

View File

@@ -11,17 +11,13 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("logon", NewLogonCollector)
}
// A LogonCollector is a Prometheus collector for WMI metrics // A LogonCollector is a Prometheus collector for WMI metrics
type LogonCollector struct { type LogonCollector struct {
LogonType *prometheus.Desc LogonType *prometheus.Desc
} }
// NewLogonCollector ... // newLogonCollector ...
func NewLogonCollector() (Collector, error) { func newLogonCollector() (Collector, error) {
const subsystem = "logon" const subsystem = "logon"
return &LogonCollector{ return &LogonCollector{

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkLogonCollector(b *testing.B) { func BenchmarkLogonCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewLogonCollector) benchmarkCollector(b, "", newLogonCollector)
} }

View File

@@ -11,10 +11,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("memory", NewMemoryCollector, "Memory")
}
// A MemoryCollector is a Prometheus collector for perflib Memory metrics // A MemoryCollector is a Prometheus collector for perflib Memory metrics
type MemoryCollector struct { type MemoryCollector struct {
AvailableBytes *prometheus.Desc AvailableBytes *prometheus.Desc
@@ -51,8 +47,8 @@ type MemoryCollector struct {
WriteCopiesTotal *prometheus.Desc WriteCopiesTotal *prometheus.Desc
} }
// NewMemoryCollector ... // newMemoryCollector ...
func NewMemoryCollector() (Collector, error) { func newMemoryCollector() (Collector, error) {
const subsystem = "memory" const subsystem = "memory"
return &MemoryCollector{ return &MemoryCollector{

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkMemoryCollector(b *testing.B) { func BenchmarkMemoryCollector(b *testing.B) {
benchmarkCollector(b, "memory", NewMemoryCollector) benchmarkCollector(b, "memory", newMemoryCollector)
} }

View File

@@ -5,10 +5,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("mscluster_cluster", newMSCluster_ClusterCollector)
}
// A MSCluster_ClusterCollector is a Prometheus collector for WMI MSCluster_Cluster metrics // A MSCluster_ClusterCollector is a Prometheus collector for WMI MSCluster_Cluster metrics
type MSCluster_ClusterCollector struct { type MSCluster_ClusterCollector struct {
AddEvictDelay *prometheus.Desc AddEvictDelay *prometheus.Desc

View File

@@ -5,10 +5,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("mscluster_network", newMSCluster_NetworkCollector)
}
// A MSCluster_NetworkCollector is a Prometheus collector for WMI MSCluster_Network metrics // A MSCluster_NetworkCollector is a Prometheus collector for WMI MSCluster_Network metrics
type MSCluster_NetworkCollector struct { type MSCluster_NetworkCollector struct {
Characteristics *prometheus.Desc Characteristics *prometheus.Desc

View File

@@ -5,10 +5,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("mscluster_node", newMSCluster_NodeCollector)
}
// A MSCluster_NodeCollector is a Prometheus collector for WMI MSCluster_Node metrics // A MSCluster_NodeCollector is a Prometheus collector for WMI MSCluster_Node metrics
type MSCluster_NodeCollector struct { type MSCluster_NodeCollector struct {
BuildNumber *prometheus.Desc BuildNumber *prometheus.Desc

View File

@@ -5,10 +5,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("mscluster_resource", newMSCluster_ResourceCollector)
}
// A MSCluster_ResourceCollector is a Prometheus collector for WMI MSCluster_Resource metrics // A MSCluster_ResourceCollector is a Prometheus collector for WMI MSCluster_Resource metrics
type MSCluster_ResourceCollector struct { type MSCluster_ResourceCollector struct {
Characteristics *prometheus.Desc Characteristics *prometheus.Desc

View File

@@ -5,10 +5,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("mscluster_resourcegroup", newMSCluster_ResourceGroupCollector)
}
// A MSCluster_ResourceGroupCollector is a Prometheus collector for WMI MSCluster_ResourceGroup metrics // A MSCluster_ResourceGroupCollector is a Prometheus collector for WMI MSCluster_ResourceGroup metrics
type MSCluster_ResourceGroupCollector struct { type MSCluster_ResourceGroupCollector struct {
AutoFailbackType *prometheus.Desc AutoFailbackType *prometheus.Desc

View File

@@ -12,10 +12,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("msmq", NewMSMQCollector)
}
var ( var (
msmqWhereClause = kingpin.Flag("collector.msmq.msmq-where", "WQL 'where' clause to use in WMI metrics query. Limits the response to the msmqs you specify and reduces the size of the response.").String() msmqWhereClause = kingpin.Flag("collector.msmq.msmq-where", "WQL 'where' clause to use in WMI metrics query. Limits the response to the msmqs you specify and reduces the size of the response.").String()
) )
@@ -31,7 +27,7 @@ type Win32_PerfRawData_MSMQ_MSMQQueueCollector struct {
} }
// NewWin32_PerfRawData_MSMQ_MSMQQueueCollector ... // NewWin32_PerfRawData_MSMQ_MSMQQueueCollector ...
func NewMSMQCollector() (Collector, error) { func newMSMQCollector() (Collector, error) {
const subsystem = "msmq" const subsystem = "msmq"
if *msmqWhereClause == "" { if *msmqWhereClause == "" {

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkMsmqCollector(b *testing.B) { func BenchmarkMsmqCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewMSMQCollector) benchmarkCollector(b, "", newMSMQCollector)
} }

View File

@@ -129,10 +129,6 @@ func mssqlGetPerfObjectName(sqlInstance string, collector string) string {
return (prefix + suffix) return (prefix + suffix)
} }
func init() {
registerCollector("mssql", NewMSSQLCollector)
}
// A MSSQLCollector is a Prometheus collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics // A MSSQLCollector is a Prometheus collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics
type MSSQLCollector struct { type MSSQLCollector struct {
// meta // meta
@@ -405,8 +401,8 @@ type MSSQLCollector struct {
mssqlChildCollectorFailure int mssqlChildCollectorFailure int
} }
// NewMSSQLCollector ... // newMSSQLCollector ...
func NewMSSQLCollector() (Collector, error) { func newMSSQLCollector() (Collector, error) {
const subsystem = "mssql" const subsystem = "mssql"

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkMSSQLCollector(b *testing.B) { func BenchmarkMSSQLCollector(b *testing.B) {
benchmarkCollector(b, "mssql", NewMSSQLCollector) benchmarkCollector(b, "mssql", newMSSQLCollector)
} }

View File

@@ -12,10 +12,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("net", NewNetworkCollector, "Network Interface")
}
var ( var (
nicWhitelist = kingpin.Flag( nicWhitelist = kingpin.Flag(
"collector.net.nic-whitelist", "collector.net.nic-whitelist",
@@ -48,8 +44,8 @@ type NetworkCollector struct {
nicBlacklistPattern *regexp.Regexp nicBlacklistPattern *regexp.Regexp
} }
// NewNetworkCollector ... // newNetworkCollector ...
func NewNetworkCollector() (Collector, error) { func newNetworkCollector() (Collector, error) {
const subsystem = "net" const subsystem = "net"
return &NetworkCollector{ return &NetworkCollector{

View File

@@ -23,5 +23,5 @@ func BenchmarkNetCollector(b *testing.B) {
// Whitelist is not set in testing context (kingpin flags not parsed), causing the collector to skip all interfaces. // Whitelist is not set in testing context (kingpin flags not parsed), causing the collector to skip all interfaces.
localNicWhitelist := ".+" localNicWhitelist := ".+"
nicWhitelist = &localNicWhitelist nicWhitelist = &localNicWhitelist
benchmarkCollector(b, "net", NewNetworkCollector) benchmarkCollector(b, "net", newNetworkCollector)
} }

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("netframework_clrexceptions", NewNETFramework_NETCLRExceptionsCollector)
}
// A NETFramework_NETCLRExceptionsCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRExceptions metrics // A NETFramework_NETCLRExceptionsCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRExceptions metrics
type NETFramework_NETCLRExceptionsCollector struct { type NETFramework_NETCLRExceptionsCollector struct {
NumberofExcepsThrown *prometheus.Desc NumberofExcepsThrown *prometheus.Desc
@@ -21,8 +17,8 @@ type NETFramework_NETCLRExceptionsCollector struct {
ThrowToCatchDepth *prometheus.Desc ThrowToCatchDepth *prometheus.Desc
} }
// NewNETFramework_NETCLRExceptionsCollector ... // newNETFramework_NETCLRExceptionsCollector ...
func NewNETFramework_NETCLRExceptionsCollector() (Collector, error) { func newNETFramework_NETCLRExceptionsCollector() (Collector, error) {
const subsystem = "netframework_clrexceptions" const subsystem = "netframework_clrexceptions"
return &NETFramework_NETCLRExceptionsCollector{ return &NETFramework_NETCLRExceptionsCollector{
NumberofExcepsThrown: prometheus.NewDesc( NumberofExcepsThrown: prometheus.NewDesc(

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkNetFrameworkNETCLRExceptionsCollector(b *testing.B) { func BenchmarkNetFrameworkNETCLRExceptionsCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewNETFramework_NETCLRExceptionsCollector) benchmarkCollector(b, "", newNETFramework_NETCLRExceptionsCollector)
} }

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("netframework_clrinterop", NewNETFramework_NETCLRInteropCollector)
}
// A NETFramework_NETCLRInteropCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRInterop metrics // A NETFramework_NETCLRInteropCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRInterop metrics
type NETFramework_NETCLRInteropCollector struct { type NETFramework_NETCLRInteropCollector struct {
NumberofCCWs *prometheus.Desc NumberofCCWs *prometheus.Desc
@@ -20,8 +16,8 @@ type NETFramework_NETCLRInteropCollector struct {
NumberofStubs *prometheus.Desc NumberofStubs *prometheus.Desc
} }
// NewNETFramework_NETCLRInteropCollector ... // newNETFramework_NETCLRInteropCollector ...
func NewNETFramework_NETCLRInteropCollector() (Collector, error) { func newNETFramework_NETCLRInteropCollector() (Collector, error) {
const subsystem = "netframework_clrinterop" const subsystem = "netframework_clrinterop"
return &NETFramework_NETCLRInteropCollector{ return &NETFramework_NETCLRInteropCollector{
NumberofCCWs: prometheus.NewDesc( NumberofCCWs: prometheus.NewDesc(

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkNETFrameworkNETCLRInteropCollector(b *testing.B) { func BenchmarkNETFrameworkNETCLRInteropCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewNETFramework_NETCLRInteropCollector) benchmarkCollector(b, "", newNETFramework_NETCLRInteropCollector)
} }

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("netframework_clrjit", NewNETFramework_NETCLRJitCollector)
}
// A NETFramework_NETCLRJitCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRJit metrics // A NETFramework_NETCLRJitCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRJit metrics
type NETFramework_NETCLRJitCollector struct { type NETFramework_NETCLRJitCollector struct {
NumberofMethodsJitted *prometheus.Desc NumberofMethodsJitted *prometheus.Desc
@@ -21,8 +17,8 @@ type NETFramework_NETCLRJitCollector struct {
TotalNumberofILBytesJitted *prometheus.Desc TotalNumberofILBytesJitted *prometheus.Desc
} }
// NewNETFramework_NETCLRJitCollector ... // newNETFramework_NETCLRJitCollector ...
func NewNETFramework_NETCLRJitCollector() (Collector, error) { func newNETFramework_NETCLRJitCollector() (Collector, error) {
const subsystem = "netframework_clrjit" const subsystem = "netframework_clrjit"
return &NETFramework_NETCLRJitCollector{ return &NETFramework_NETCLRJitCollector{
NumberofMethodsJitted: prometheus.NewDesc( NumberofMethodsJitted: prometheus.NewDesc(

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkNETFrameworkNETCLRJitCollector(b *testing.B) { func BenchmarkNETFrameworkNETCLRJitCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewNETFramework_NETCLRJitCollector) benchmarkCollector(b, "", newNETFramework_NETCLRJitCollector)
} }

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("netframework_clrloading", NewNETFramework_NETCLRLoadingCollector)
}
// A NETFramework_NETCLRLoadingCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRLoading metrics // A NETFramework_NETCLRLoadingCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRLoading metrics
type NETFramework_NETCLRLoadingCollector struct { type NETFramework_NETCLRLoadingCollector struct {
BytesinLoaderHeap *prometheus.Desc BytesinLoaderHeap *prometheus.Desc
@@ -26,8 +22,8 @@ type NETFramework_NETCLRLoadingCollector struct {
TotalNumberofLoadFailures *prometheus.Desc TotalNumberofLoadFailures *prometheus.Desc
} }
// NewNETFramework_NETCLRLoadingCollector ... // newNETFramework_NETCLRLoadingCollector ...
func NewNETFramework_NETCLRLoadingCollector() (Collector, error) { func newNETFramework_NETCLRLoadingCollector() (Collector, error) {
const subsystem = "netframework_clrloading" const subsystem = "netframework_clrloading"
return &NETFramework_NETCLRLoadingCollector{ return &NETFramework_NETCLRLoadingCollector{
BytesinLoaderHeap: prometheus.NewDesc( BytesinLoaderHeap: prometheus.NewDesc(

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkNETFrameworkNETCLRLoadingCollector(b *testing.B) { func BenchmarkNETFrameworkNETCLRLoadingCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewNETFramework_NETCLRLoadingCollector) benchmarkCollector(b, "", newNETFramework_NETCLRLoadingCollector)
} }

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("netframework_clrlocksandthreads", NewNETFramework_NETCLRLocksAndThreadsCollector)
}
// A NETFramework_NETCLRLocksAndThreadsCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads metrics // A NETFramework_NETCLRLocksAndThreadsCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads metrics
type NETFramework_NETCLRLocksAndThreadsCollector struct { type NETFramework_NETCLRLocksAndThreadsCollector struct {
CurrentQueueLength *prometheus.Desc CurrentQueueLength *prometheus.Desc
@@ -24,8 +20,8 @@ type NETFramework_NETCLRLocksAndThreadsCollector struct {
TotalNumberofContentions *prometheus.Desc TotalNumberofContentions *prometheus.Desc
} }
// NewNETFramework_NETCLRLocksAndThreadsCollector ... // newNETFramework_NETCLRLocksAndThreadsCollector ...
func NewNETFramework_NETCLRLocksAndThreadsCollector() (Collector, error) { func newNETFramework_NETCLRLocksAndThreadsCollector() (Collector, error) {
const subsystem = "netframework_clrlocksandthreads" const subsystem = "netframework_clrlocksandthreads"
return &NETFramework_NETCLRLocksAndThreadsCollector{ return &NETFramework_NETCLRLocksAndThreadsCollector{
CurrentQueueLength: prometheus.NewDesc( CurrentQueueLength: prometheus.NewDesc(

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkNETFrameworkNETCLRLocksAndThreadsCollector(b *testing.B) { func BenchmarkNETFrameworkNETCLRLocksAndThreadsCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewNETFramework_NETCLRLocksAndThreadsCollector) benchmarkCollector(b, "", newNETFramework_NETCLRLocksAndThreadsCollector)
} }

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("netframework_clrmemory", NewNETFramework_NETCLRMemoryCollector)
}
// A NETFramework_NETCLRMemoryCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRMemory metrics // A NETFramework_NETCLRMemoryCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRMemory metrics
type NETFramework_NETCLRMemoryCollector struct { type NETFramework_NETCLRMemoryCollector struct {
AllocatedBytes *prometheus.Desc AllocatedBytes *prometheus.Desc
@@ -32,8 +28,8 @@ type NETFramework_NETCLRMemoryCollector struct {
PromotedMemoryfromGen1 *prometheus.Desc PromotedMemoryfromGen1 *prometheus.Desc
} }
// NewNETFramework_NETCLRMemoryCollector ... // newNETFramework_NETCLRMemoryCollector ...
func NewNETFramework_NETCLRMemoryCollector() (Collector, error) { func newNETFramework_NETCLRMemoryCollector() (Collector, error) {
const subsystem = "netframework_clrmemory" const subsystem = "netframework_clrmemory"
return &NETFramework_NETCLRMemoryCollector{ return &NETFramework_NETCLRMemoryCollector{
AllocatedBytes: prometheus.NewDesc( AllocatedBytes: prometheus.NewDesc(

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkNETFrameworkNETCLRMemoryCollector(b *testing.B) { func BenchmarkNETFrameworkNETCLRMemoryCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewNETFramework_NETCLRMemoryCollector) benchmarkCollector(b, "", newNETFramework_NETCLRMemoryCollector)
} }

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("netframework_clrremoting", NewNETFramework_NETCLRRemotingCollector)
}
// A NETFramework_NETCLRRemotingCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRRemoting metrics // A NETFramework_NETCLRRemotingCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRRemoting metrics
type NETFramework_NETCLRRemotingCollector struct { type NETFramework_NETCLRRemotingCollector struct {
Channels *prometheus.Desc Channels *prometheus.Desc
@@ -23,8 +19,8 @@ type NETFramework_NETCLRRemotingCollector struct {
TotalRemoteCalls *prometheus.Desc TotalRemoteCalls *prometheus.Desc
} }
// NewNETFramework_NETCLRRemotingCollector ... // newNETFramework_NETCLRRemotingCollector ...
func NewNETFramework_NETCLRRemotingCollector() (Collector, error) { func newNETFramework_NETCLRRemotingCollector() (Collector, error) {
const subsystem = "netframework_clrremoting" const subsystem = "netframework_clrremoting"
return &NETFramework_NETCLRRemotingCollector{ return &NETFramework_NETCLRRemotingCollector{
Channels: prometheus.NewDesc( Channels: prometheus.NewDesc(

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkNETFrameworkNETCLRRemotingCollector(b *testing.B) { func BenchmarkNETFrameworkNETCLRRemotingCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewNETFramework_NETCLRRemotingCollector) benchmarkCollector(b, "", newNETFramework_NETCLRRemotingCollector)
} }

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("netframework_clrsecurity", NewNETFramework_NETCLRSecurityCollector)
}
// A NETFramework_NETCLRSecurityCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRSecurity metrics // A NETFramework_NETCLRSecurityCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRSecurity metrics
type NETFramework_NETCLRSecurityCollector struct { type NETFramework_NETCLRSecurityCollector struct {
NumberLinkTimeChecks *prometheus.Desc NumberLinkTimeChecks *prometheus.Desc
@@ -21,8 +17,8 @@ type NETFramework_NETCLRSecurityCollector struct {
TotalRuntimeChecks *prometheus.Desc TotalRuntimeChecks *prometheus.Desc
} }
// NewNETFramework_NETCLRSecurityCollector ... // newNETFramework_NETCLRSecurityCollector ...
func NewNETFramework_NETCLRSecurityCollector() (Collector, error) { func newNETFramework_NETCLRSecurityCollector() (Collector, error) {
const subsystem = "netframework_clrsecurity" const subsystem = "netframework_clrsecurity"
return &NETFramework_NETCLRSecurityCollector{ return &NETFramework_NETCLRSecurityCollector{
NumberLinkTimeChecks: prometheus.NewDesc( NumberLinkTimeChecks: prometheus.NewDesc(

View File

@@ -6,5 +6,5 @@ import (
func BenchmarkNETFrameworkNETCLRSecurityCollector(b *testing.B) { func BenchmarkNETFrameworkNETCLRSecurityCollector(b *testing.B) {
// No context name required as collector source is WMI // No context name required as collector source is WMI
benchmarkCollector(b, "", NewNETFramework_NETCLRSecurityCollector) benchmarkCollector(b, "", newNETFramework_NETCLRSecurityCollector)
} }

View File

@@ -17,10 +17,6 @@ import (
"golang.org/x/sys/windows/registry" "golang.org/x/sys/windows/registry"
) )
func init() {
registerCollector("os", NewOSCollector, "Paging File")
}
// A OSCollector is a Prometheus collector for WMI metrics // A OSCollector is a Prometheus collector for WMI metrics
type OSCollector struct { type OSCollector struct {
OSInformation *prometheus.Desc OSInformation *prometheus.Desc
@@ -44,8 +40,8 @@ type pagingFileCounter struct {
UsagePeak float64 `perflib:"% Usage Peak"` UsagePeak float64 `perflib:"% Usage Peak"`
} }
// NewOSCollector ... // newOSCollector ...
func NewOSCollector() (Collector, error) { func newOSCollector() (Collector, error) {
const subsystem = "os" const subsystem = "os"
return &OSCollector{ return &OSCollector{

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkOSCollector(b *testing.B) { func BenchmarkOSCollector(b *testing.B) {
benchmarkCollector(b, "os", NewOSCollector) benchmarkCollector(b, "os", newOSCollector)
} }

View File

@@ -15,10 +15,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("process", newProcessCollector, "Process")
}
var ( var (
processWhitelist = kingpin.Flag( processWhitelist = kingpin.Flag(
"collector.process.whitelist", "collector.process.whitelist",

View File

@@ -10,10 +10,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("remote_fx", NewRemoteFx, "RemoteFX Network", "RemoteFX Graphics")
}
// A RemoteFxNetworkCollector is a Prometheus collector for // A RemoteFxNetworkCollector is a Prometheus collector for
// WMI Win32_PerfRawData_Counters_RemoteFXNetwork & Win32_PerfRawData_Counters_RemoteFXGraphics metrics // WMI Win32_PerfRawData_Counters_RemoteFXNetwork & Win32_PerfRawData_Counters_RemoteFXGraphics metrics
// https://wutils.com/wmi/root/cimv2/win32_perfrawdata_counters_remotefxnetwork/ // https://wutils.com/wmi/root/cimv2/win32_perfrawdata_counters_remotefxnetwork/
@@ -42,8 +38,8 @@ type RemoteFxCollector struct {
SourceFramesPerSecond *prometheus.Desc SourceFramesPerSecond *prometheus.Desc
} }
// NewRemoteFx ... // newRemoteFx ...
func NewRemoteFx() (Collector, error) { func newRemoteFx() (Collector, error) {
const subsystem = "remote_fx" const subsystem = "remote_fx"
return &RemoteFxCollector{ return &RemoteFxCollector{
// net // net

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkRemoteFXCollector(b *testing.B) { func BenchmarkRemoteFXCollector(b *testing.B) {
benchmarkCollector(b, "remote_fx", NewRemoteFx) benchmarkCollector(b, "remote_fx", newRemoteFx)
} }

View File

@@ -63,12 +63,8 @@ type ScheduledTask struct {
type ScheduledTasks []ScheduledTask type ScheduledTasks []ScheduledTask
func init() { // newScheduledTask ...
registerCollector("scheduled_task", NewScheduledTask) func newScheduledTask() (Collector, error) {
}
// NewScheduledTask ...
func NewScheduledTask() (Collector, error) {
const subsystem = "scheduled_task" const subsystem = "scheduled_task"
runtime.LockOSThread() runtime.LockOSThread()

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkScheduledTaskCollector(b *testing.B) { func BenchmarkScheduledTaskCollector(b *testing.B) {
benchmarkCollector(b, "scheduled_task", NewScheduledTask) benchmarkCollector(b, "scheduled_task", newScheduledTask)
} }

View File

@@ -16,10 +16,6 @@ import (
"golang.org/x/sys/windows/svc/mgr" "golang.org/x/sys/windows/svc/mgr"
) )
func init() {
registerCollector("service", NewserviceCollector)
}
var ( var (
serviceWhereClause = kingpin.Flag( serviceWhereClause = kingpin.Flag(
"collector.service.services-where", "collector.service.services-where",
@@ -41,8 +37,8 @@ type serviceCollector struct {
queryWhereClause string queryWhereClause string
} }
// NewserviceCollector ... // newserviceCollector ...
func NewserviceCollector() (Collector, error) { func newserviceCollector() (Collector, error) {
const subsystem = "service" const subsystem = "service"
if *serviceWhereClause == "" { if *serviceWhereClause == "" {

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkServiceCollector(b *testing.B) { func BenchmarkServiceCollector(b *testing.B) {
benchmarkCollector(b, "service", NewserviceCollector) benchmarkCollector(b, "service", newserviceCollector)
} }

View File

@@ -11,10 +11,6 @@ import (
"regexp" "regexp"
) )
func init() {
registerCollector("smtp", NewSMTPCollector, "SMTP Server")
}
var ( var (
serverWhitelist = kingpin.Flag("collector.smtp.server-whitelist", "Regexp of virtual servers to whitelist. Server name must both match whitelist and not match blacklist to be included.").Default(".+").String() serverWhitelist = kingpin.Flag("collector.smtp.server-whitelist", "Regexp of virtual servers to whitelist. Server name must both match whitelist and not match blacklist to be included.").Default(".+").String()
serverBlacklist = kingpin.Flag("collector.smtp.server-blacklist", "Regexp of virtual servers to blacklist. Server name must both match whitelist and not match blacklist to be included.").String() serverBlacklist = kingpin.Flag("collector.smtp.server-blacklist", "Regexp of virtual servers to blacklist. Server name must both match whitelist and not match blacklist to be included.").String()
@@ -68,7 +64,7 @@ type SMTPCollector struct {
serverBlacklistPattern *regexp.Regexp serverBlacklistPattern *regexp.Regexp
} }
func NewSMTPCollector() (Collector, error) { func newSMTPCollector() (Collector, error) {
log.Info("smtp collector is in an experimental state! Metrics for this collector have not been tested.") log.Info("smtp collector is in an experimental state! Metrics for this collector have not been tested.")
const subsystem = "smtp" const subsystem = "smtp"

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkSmtpCollector(b *testing.B) { func BenchmarkSmtpCollector(b *testing.B) {
benchmarkCollector(b, "smtp", NewSMTPCollector) benchmarkCollector(b, "smtp", newSMTPCollector)
} }

View File

@@ -8,10 +8,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("system", NewSystemCollector, "System")
}
// A SystemCollector is a Prometheus collector for WMI metrics // A SystemCollector is a Prometheus collector for WMI metrics
type SystemCollector struct { type SystemCollector struct {
ContextSwitchesTotal *prometheus.Desc ContextSwitchesTotal *prometheus.Desc
@@ -22,8 +18,8 @@ type SystemCollector struct {
Threads *prometheus.Desc Threads *prometheus.Desc
} }
// NewSystemCollector ... // newSystemCollector ...
func NewSystemCollector() (Collector, error) { func newSystemCollector() (Collector, error) {
const subsystem = "system" const subsystem = "system"
return &SystemCollector{ return &SystemCollector{

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkSystemCollector(b *testing.B) { func BenchmarkSystemCollector(b *testing.B) {
benchmarkCollector(b, "system", NewSystemCollector) benchmarkCollector(b, "system", newSystemCollector)
} }

View File

@@ -8,10 +8,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("tcp", NewTCPCollector, "TCPv4", "TCPv6")
}
// A TCPCollector is a Prometheus collector for WMI Win32_PerfRawData_Tcpip_TCPv{4,6} metrics // A TCPCollector is a Prometheus collector for WMI Win32_PerfRawData_Tcpip_TCPv{4,6} metrics
type TCPCollector struct { type TCPCollector struct {
ConnectionFailures *prometheus.Desc ConnectionFailures *prometheus.Desc
@@ -25,8 +21,8 @@ type TCPCollector struct {
SegmentsSentTotal *prometheus.Desc SegmentsSentTotal *prometheus.Desc
} }
// NewTCPCollector ... // newTCPCollector ...
func NewTCPCollector() (Collector, error) { func newTCPCollector() (Collector, error) {
const subsystem = "tcp" const subsystem = "tcp"
return &TCPCollector{ return &TCPCollector{

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkTCPCollector(b *testing.B) { func BenchmarkTCPCollector(b *testing.B) {
benchmarkCollector(b, "tcp", NewTCPCollector) benchmarkCollector(b, "tcp", newTCPCollector)
} }

View File

@@ -11,10 +11,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("teradici_pcoip", newTeradiciPcoipCollector)
}
// A teradiciPcoipCollector is a Prometheus collector for WMI metrics: // A teradiciPcoipCollector is a Prometheus collector for WMI metrics:
// win32_PerfRawData_TeradiciPerf_PCoIPSessionAudioStatistics // win32_PerfRawData_TeradiciPerf_PCoIPSessionAudioStatistics
// win32_PerfRawData_TeradiciPerf_PCoIPSessionGeneralStatistics // win32_PerfRawData_TeradiciPerf_PCoIPSessionGeneralStatistics

View File

@@ -14,10 +14,6 @@ import (
const ConnectionBrokerFeatureID uint32 = 133 const ConnectionBrokerFeatureID uint32 = 133
func init() {
registerCollector("terminal_services", NewTerminalServicesCollector, "Terminal Services", "Terminal Services Session", "Remote Desktop Connection Broker Counterset")
}
var ( var (
connectionBrokerEnabled = isConnectionBrokerServer() connectionBrokerEnabled = isConnectionBrokerServer()
) )
@@ -65,8 +61,8 @@ type TerminalServicesCollector struct {
WorkingSetPeak *prometheus.Desc WorkingSetPeak *prometheus.Desc
} }
// NewTerminalServicesCollector ... // newTerminalServicesCollector ...
func NewTerminalServicesCollector() (Collector, error) { func newTerminalServicesCollector() (Collector, error) {
const subsystem = "terminal_services" const subsystem = "terminal_services"
return &TerminalServicesCollector{ return &TerminalServicesCollector{
LocalSessionCount: prometheus.NewDesc( LocalSessionCount: prometheus.NewDesc(

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkTerminalServicesCollector(b *testing.B) { func BenchmarkTerminalServicesCollector(b *testing.B) {
benchmarkCollector(b, "terminal_services", NewTerminalServicesCollector) benchmarkCollector(b, "terminal_services", newTerminalServicesCollector)
} }

View File

@@ -55,13 +55,9 @@ type textFileCollector struct {
mtime *float64 mtime *float64
} }
func init() { // newTextFileCollector returns a new Collector exposing metrics read from files
registerCollector("textfile", NewTextFileCollector)
}
// NewTextFileCollector returns a new Collector exposing metrics read from files
// in the given textfile directory. // in the given textfile directory.
func NewTextFileCollector() (Collector, error) { func newTextFileCollector() (Collector, error) {
return &textFileCollector{ return &textFileCollector{
path: *textFileDirectory, path: *textFileDirectory,
}, nil }, nil

View File

@@ -8,10 +8,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("thermalzone", NewThermalZoneCollector)
}
// A thermalZoneCollector is a Prometheus collector for WMI Win32_PerfRawData_Counters_ThermalZoneInformation metrics // A thermalZoneCollector is a Prometheus collector for WMI Win32_PerfRawData_Counters_ThermalZoneInformation metrics
type thermalZoneCollector struct { type thermalZoneCollector struct {
PercentPassiveLimit *prometheus.Desc PercentPassiveLimit *prometheus.Desc
@@ -19,8 +15,8 @@ type thermalZoneCollector struct {
ThrottleReasons *prometheus.Desc ThrottleReasons *prometheus.Desc
} }
// NewThermalZoneCollector ... // newThermalZoneCollector ...
func NewThermalZoneCollector() (Collector, error) { func newThermalZoneCollector() (Collector, error) {
const subsystem = "thermalzone" const subsystem = "thermalzone"
return &thermalZoneCollector{ return &thermalZoneCollector{
Temperature: prometheus.NewDesc( Temperature: prometheus.NewDesc(

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkThermalZoneCollector(b *testing.B) { func BenchmarkThermalZoneCollector(b *testing.B) {
benchmarkCollector(b, "thermalzone", NewThermalZoneCollector) benchmarkCollector(b, "thermalzone", newThermalZoneCollector)
} }

View File

@@ -10,10 +10,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
func init() {
registerCollector("time", newTimeCollector, "Windows Time Service")
}
// TimeCollector is a Prometheus collector for Perflib counter metrics // TimeCollector is a Prometheus collector for Perflib counter metrics
type TimeCollector struct { type TimeCollector struct {
ClockFrequencyAdjustmentPPBTotal *prometheus.Desc ClockFrequencyAdjustmentPPBTotal *prometheus.Desc

View File

@@ -11,10 +11,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("vmware", NewVmwareCollector)
}
// A VmwareCollector is a Prometheus collector for WMI Win32_PerfRawData_vmGuestLib_VMem/Win32_PerfRawData_vmGuestLib_VCPU metrics // A VmwareCollector is a Prometheus collector for WMI Win32_PerfRawData_vmGuestLib_VMem/Win32_PerfRawData_vmGuestLib_VCPU metrics
type VmwareCollector struct { type VmwareCollector struct {
MemActive *prometheus.Desc MemActive *prometheus.Desc
@@ -39,8 +35,8 @@ type VmwareCollector struct {
HostProcessorSpeedMHz *prometheus.Desc HostProcessorSpeedMHz *prometheus.Desc
} }
// NewVmwareCollector constructs a new VmwareCollector // newVmwareCollector constructs a new VmwareCollector
func NewVmwareCollector() (Collector, error) { func newVmwareCollector() (Collector, error) {
const subsystem = "vmware" const subsystem = "vmware"
return &VmwareCollector{ return &VmwareCollector{
MemActive: prometheus.NewDesc( MemActive: prometheus.NewDesc(

View File

@@ -9,10 +9,6 @@ import (
"github.com/yusufpapurcu/wmi" "github.com/yusufpapurcu/wmi"
) )
func init() {
registerCollector("vmware_blast", newVmwareBlastCollector)
}
// A vmwareBlastCollector is a Prometheus collector for WMI metrics: // A vmwareBlastCollector is a Prometheus collector for WMI metrics:
// win32_PerfRawData_Counters_VMwareBlastAudioCounters // win32_PerfRawData_Counters_VMwareBlastAudioCounters
// win32_PerfRawData_Counters_VMwareBlastCDRCounters // win32_PerfRawData_Counters_VMwareBlastCDRCounters

View File

@@ -5,5 +5,5 @@ import (
) )
func BenchmarkVmwareCollector(b *testing.B) { func BenchmarkVmwareCollector(b *testing.B) {
benchmarkCollector(b, "vmware", NewVmwareCollector) benchmarkCollector(b, "vmware", newVmwareCollector)
} }

View File

@@ -333,6 +333,9 @@ func main() {
initWbem() initWbem()
// Initialize collectors before loading
collector.RegisterCollectors()
collectors, err := loadCollectors(*enabledCollectors) collectors, err := loadCollectors(*enabledCollectors)
if err != nil { if err != nil {
log.Fatalf("Couldn't load collectors: %s", err) log.Fatalf("Couldn't load collectors: %s", err)