diff --git a/collector/ad.go b/collector/ad.go index cbf0b57a63..6bf8714ad7 100644 --- a/collector/ad.go +++ b/collector/ad.go @@ -11,10 +11,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("ad", NewADCollector) -} - // A ADCollector is a Prometheus collector for WMI Win32_PerfRawData_DirectoryServices_DirectoryServices metrics type ADCollector struct { AddressBookOperationsTotal *prometheus.Desc diff --git a/collector/adcs.go b/collector/adcs.go index 6d87ce55d3..443a5d8941 100644 --- a/collector/adcs.go +++ b/collector/adcs.go @@ -10,10 +10,6 @@ import ( "strings" ) -func init() { - registerCollector("adcs", adcsCollectorMethod, "Certification Authority") -} - type adcsCollector struct { RequestsPerSecond *prometheus.Desc RequestProcessingTime *prometheus.Desc diff --git a/collector/adfs.go b/collector/adfs.go index 9b243fbfb8..6d69c22a07 100644 --- a/collector/adfs.go +++ b/collector/adfs.go @@ -8,10 +8,6 @@ import ( "math" ) -func init() { - registerCollector("adfs", newADFSCollector, "AD FS") -} - type adfsCollector struct { adLoginConnectionFailures *prometheus.Desc certificateAuthentications *prometheus.Desc diff --git a/collector/cache.go b/collector/cache.go index bba70f824b..9999cac540 100644 --- a/collector/cache.go +++ b/collector/cache.go @@ -8,10 +8,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("cache", newCacheCollector, "Cache") -} - // A CacheCollector is a Prometheus collector for Perflib Cache metrics type CacheCollector struct { AsyncCopyReadsTotal *prometheus.Desc diff --git a/collector/container.go b/collector/container.go index 332f6c163f..2812cec187 100644 --- a/collector/container.go +++ b/collector/container.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("container", NewContainerMetricsCollector) -} - // A ContainerMetricsCollector is a Prometheus collector for containers metrics type ContainerMetricsCollector struct { // Presence diff --git a/collector/cpu.go b/collector/cpu.go index e3a43a0de5..8e80195dfa 100644 --- a/collector/cpu.go +++ b/collector/cpu.go @@ -9,17 +9,6 @@ import ( "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 { CStateSecondsTotal *prometheus.Desc TimeTotal *prometheus.Desc diff --git a/collector/cpu_info.go b/collector/cpu_info.go index 3c087f047b..c8098b9dd4 100644 --- a/collector/cpu_info.go +++ b/collector/cpu_info.go @@ -13,10 +13,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -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. const ( win32ProcessorQuery = "SELECT Architecture, DeviceId, Description, Family, L2CacheSize, L3CacheSize, Name FROM Win32_Processor" diff --git a/collector/cs.go b/collector/cs.go index ba70e754f2..df768faad8 100644 --- a/collector/cs.go +++ b/collector/cs.go @@ -10,10 +10,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("cs", NewCSCollector) -} - // A CSCollector is a Prometheus collector for WMI metrics type CSCollector struct { PhysicalMemoryBytes *prometheus.Desc diff --git a/collector/dfsr.go b/collector/dfsr.go index ef438ee301..d5ff1f86d7 100644 --- a/collector/dfsr.go +++ b/collector/dfsr.go @@ -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() -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. type DFSRCollector struct { // Connection source diff --git a/collector/dhcp.go b/collector/dhcp.go index 0544b1b8a1..09c8ba0e2f 100644 --- a/collector/dhcp.go +++ b/collector/dhcp.go @@ -7,10 +7,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("dhcp", NewDhcpCollector, "DHCP Server") -} - // A DhcpCollector is a Prometheus collector perflib DHCP metrics type DhcpCollector struct { PacketsReceivedTotal *prometheus.Desc diff --git a/collector/dns.go b/collector/dns.go index 037766a29b..3cc71511a4 100644 --- a/collector/dns.go +++ b/collector/dns.go @@ -11,10 +11,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("dns", NewDNSCollector) -} - // A DNSCollector is a Prometheus collector for WMI Win32_PerfRawData_DNS_DNS metrics type DNSCollector struct { ZoneTransferRequestsReceived *prometheus.Desc diff --git a/collector/exchange.go b/collector/exchange.go index 25b0354da3..6501e2d9ad 100644 --- a/collector/exchange.go +++ b/collector/exchange.go @@ -13,20 +13,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -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 { LDAPReadTime *prometheus.Desc LDAPSearchTime *prometheus.Desc diff --git a/collector/fsrmquota.go b/collector/fsrmquota.go index 23c7c097d0..0b66411514 100644 --- a/collector/fsrmquota.go +++ b/collector/fsrmquota.go @@ -6,10 +6,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("fsrmquota", newFSRMQuotaCollector) -} - type FSRMQuotaCollector struct { QuotasCount *prometheus.Desc Path *prometheus.Desc diff --git a/collector/hyperv.go b/collector/hyperv.go index 761b5d94f3..320a2dd5f3 100644 --- a/collector/hyperv.go +++ b/collector/hyperv.go @@ -11,10 +11,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("hyperv", NewHyperVCollector) -} - // HyperVCollector is a Prometheus collector for hyper-v type HyperVCollector struct { // Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary diff --git a/collector/iis.go b/collector/iis.go index 5703e37d39..5aabff1138 100644 --- a/collector/iis.go +++ b/collector/iis.go @@ -13,10 +13,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -func init() { - registerCollector("iis", NewIISCollector, "Web Service", "APP_POOL_WAS", "Web Service Cache", "W3SVC_W3WP") -} - 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() 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() diff --git a/collector/init.go b/collector/init.go new file mode 100644 index 0000000000..da51a6611d --- /dev/null +++ b/collector/init.go @@ -0,0 +1,294 @@ +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: "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: "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, + }, +} + +// To be called by the exporter for collector initialisation +func RegisterCollectors() { + for _, v := range collectors { + registerCollector(v.name, v.builder, v.perfCounterNames...) + } +} diff --git a/collector/logical_disk.go b/collector/logical_disk.go index 36eba9bd27..dd634754f4 100644 --- a/collector/logical_disk.go +++ b/collector/logical_disk.go @@ -12,10 +12,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -func init() { - registerCollector("logical_disk", NewLogicalDiskCollector, "LogicalDisk") -} - var ( volumeWhitelist = kingpin.Flag( "collector.logical_disk.volume-whitelist", diff --git a/collector/logon.go b/collector/logon.go index 182f6bdb28..46defd3ffa 100644 --- a/collector/logon.go +++ b/collector/logon.go @@ -11,10 +11,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("logon", NewLogonCollector) -} - // A LogonCollector is a Prometheus collector for WMI metrics type LogonCollector struct { LogonType *prometheus.Desc diff --git a/collector/memory.go b/collector/memory.go index 114a927181..e216d21b95 100644 --- a/collector/memory.go +++ b/collector/memory.go @@ -11,10 +11,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("memory", NewMemoryCollector, "Memory") -} - // A MemoryCollector is a Prometheus collector for perflib Memory metrics type MemoryCollector struct { AvailableBytes *prometheus.Desc diff --git a/collector/mscluster_cluster.go b/collector/mscluster_cluster.go index 2f819ca9b5..b0f3096893 100644 --- a/collector/mscluster_cluster.go +++ b/collector/mscluster_cluster.go @@ -5,10 +5,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("mscluster_cluster", newMSCluster_ClusterCollector) -} - // A MSCluster_ClusterCollector is a Prometheus collector for WMI MSCluster_Cluster metrics type MSCluster_ClusterCollector struct { AddEvictDelay *prometheus.Desc @@ -560,7 +556,6 @@ func newMSCluster_ClusterCollector() (Collector, error) { // MSCluster_Cluster docs: // - https://docs.microsoft.com/en-us/previous-versions/windows/desktop/cluswmi/mscluster-cluster -// type MSCluster_Cluster struct { Name string diff --git a/collector/mscluster_network.go b/collector/mscluster_network.go index f0281ef504..96a44f9ca7 100644 --- a/collector/mscluster_network.go +++ b/collector/mscluster_network.go @@ -5,10 +5,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("mscluster_network", newMSCluster_NetworkCollector) -} - // A MSCluster_NetworkCollector is a Prometheus collector for WMI MSCluster_Network metrics type MSCluster_NetworkCollector struct { Characteristics *prometheus.Desc @@ -56,7 +52,6 @@ func newMSCluster_NetworkCollector() (Collector, error) { // MSCluster_Network docs: // - https://docs.microsoft.com/en-us/previous-versions/windows/desktop/cluswmi/mscluster-network -// type MSCluster_Network struct { Name string diff --git a/collector/mscluster_node.go b/collector/mscluster_node.go index e3f375f4a3..f8876cd69b 100644 --- a/collector/mscluster_node.go +++ b/collector/mscluster_node.go @@ -5,10 +5,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("mscluster_node", newMSCluster_NodeCollector) -} - // A MSCluster_NodeCollector is a Prometheus collector for WMI MSCluster_Node metrics type MSCluster_NodeCollector struct { BuildNumber *prometheus.Desc @@ -119,7 +115,6 @@ func newMSCluster_NodeCollector() (Collector, error) { // MSCluster_Node docs: // - https://docs.microsoft.com/en-us/previous-versions/windows/desktop/cluswmi/mscluster-node -// type MSCluster_Node struct { Name string diff --git a/collector/mscluster_resource.go b/collector/mscluster_resource.go index 1c50aea720..d526b55f4c 100644 --- a/collector/mscluster_resource.go +++ b/collector/mscluster_resource.go @@ -5,10 +5,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("mscluster_resource", newMSCluster_ResourceCollector) -} - // A MSCluster_ResourceCollector is a Prometheus collector for WMI MSCluster_Resource metrics type MSCluster_ResourceCollector struct { Characteristics *prometheus.Desc @@ -133,7 +129,6 @@ func newMSCluster_ResourceCollector() (Collector, error) { // MSCluster_Resource docs: // - https://docs.microsoft.com/en-us/previous-versions/windows/desktop/cluswmi/mscluster-resource -// type MSCluster_Resource struct { Name string Type string diff --git a/collector/mscluster_resourcegroup.go b/collector/mscluster_resourcegroup.go index a98bed4069..140066d03b 100644 --- a/collector/mscluster_resourcegroup.go +++ b/collector/mscluster_resourcegroup.go @@ -5,10 +5,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("mscluster_resourcegroup", newMSCluster_ResourceGroupCollector) -} - // A MSCluster_ResourceGroupCollector is a Prometheus collector for WMI MSCluster_ResourceGroup metrics type MSCluster_ResourceGroupCollector struct { AutoFailbackType *prometheus.Desc @@ -114,7 +110,6 @@ func newMSCluster_ResourceGroupCollector() (Collector, error) { // MSCluster_ResourceGroup docs: // - https://docs.microsoft.com/en-us/previous-versions/windows/desktop/cluswmi/mscluster-resourcegroup -// type MSCluster_ResourceGroup struct { Name string diff --git a/collector/msmq.go b/collector/msmq.go index d3638f5a7e..30174709d1 100644 --- a/collector/msmq.go +++ b/collector/msmq.go @@ -12,10 +12,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -func init() { - registerCollector("msmq", NewMSMQCollector) -} - 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() ) diff --git a/collector/mssql.go b/collector/mssql.go index d8430e01f6..4954ce1c20 100644 --- a/collector/mssql.go +++ b/collector/mssql.go @@ -129,10 +129,6 @@ func mssqlGetPerfObjectName(sqlInstance string, collector string) string { return (prefix + suffix) } -func init() { - registerCollector("mssql", NewMSSQLCollector) -} - // A MSSQLCollector is a Prometheus collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics type MSSQLCollector struct { // meta diff --git a/collector/net.go b/collector/net.go index 392314c6f9..cbabfa76eb 100644 --- a/collector/net.go +++ b/collector/net.go @@ -12,10 +12,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -func init() { - registerCollector("net", NewNetworkCollector, "Network Interface") -} - var ( nicWhitelist = kingpin.Flag( "collector.net.nic-whitelist", diff --git a/collector/netframework_clrexceptions.go b/collector/netframework_clrexceptions.go index 134e457d5f..2cb3b2125d 100644 --- a/collector/netframework_clrexceptions.go +++ b/collector/netframework_clrexceptions.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("netframework_clrexceptions", NewNETFramework_NETCLRExceptionsCollector) -} - // A NETFramework_NETCLRExceptionsCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRExceptions metrics type NETFramework_NETCLRExceptionsCollector struct { NumberofExcepsThrown *prometheus.Desc diff --git a/collector/netframework_clrinterop.go b/collector/netframework_clrinterop.go index fb4cfdcd8c..6cc708073f 100644 --- a/collector/netframework_clrinterop.go +++ b/collector/netframework_clrinterop.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("netframework_clrinterop", NewNETFramework_NETCLRInteropCollector) -} - // A NETFramework_NETCLRInteropCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRInterop metrics type NETFramework_NETCLRInteropCollector struct { NumberofCCWs *prometheus.Desc diff --git a/collector/netframework_clrjit.go b/collector/netframework_clrjit.go index ca1e3e6e9e..bbf349ef70 100644 --- a/collector/netframework_clrjit.go +++ b/collector/netframework_clrjit.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("netframework_clrjit", NewNETFramework_NETCLRJitCollector) -} - // A NETFramework_NETCLRJitCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRJit metrics type NETFramework_NETCLRJitCollector struct { NumberofMethodsJitted *prometheus.Desc diff --git a/collector/netframework_clrloading.go b/collector/netframework_clrloading.go index f054138843..3f4e64c803 100644 --- a/collector/netframework_clrloading.go +++ b/collector/netframework_clrloading.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("netframework_clrloading", NewNETFramework_NETCLRLoadingCollector) -} - // A NETFramework_NETCLRLoadingCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRLoading metrics type NETFramework_NETCLRLoadingCollector struct { BytesinLoaderHeap *prometheus.Desc diff --git a/collector/netframework_clrlocksandthreads.go b/collector/netframework_clrlocksandthreads.go index e5290474a7..2962301c07 100644 --- a/collector/netframework_clrlocksandthreads.go +++ b/collector/netframework_clrlocksandthreads.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("netframework_clrlocksandthreads", NewNETFramework_NETCLRLocksAndThreadsCollector) -} - // A NETFramework_NETCLRLocksAndThreadsCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads metrics type NETFramework_NETCLRLocksAndThreadsCollector struct { CurrentQueueLength *prometheus.Desc diff --git a/collector/netframework_clrmemory.go b/collector/netframework_clrmemory.go index 74fbe1fe3c..3864b1d2d4 100644 --- a/collector/netframework_clrmemory.go +++ b/collector/netframework_clrmemory.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("netframework_clrmemory", NewNETFramework_NETCLRMemoryCollector) -} - // A NETFramework_NETCLRMemoryCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRMemory metrics type NETFramework_NETCLRMemoryCollector struct { AllocatedBytes *prometheus.Desc diff --git a/collector/netframework_clrremoting.go b/collector/netframework_clrremoting.go index a4ad25ac0d..72f0327834 100644 --- a/collector/netframework_clrremoting.go +++ b/collector/netframework_clrremoting.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("netframework_clrremoting", NewNETFramework_NETCLRRemotingCollector) -} - // A NETFramework_NETCLRRemotingCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRRemoting metrics type NETFramework_NETCLRRemotingCollector struct { Channels *prometheus.Desc diff --git a/collector/netframework_clrsecurity.go b/collector/netframework_clrsecurity.go index 416bc7af91..5469f86e19 100644 --- a/collector/netframework_clrsecurity.go +++ b/collector/netframework_clrsecurity.go @@ -9,10 +9,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("netframework_clrsecurity", NewNETFramework_NETCLRSecurityCollector) -} - // A NETFramework_NETCLRSecurityCollector is a Prometheus collector for WMI Win32_PerfRawData_NETFramework_NETCLRSecurity metrics type NETFramework_NETCLRSecurityCollector struct { NumberLinkTimeChecks *prometheus.Desc diff --git a/collector/os.go b/collector/os.go index 34bab42c18..bc4635e699 100644 --- a/collector/os.go +++ b/collector/os.go @@ -17,10 +17,6 @@ import ( "golang.org/x/sys/windows/registry" ) -func init() { - registerCollector("os", NewOSCollector, "Paging File") -} - // A OSCollector is a Prometheus collector for WMI metrics type OSCollector struct { OSInformation *prometheus.Desc diff --git a/collector/process.go b/collector/process.go index d19076def8..1935c72b4f 100644 --- a/collector/process.go +++ b/collector/process.go @@ -15,10 +15,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -func init() { - registerCollector("process", newProcessCollector, "Process") -} - var ( processWhitelist = kingpin.Flag( "collector.process.whitelist", diff --git a/collector/remote_fx.go b/collector/remote_fx.go index 40ed09059c..6b547fec55 100644 --- a/collector/remote_fx.go +++ b/collector/remote_fx.go @@ -10,10 +10,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("remote_fx", NewRemoteFx, "RemoteFX Network", "RemoteFX Graphics") -} - // A RemoteFxNetworkCollector is a Prometheus collector for // WMI Win32_PerfRawData_Counters_RemoteFXNetwork & Win32_PerfRawData_Counters_RemoteFXGraphics metrics // https://wutils.com/wmi/root/cimv2/win32_perfrawdata_counters_remotefxnetwork/ diff --git a/collector/scheduled_task.go b/collector/scheduled_task.go index 20bc4b41b8..902d6f4c55 100644 --- a/collector/scheduled_task.go +++ b/collector/scheduled_task.go @@ -63,10 +63,6 @@ type ScheduledTask struct { type ScheduledTasks []ScheduledTask -func init() { - registerCollector("scheduled_task", NewScheduledTask) -} - // NewScheduledTask ... func NewScheduledTask() (Collector, error) { const subsystem = "scheduled_task" diff --git a/collector/service.go b/collector/service.go index 949872a6e7..3c86d81273 100644 --- a/collector/service.go +++ b/collector/service.go @@ -16,10 +16,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -func init() { - registerCollector("service", NewserviceCollector) -} - var ( serviceWhereClause = kingpin.Flag( "collector.service.services-where", diff --git a/collector/smtp.go b/collector/smtp.go index 94650123a4..f203ce5294 100644 --- a/collector/smtp.go +++ b/collector/smtp.go @@ -11,10 +11,6 @@ import ( "regexp" ) -func init() { - registerCollector("smtp", NewSMTPCollector, "SMTP Server") -} - 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() 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() diff --git a/collector/system.go b/collector/system.go index 2e3f763128..937913be0e 100644 --- a/collector/system.go +++ b/collector/system.go @@ -8,10 +8,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("system", NewSystemCollector, "System") -} - // A SystemCollector is a Prometheus collector for WMI metrics type SystemCollector struct { ContextSwitchesTotal *prometheus.Desc diff --git a/collector/tcp.go b/collector/tcp.go index 2cc7546985..ae9e9d12af 100644 --- a/collector/tcp.go +++ b/collector/tcp.go @@ -8,10 +8,6 @@ import ( "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 type TCPCollector struct { ConnectionFailures *prometheus.Desc diff --git a/collector/terminal_services.go b/collector/terminal_services.go index 952371478c..2c4e22ce0b 100644 --- a/collector/terminal_services.go +++ b/collector/terminal_services.go @@ -14,10 +14,6 @@ import ( const ConnectionBrokerFeatureID uint32 = 133 -func init() { - registerCollector("terminal_services", NewTerminalServicesCollector, "Terminal Services", "Terminal Services Session", "Remote Desktop Connection Broker Counterset") -} - var ( connectionBrokerEnabled = isConnectionBrokerServer() ) diff --git a/collector/textfile.go b/collector/textfile.go index 2a8d66172c..5082a4ae43 100644 --- a/collector/textfile.go +++ b/collector/textfile.go @@ -55,10 +55,6 @@ type textFileCollector struct { mtime *float64 } -func init() { - registerCollector("textfile", NewTextFileCollector) -} - // NewTextFileCollector returns a new Collector exposing metrics read from files // in the given textfile directory. func NewTextFileCollector() (Collector, error) { diff --git a/collector/thermalzone.go b/collector/thermalzone.go index 3629d473aa..f180a4aa21 100644 --- a/collector/thermalzone.go +++ b/collector/thermalzone.go @@ -8,10 +8,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("thermalzone", NewThermalZoneCollector) -} - // A thermalZoneCollector is a Prometheus collector for WMI Win32_PerfRawData_Counters_ThermalZoneInformation metrics type thermalZoneCollector struct { PercentPassiveLimit *prometheus.Desc diff --git a/collector/time.go b/collector/time.go index 82da5fa13a..a52241db30 100644 --- a/collector/time.go +++ b/collector/time.go @@ -10,10 +10,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("time", newTimeCollector, "Windows Time Service") -} - // TimeCollector is a Prometheus collector for Perflib counter metrics type TimeCollector struct { ClockFrequencyAdjustmentPPBTotal *prometheus.Desc diff --git a/collector/vmware.go b/collector/vmware.go index 0373f774ef..617a82d06b 100644 --- a/collector/vmware.go +++ b/collector/vmware.go @@ -11,10 +11,6 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func init() { - registerCollector("vmware", NewVmwareCollector) -} - // A VmwareCollector is a Prometheus collector for WMI Win32_PerfRawData_vmGuestLib_VMem/Win32_PerfRawData_vmGuestLib_VCPU metrics type VmwareCollector struct { MemActive *prometheus.Desc diff --git a/exporter.go b/exporter.go index 1f26a16970..2b6090bd9e 100644 --- a/exporter.go +++ b/exporter.go @@ -329,6 +329,9 @@ func main() { initWbem() + // Initialize collectors before loading + collector.RegisterCollectors() + collectors, err := loadCollectors(*enabledCollectors) if err != nil { log.Fatalf("Couldn't load collectors: %s", err)