mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-06 10:36:36 +00:00
Merge pull request #1186 from jkroepke/custom-kingpin
Remove fluent-style kingpin
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/leoluk/perflib_exporter/perflib"
|
"github.com/leoluk/perflib_exporter/perflib"
|
||||||
"github.com/prometheus-community/windows_exporter/log"
|
"github.com/prometheus-community/windows_exporter/log"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -51,6 +52,8 @@ func getWindowsVersion() float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type collectorBuilder func() (Collector, error)
|
type collectorBuilder func() (Collector, error)
|
||||||
|
type flagsBuilder func(*kingpin.Application)
|
||||||
|
type perfCounterNamesBuilder func() []string
|
||||||
|
|
||||||
var (
|
var (
|
||||||
builders = make(map[string]collectorBuilder)
|
builders = make(map[string]collectorBuilder)
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dfsrEnabledCollectors = kingpin.Flag("collectors.dfsr.sources-enabled", "Comma-seperated list of DFSR Perflib sources to use.").Default("connection,folder,volume").String()
|
const (
|
||||||
|
FlagDfsrEnabledCollectors = "collectors.dfsr.sources-enabled"
|
||||||
|
)
|
||||||
|
|
||||||
|
var dfsrEnabledCollectors *string
|
||||||
|
|
||||||
// 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 {
|
||||||
@@ -82,6 +86,11 @@ func dfsrGetPerfObjectName(collector string) string {
|
|||||||
return (prefix + suffix)
|
return (prefix + suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newDFSRCollectorFlags is registered
|
||||||
|
func newDFSRCollectorFlags(app *kingpin.Application) {
|
||||||
|
dfsrEnabledCollectors = app.Flag(FlagDfsrEnabledCollectors, "Comma-seperated list of DFSR Perflib sources to use.").Default("connection,folder,volume").String()
|
||||||
|
}
|
||||||
|
|
||||||
// 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.")
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagExchangeListAllCollectors = "collectors.exchange.list"
|
||||||
|
FlagExchangeCollectorsEnabled = "collectors.exchange.enabled"
|
||||||
|
)
|
||||||
|
|
||||||
type exchangeCollector struct {
|
type exchangeCollector struct {
|
||||||
LDAPReadTime *prometheus.Desc
|
LDAPReadTime *prometheus.Desc
|
||||||
LDAPSearchTime *prometheus.Desc
|
LDAPSearchTime *prometheus.Desc
|
||||||
@@ -69,16 +74,23 @@ var (
|
|||||||
"RpcClientAccess",
|
"RpcClientAccess",
|
||||||
}
|
}
|
||||||
|
|
||||||
argExchangeListAllCollectors = kingpin.Flag(
|
argExchangeListAllCollectors *bool
|
||||||
"collectors.exchange.list",
|
|
||||||
|
argExchangeCollectorsEnabled *string
|
||||||
|
)
|
||||||
|
|
||||||
|
// newExchangeCollectorFlags ...
|
||||||
|
func newExchangeCollectorFlags(app *kingpin.Application) {
|
||||||
|
argExchangeListAllCollectors = app.Flag(
|
||||||
|
FlagExchangeListAllCollectors,
|
||||||
"List the collectors along with their perflib object name/ids",
|
"List the collectors along with their perflib object name/ids",
|
||||||
).Bool()
|
).Bool()
|
||||||
|
|
||||||
argExchangeCollectorsEnabled = kingpin.Flag(
|
argExchangeCollectorsEnabled = app.Flag(
|
||||||
"collectors.exchange.enabled",
|
FlagExchangeCollectorsEnabled,
|
||||||
"Comma-separated list of collectors to use. Defaults to all, if not specified.",
|
"Comma-separated list of collectors to use. Defaults to all, if not specified.",
|
||||||
).Default("").String()
|
).Default("").String()
|
||||||
)
|
}
|
||||||
|
|
||||||
// newExchangeCollector returns a new Collector
|
// newExchangeCollector returns a new Collector
|
||||||
func newExchangeCollector() (Collector, error) {
|
func newExchangeCollector() (Collector, error) {
|
||||||
|
|||||||
@@ -13,11 +13,18 @@ import (
|
|||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagISSSiteBlacklist = "collector.iis.site-blacklist"
|
||||||
|
FlagISSSiteWhitelist = "collector.iis.site-whitelist"
|
||||||
|
FlagISSAppBlacklist = "collector.iis.app-blacklist"
|
||||||
|
FlagISSAppWhitelist = "collector.iis.app-whitelist"
|
||||||
|
)
|
||||||
|
|
||||||
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 *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 *string
|
||||||
appWhitelist = kingpin.Flag("collector.iis.app-whitelist", "Regexp of apps to whitelist. App name must both match whitelist and not match blacklist to be included.").Default(".+").String()
|
appWhitelist *string
|
||||||
appBlacklist = kingpin.Flag("collector.iis.app-blacklist", "Regexp of apps to blacklist. App name must both match whitelist and not match blacklist to be included.").String()
|
appBlacklist *string
|
||||||
)
|
)
|
||||||
|
|
||||||
type simple_version struct {
|
type simple_version struct {
|
||||||
@@ -191,6 +198,13 @@ type IISCollector struct {
|
|||||||
iis_version simple_version
|
iis_version simple_version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newIISCollectorFlags(app *kingpin.Application) {
|
||||||
|
siteWhitelist = kingpin.Flag(FlagISSSiteWhitelist, "Regexp of sites to whitelist. Site name must both match whitelist and not match blacklist to be included.").Default(".+").String()
|
||||||
|
siteBlacklist = kingpin.Flag(FlagISSSiteBlacklist, "Regexp of sites to blacklist. Site name must both match whitelist and not match blacklist to be included.").String()
|
||||||
|
appWhitelist = kingpin.Flag(FlagISSAppWhitelist, "Regexp of apps to whitelist. App name must both match whitelist and not match blacklist to be included.").Default(".+").String()
|
||||||
|
appBlacklist = kingpin.Flag(FlagISSAppBlacklist, "Regexp of apps to blacklist. App name must both match whitelist and not match blacklist to be included.").String()
|
||||||
|
}
|
||||||
|
|
||||||
func newIISCollector() (Collector, error) {
|
func newIISCollector() (Collector, error) {
|
||||||
const subsystem = "iis"
|
const subsystem = "iis"
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,18 @@
|
|||||||
package collector
|
package collector
|
||||||
|
|
||||||
|
import "github.com/alecthomas/kingpin/v2"
|
||||||
|
|
||||||
// collectorInit represents the required initialisation config for a collector.
|
// collectorInit represents the required initialisation config for a collector.
|
||||||
type collectorInit struct {
|
type collectorInit struct {
|
||||||
// Name of collector to be initialised
|
// Name of collector to be initialised
|
||||||
name string
|
name string
|
||||||
// Builder function for the collector
|
// Builder function for the collector
|
||||||
|
flags flagsBuilder
|
||||||
|
// Builder function for the collector
|
||||||
builder collectorBuilder
|
builder collectorBuilder
|
||||||
// Perflib counter names for the collector.
|
// Perflib counter names for the collector.
|
||||||
// These will be included in the Perflib scrape scope by the exporter.
|
// These will be included in the Perflib scrape scope by the exporter.
|
||||||
perfCounterNames []string
|
perfCounterFunc perfCounterNamesBuilder
|
||||||
}
|
|
||||||
|
|
||||||
func getCPUCollectorDeps() string {
|
|
||||||
// See below for 6.05 magic value
|
|
||||||
if getWindowsVersion() > 6.05 {
|
|
||||||
return "Processor Information"
|
|
||||||
}
|
|
||||||
return "Processor"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDFSRCollectorDeps() []string {
|
func getDFSRCollectorDeps() []string {
|
||||||
@@ -32,278 +27,381 @@ func getDFSRCollectorDeps() []string {
|
|||||||
|
|
||||||
var collectors = []collectorInit{
|
var collectors = []collectorInit{
|
||||||
{
|
{
|
||||||
name: "ad",
|
name: "ad",
|
||||||
builder: newADCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newADCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "adcs",
|
name: "adcs",
|
||||||
builder: adcsCollectorMethod,
|
flags: nil,
|
||||||
perfCounterNames: []string{"Certification Authority"},
|
builder: adcsCollectorMethod,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"Certification Authority"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "adfs",
|
name: "adfs",
|
||||||
builder: newADFSCollector,
|
flags: nil,
|
||||||
perfCounterNames: []string{"AD FS"},
|
builder: newADFSCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"AD FS"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "cache",
|
name: "cache",
|
||||||
builder: newCacheCollector,
|
flags: nil,
|
||||||
perfCounterNames: []string{"Cache"},
|
builder: newCacheCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"Cache"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "container",
|
name: "container",
|
||||||
builder: newContainerMetricsCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newContainerMetricsCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "cpu",
|
name: "cpu",
|
||||||
builder: newCPUCollector,
|
flags: nil,
|
||||||
perfCounterNames: []string{getCPUCollectorDeps()},
|
builder: newCPUCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
if getWindowsVersion() > 6.05 {
|
||||||
|
return []string{"Processor Information"}
|
||||||
|
}
|
||||||
|
return []string{"Processor"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "cpu_info",
|
name: "cpu_info",
|
||||||
builder: newCpuInfoCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newCpuInfoCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "cs",
|
name: "cs",
|
||||||
builder: newCSCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newCSCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dfsr",
|
name: "dfsr",
|
||||||
builder: newDFSRCollector,
|
flags: newDFSRCollectorFlags,
|
||||||
perfCounterNames: getDFSRCollectorDeps(),
|
builder: newDFSRCollector,
|
||||||
|
perfCounterFunc: getDFSRCollectorDeps,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dhcp",
|
name: "dhcp",
|
||||||
builder: newDhcpCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newDhcpCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "diskdrive",
|
name: "diskdrive",
|
||||||
builder: newDiskDriveInfoCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newDiskDriveInfoCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dns",
|
name: "dns",
|
||||||
builder: newDNSCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newDNSCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "exchange",
|
name: "exchange",
|
||||||
|
flags: newExchangeCollectorFlags,
|
||||||
builder: newExchangeCollector,
|
builder: newExchangeCollector,
|
||||||
perfCounterNames: []string{
|
perfCounterFunc: func() []string {
|
||||||
"MSExchange ADAccess Processes",
|
return []string{
|
||||||
"MSExchangeTransport Queues",
|
"MSExchange ADAccess Processes",
|
||||||
"MSExchange HttpProxy",
|
"MSExchangeTransport Queues",
|
||||||
"MSExchange ActiveSync",
|
"MSExchange HttpProxy",
|
||||||
"MSExchange Availability Service",
|
"MSExchange ActiveSync",
|
||||||
"MSExchange OWA",
|
"MSExchange Availability Service",
|
||||||
"MSExchangeAutodiscover",
|
"MSExchange OWA",
|
||||||
"MSExchange WorkloadManagement Workloads",
|
"MSExchangeAutodiscover",
|
||||||
"MSExchange RpcClientAccess",
|
"MSExchange WorkloadManagement Workloads",
|
||||||
|
"MSExchange RpcClientAccess",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "fsrmquota",
|
name: "fsrmquota",
|
||||||
builder: newFSRMQuotaCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newFSRMQuotaCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "hyperv",
|
name: "hyperv",
|
||||||
builder: newHyperVCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newHyperVCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "iis",
|
name: "iis",
|
||||||
|
flags: newIISCollectorFlags,
|
||||||
builder: newIISCollector,
|
builder: newIISCollector,
|
||||||
perfCounterNames: []string{"Web Service",
|
perfCounterFunc: func() []string {
|
||||||
"APP_POOL_WAS",
|
return []string{
|
||||||
"Web Service Cache",
|
"Web Service",
|
||||||
"W3SVC_W3WP",
|
"APP_POOL_WAS",
|
||||||
|
"Web Service Cache",
|
||||||
|
"W3SVC_W3WP",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "logical_disk",
|
name: "logical_disk",
|
||||||
builder: newLogicalDiskCollector,
|
flags: newLogicalDiskCollectorFlags,
|
||||||
perfCounterNames: []string{"LogicalDisk"},
|
builder: newLogicalDiskCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"LogicalDisk"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "logon",
|
name: "logon",
|
||||||
builder: newLogonCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newLogonCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "memory",
|
name: "memory",
|
||||||
builder: newMemoryCollector,
|
flags: nil,
|
||||||
perfCounterNames: []string{"Memory"},
|
builder: newMemoryCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"Memory"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mscluster_cluster",
|
name: "mscluster_cluster",
|
||||||
builder: newMSCluster_ClusterCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newMSCluster_ClusterCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mscluster_network",
|
name: "mscluster_network",
|
||||||
builder: newMSCluster_NetworkCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newMSCluster_NetworkCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mscluster_node",
|
name: "mscluster_node",
|
||||||
builder: newMSCluster_NodeCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newMSCluster_NodeCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mscluster_resource",
|
name: "mscluster_resource",
|
||||||
builder: newMSCluster_ResourceCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newMSCluster_ResourceCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mscluster_resourcegroup",
|
name: "mscluster_resourcegroup",
|
||||||
builder: newMSCluster_ResourceGroupCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newMSCluster_ResourceGroupCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "msmq",
|
name: "msmq",
|
||||||
builder: newMSMQCollector,
|
flags: newMSMQCollectorFlags,
|
||||||
perfCounterNames: nil,
|
builder: newMSMQCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mssql",
|
name: "mssql",
|
||||||
builder: newMSSQLCollector,
|
flags: newMSSQLCollectorFlags,
|
||||||
perfCounterNames: nil,
|
builder: newMSSQLCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "net",
|
name: "net",
|
||||||
builder: newNetworkCollector,
|
flags: newNetworkCollectorFlags,
|
||||||
perfCounterNames: []string{"Network Interface"},
|
builder: newNetworkCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"Network Interface"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "netframework_clrexceptions",
|
name: "netframework_clrexceptions",
|
||||||
builder: newNETFramework_NETCLRExceptionsCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newNETFramework_NETCLRExceptionsCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "netframework_clrinterop",
|
name: "netframework_clrinterop",
|
||||||
builder: newNETFramework_NETCLRInteropCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newNETFramework_NETCLRInteropCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "netframework_clrjit",
|
name: "netframework_clrjit",
|
||||||
builder: newNETFramework_NETCLRJitCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newNETFramework_NETCLRJitCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "netframework_clrloading",
|
name: "netframework_clrloading",
|
||||||
builder: newNETFramework_NETCLRLoadingCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newNETFramework_NETCLRLoadingCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "netframework_clrlocksandthreads",
|
name: "netframework_clrlocksandthreads",
|
||||||
builder: newNETFramework_NETCLRLocksAndThreadsCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newNETFramework_NETCLRLocksAndThreadsCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "netframework_clrmemory",
|
name: "netframework_clrmemory",
|
||||||
builder: newNETFramework_NETCLRMemoryCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newNETFramework_NETCLRMemoryCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "netframework_clrremoting",
|
name: "netframework_clrremoting",
|
||||||
builder: newNETFramework_NETCLRRemotingCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newNETFramework_NETCLRRemotingCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "netframework_clrsecurity",
|
name: "netframework_clrsecurity",
|
||||||
builder: newNETFramework_NETCLRSecurityCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newNETFramework_NETCLRSecurityCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "os",
|
name: "os",
|
||||||
builder: newOSCollector,
|
flags: nil,
|
||||||
perfCounterNames: []string{"Paging File"},
|
builder: newOSCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"Paging File"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "process",
|
name: "process",
|
||||||
builder: newProcessCollector,
|
flags: newProcessCollectorFlags,
|
||||||
perfCounterNames: []string{"Process"},
|
builder: newProcessCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"Process"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "remote_fx",
|
name: "remote_fx",
|
||||||
builder: newRemoteFx,
|
flags: nil,
|
||||||
perfCounterNames: []string{"RemoteFX Network"},
|
builder: newRemoteFx,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"RemoteFX Network"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "scheduled_task",
|
name: "scheduled_task",
|
||||||
builder: newScheduledTask,
|
flags: newScheduledTaskFlags,
|
||||||
perfCounterNames: nil,
|
builder: newScheduledTask,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "service",
|
name: "service",
|
||||||
builder: newserviceCollector,
|
flags: newServiceCollectorFlags,
|
||||||
perfCounterNames: nil,
|
builder: newserviceCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "smtp",
|
name: "smtp",
|
||||||
builder: newSMTPCollector,
|
flags: newSMTPCollectorFlags,
|
||||||
perfCounterNames: []string{"SMTP Server"},
|
builder: newSMTPCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"SMTP Server"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "system",
|
name: "system",
|
||||||
builder: newSystemCollector,
|
flags: nil,
|
||||||
perfCounterNames: []string{"System"},
|
builder: newSystemCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"System"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "teradici_pcoip",
|
name: "teradici_pcoip",
|
||||||
builder: newTeradiciPcoipCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newTeradiciPcoipCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tcp",
|
name: "tcp",
|
||||||
builder: newTCPCollector,
|
flags: nil,
|
||||||
perfCounterNames: []string{"TCPv4"},
|
builder: newTCPCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"TCPv4"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "terminal_services",
|
name: "terminal_services",
|
||||||
|
flags: nil,
|
||||||
builder: newTerminalServicesCollector,
|
builder: newTerminalServicesCollector,
|
||||||
perfCounterNames: []string{
|
perfCounterFunc: func() []string {
|
||||||
"Terminal Services",
|
return []string{
|
||||||
"Terminal Services Session",
|
"Terminal Services",
|
||||||
"Remote Desktop Connection Broker Counterset",
|
"Terminal Services Session",
|
||||||
|
"Remote Desktop Connection Broker Counterset",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "textfile",
|
name: "textfile",
|
||||||
builder: newTextFileCollector,
|
flags: newTextFileCollectorFlags,
|
||||||
perfCounterNames: nil,
|
builder: newTextFileCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "thermalzone",
|
name: "thermalzone",
|
||||||
builder: newThermalZoneCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newThermalZoneCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "time",
|
name: "time",
|
||||||
builder: newTimeCollector,
|
flags: nil,
|
||||||
perfCounterNames: []string{"Windows Time Service"},
|
builder: newTimeCollector,
|
||||||
|
perfCounterFunc: func() []string {
|
||||||
|
return []string{"Windows Time Service"}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "vmware",
|
name: "vmware",
|
||||||
builder: newVmwareCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newVmwareCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "vmware_blast",
|
name: "vmware_blast",
|
||||||
builder: newVmwareBlastCollector,
|
flags: nil,
|
||||||
perfCounterNames: nil,
|
builder: newVmwareBlastCollector,
|
||||||
|
perfCounterFunc: nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be called by the exporter for collector initialisation
|
// RegisterCollectorsFlags To be called by the exporter for collector initialisation before running app.Parse
|
||||||
func RegisterCollectors() {
|
func RegisterCollectorsFlags(app *kingpin.Application) {
|
||||||
for _, v := range collectors {
|
for _, v := range collectors {
|
||||||
registerCollector(v.name, v.builder, v.perfCounterNames...)
|
if v.flags != nil {
|
||||||
|
v.flags(app)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterCollectors To be called by the exporter for collector initialisation
|
||||||
|
func RegisterCollectors() {
|
||||||
|
for _, v := range collectors {
|
||||||
|
var perfCounterNames []string
|
||||||
|
|
||||||
|
if v.perfCounterFunc != nil {
|
||||||
|
perfCounterNames = v.perfCounterFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
registerCollector(v.name, v.builder, perfCounterNames...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,15 +12,14 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagLogicalDiskVolumeBlacklist = "collector.logical_disk.volume-blacklist"
|
||||||
|
FlagLogicalDiskVolumeWhitelist = "collector.logical_disk.volume-whitelist"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
volumeWhitelist = kingpin.Flag(
|
volumeWhitelist *string
|
||||||
"collector.logical_disk.volume-whitelist",
|
volumeBlacklist *string
|
||||||
"Regexp of volumes to whitelist. Volume name must both match whitelist and not match blacklist to be included.",
|
|
||||||
).Default(".+").String()
|
|
||||||
volumeBlacklist = kingpin.Flag(
|
|
||||||
"collector.logical_disk.volume-blacklist",
|
|
||||||
"Regexp of volumes to blacklist. Volume name must both match whitelist and not match blacklist to be included.",
|
|
||||||
).Default("").String()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// A LogicalDiskCollector is a Prometheus collector for perflib logicalDisk metrics
|
// A LogicalDiskCollector is a Prometheus collector for perflib logicalDisk metrics
|
||||||
@@ -46,6 +45,18 @@ type LogicalDiskCollector struct {
|
|||||||
volumeBlacklistPattern *regexp.Regexp
|
volumeBlacklistPattern *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newLogicalDiskCollectorFlags ...
|
||||||
|
func newLogicalDiskCollectorFlags(app *kingpin.Application) {
|
||||||
|
volumeWhitelist = app.Flag(
|
||||||
|
FlagLogicalDiskVolumeWhitelist,
|
||||||
|
"Regexp of volumes to whitelist. Volume name must both match whitelist and not match blacklist to be included.",
|
||||||
|
).Default(".+").String()
|
||||||
|
volumeBlacklist = app.Flag(
|
||||||
|
FlagLogicalDiskVolumeBlacklist,
|
||||||
|
"Regexp of volumes to blacklist. Volume name must both match whitelist and not match blacklist to be included.",
|
||||||
|
).Default("").String()
|
||||||
|
}
|
||||||
|
|
||||||
// newLogicalDiskCollector ...
|
// newLogicalDiskCollector ...
|
||||||
func newLogicalDiskCollector() (Collector, error) {
|
func newLogicalDiskCollector() (Collector, error) {
|
||||||
const subsystem = "logical_disk"
|
const subsystem = "logical_disk"
|
||||||
|
|||||||
@@ -12,8 +12,12 @@ import (
|
|||||||
"github.com/yusufpapurcu/wmi"
|
"github.com/yusufpapurcu/wmi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagMsmqWhereClause = "collector.msmq.msmq-where"
|
||||||
|
)
|
||||||
|
|
||||||
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 *string
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Win32_PerfRawData_MSMQ_MSMQQueueCollector is a Prometheus collector for WMI Win32_PerfRawData_MSMQ_MSMQQueue metrics
|
// A Win32_PerfRawData_MSMQ_MSMQQueueCollector is a Prometheus collector for WMI Win32_PerfRawData_MSMQ_MSMQQueue metrics
|
||||||
@@ -26,6 +30,11 @@ type Win32_PerfRawData_MSMQ_MSMQQueueCollector struct {
|
|||||||
queryWhereClause string
|
queryWhereClause string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newMSMQCollectorFlags ..
|
||||||
|
func newMSMQCollectorFlags(app *kingpin.Application) {
|
||||||
|
msmqWhereClause = app.Flag(FlagMsmqWhereClause, "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()
|
||||||
|
}
|
||||||
|
|
||||||
// NewWin32_PerfRawData_MSMQ_MSMQQueueCollector ...
|
// NewWin32_PerfRawData_MSMQ_MSMQQueueCollector ...
|
||||||
func newMSMQCollector() (Collector, error) {
|
func newMSMQCollector() (Collector, error) {
|
||||||
const subsystem = "msmq"
|
const subsystem = "msmq"
|
||||||
|
|||||||
@@ -17,16 +17,15 @@ import (
|
|||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
const (
|
||||||
mssqlEnabledCollectors = kingpin.Flag(
|
FlagMssqlEnabledCollectors = "collectors.mssql.classes-enabled"
|
||||||
"collectors.mssql.classes-enabled",
|
FlagMssqlPrintCollectors = "collectors.mssql.class-print"
|
||||||
"Comma-separated list of mssql WMI classes to use.").
|
)
|
||||||
Default(mssqlAvailableClassCollectors()).String()
|
|
||||||
|
|
||||||
mssqlPrintCollectors = kingpin.Flag(
|
var (
|
||||||
"collectors.mssql.class-print",
|
mssqlEnabledCollectors *string
|
||||||
"If true, print available mssql WMI classes and exit. Only displays if the mssql collector is enabled.",
|
|
||||||
).Bool()
|
mssqlPrintCollectors *bool
|
||||||
)
|
)
|
||||||
|
|
||||||
type mssqlInstancesType map[string]string
|
type mssqlInstancesType map[string]string
|
||||||
@@ -401,6 +400,19 @@ type MSSQLCollector struct {
|
|||||||
mssqlChildCollectorFailure int
|
mssqlChildCollectorFailure int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newMSSQLCollectorFlags ...
|
||||||
|
func newMSSQLCollectorFlags(app *kingpin.Application) {
|
||||||
|
mssqlEnabledCollectors = app.Flag(
|
||||||
|
FlagMssqlEnabledCollectors,
|
||||||
|
"Comma-separated list of mssql WMI classes to use.").
|
||||||
|
Default(mssqlAvailableClassCollectors()).String()
|
||||||
|
|
||||||
|
mssqlPrintCollectors = app.Flag(
|
||||||
|
FlagMssqlPrintCollectors,
|
||||||
|
"If true, print available mssql WMI classes and exit. Only displays if the mssql collector is enabled.",
|
||||||
|
).Bool()
|
||||||
|
}
|
||||||
|
|
||||||
// newMSSQLCollector ...
|
// newMSSQLCollector ...
|
||||||
func newMSSQLCollector() (Collector, error) {
|
func newMSSQLCollector() (Collector, error) {
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,14 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagNicBlacklist = "collector.net.nic-blacklist"
|
||||||
|
FlagNicWhitelist = "collector.net.nic-whitelist"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
nicWhitelist = kingpin.Flag(
|
nicWhitelist *string
|
||||||
"collector.net.nic-whitelist",
|
nicBlacklist *string
|
||||||
"Regexp of NIC:s to whitelist. NIC name must both match whitelist and not match blacklist to be included.",
|
|
||||||
).Default(".+").String()
|
|
||||||
nicBlacklist = kingpin.Flag(
|
|
||||||
"collector.net.nic-blacklist",
|
|
||||||
"Regexp of NIC:s to blacklist. NIC name must both match whitelist and not match blacklist to be included.",
|
|
||||||
).Default("").String()
|
|
||||||
nicNameToUnderscore = regexp.MustCompile("[^a-zA-Z0-9]")
|
nicNameToUnderscore = regexp.MustCompile("[^a-zA-Z0-9]")
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -44,6 +43,18 @@ type NetworkCollector struct {
|
|||||||
nicBlacklistPattern *regexp.Regexp
|
nicBlacklistPattern *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newNetworkCollectorFlags ...
|
||||||
|
func newNetworkCollectorFlags(app *kingpin.Application) {
|
||||||
|
nicWhitelist = app.Flag(
|
||||||
|
FlagNicWhitelist,
|
||||||
|
"Regexp of NIC:s to whitelist. NIC name must both match whitelist and not match blacklist to be included.",
|
||||||
|
).Default(".+").String()
|
||||||
|
nicBlacklist = app.Flag(
|
||||||
|
FlagNicBlacklist,
|
||||||
|
"Regexp of NIC:s to blacklist. NIC name must both match whitelist and not match blacklist to be included.",
|
||||||
|
).Default("").String()
|
||||||
|
}
|
||||||
|
|
||||||
// newNetworkCollector ...
|
// newNetworkCollector ...
|
||||||
func newNetworkCollector() (Collector, error) {
|
func newNetworkCollector() (Collector, error) {
|
||||||
const subsystem = "net"
|
const subsystem = "net"
|
||||||
|
|||||||
@@ -15,15 +15,14 @@ import (
|
|||||||
"github.com/yusufpapurcu/wmi"
|
"github.com/yusufpapurcu/wmi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagProcessBlacklist = "collector.process.blacklist"
|
||||||
|
FlagProcessWhitelist = "collector.process.whitelist"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
processWhitelist = kingpin.Flag(
|
processWhitelist *string
|
||||||
"collector.process.whitelist",
|
processBlacklist *string
|
||||||
"Regexp of processes to include. Process name must both match whitelist and not match blacklist to be included.",
|
|
||||||
).Default(".*").String()
|
|
||||||
processBlacklist = kingpin.Flag(
|
|
||||||
"collector.process.blacklist",
|
|
||||||
"Regexp of processes to exclude. Process name must both match whitelist and not match blacklist to be included.",
|
|
||||||
).Default("").String()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type processCollector struct {
|
type processCollector struct {
|
||||||
@@ -47,6 +46,18 @@ type processCollector struct {
|
|||||||
processBlacklistPattern *regexp.Regexp
|
processBlacklistPattern *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newProcessCollectorFlags ...
|
||||||
|
func newProcessCollectorFlags(app *kingpin.Application) {
|
||||||
|
processWhitelist = app.Flag(
|
||||||
|
FlagProcessWhitelist,
|
||||||
|
"Regexp of processes to include. Process name must both match whitelist and not match blacklist to be included.",
|
||||||
|
).Default(".*").String()
|
||||||
|
processBlacklist = app.Flag(
|
||||||
|
FlagProcessBlacklist,
|
||||||
|
"Regexp of processes to exclude. Process name must both match whitelist and not match blacklist to be included.",
|
||||||
|
).Default("").String()
|
||||||
|
}
|
||||||
|
|
||||||
// NewProcessCollector ...
|
// NewProcessCollector ...
|
||||||
func newProcessCollector() (Collector, error) {
|
func newProcessCollector() (Collector, error) {
|
||||||
const subsystem = "process"
|
const subsystem = "process"
|
||||||
|
|||||||
@@ -16,15 +16,14 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagScheduledTaskBlacklist = "collector.scheduled_task.blacklist"
|
||||||
|
FlagScheduledTaskWhitelist = "collector.scheduled_task.whitelist"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
taskWhitelist = kingpin.Flag(
|
taskWhitelist *string
|
||||||
"collector.scheduled_task.whitelist",
|
taskBlacklist *string
|
||||||
"Regexp of tasks to whitelist. Task path must both match whitelist and not match blacklist to be included.",
|
|
||||||
).Default(".+").String()
|
|
||||||
taskBlacklist = kingpin.Flag(
|
|
||||||
"collector.scheduled_task.blacklist",
|
|
||||||
"Regexp of tasks to blacklist. Task path must both match whitelist and not match blacklist to be included.",
|
|
||||||
).String()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScheduledTaskCollector struct {
|
type ScheduledTaskCollector struct {
|
||||||
@@ -63,6 +62,18 @@ type ScheduledTask struct {
|
|||||||
|
|
||||||
type ScheduledTasks []ScheduledTask
|
type ScheduledTasks []ScheduledTask
|
||||||
|
|
||||||
|
// newScheduledTask ...
|
||||||
|
func newScheduledTaskFlags(app *kingpin.Application) {
|
||||||
|
taskWhitelist = app.Flag(
|
||||||
|
FlagScheduledTaskWhitelist,
|
||||||
|
"Regexp of tasks to whitelist. Task path must both match whitelist and not match blacklist to be included.",
|
||||||
|
).Default(".+").String()
|
||||||
|
taskBlacklist = app.Flag(
|
||||||
|
FlagScheduledTaskBlacklist,
|
||||||
|
"Regexp of tasks to blacklist. Task path must both match whitelist and not match blacklist to be included.",
|
||||||
|
).String()
|
||||||
|
}
|
||||||
|
|
||||||
// newScheduledTask ...
|
// newScheduledTask ...
|
||||||
func newScheduledTask() (Collector, error) {
|
func newScheduledTask() (Collector, error) {
|
||||||
const subsystem = "scheduled_task"
|
const subsystem = "scheduled_task"
|
||||||
|
|||||||
@@ -16,15 +16,14 @@ import (
|
|||||||
"golang.org/x/sys/windows/svc/mgr"
|
"golang.org/x/sys/windows/svc/mgr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagServiceWhereClause = "collector.service.services-where"
|
||||||
|
FlagServiceUseAPI = "collector.service.use-api"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
serviceWhereClause = kingpin.Flag(
|
serviceWhereClause *string
|
||||||
"collector.service.services-where",
|
useAPI *bool
|
||||||
"WQL 'where' clause to use in WMI metrics query. Limits the response to the services you specify and reduces the size of the response.",
|
|
||||||
).Default("").String()
|
|
||||||
useAPI = kingpin.Flag(
|
|
||||||
"collector.service.use-api",
|
|
||||||
"Use API calls to collect service data instead of WMI. Flag 'collector.service.services-where' won't be effective.",
|
|
||||||
).Default("false").Bool()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// A serviceCollector is a Prometheus collector for WMI Win32_Service metrics
|
// A serviceCollector is a Prometheus collector for WMI Win32_Service metrics
|
||||||
@@ -37,6 +36,18 @@ type serviceCollector struct {
|
|||||||
queryWhereClause string
|
queryWhereClause string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newServiceCollectorFlags ...
|
||||||
|
func newServiceCollectorFlags(app *kingpin.Application) {
|
||||||
|
serviceWhereClause = app.Flag(
|
||||||
|
FlagServiceWhereClause,
|
||||||
|
"WQL 'where' clause to use in WMI metrics query. Limits the response to the services you specify and reduces the size of the response.",
|
||||||
|
).Default("").String()
|
||||||
|
useAPI = app.Flag(
|
||||||
|
FlagServiceUseAPI,
|
||||||
|
"Use API calls to collect service data instead of WMI. Flag 'collector.service.services-where' won't be effective.",
|
||||||
|
).Default("false").Bool()
|
||||||
|
}
|
||||||
|
|
||||||
// newserviceCollector ...
|
// newserviceCollector ...
|
||||||
func newserviceCollector() (Collector, error) {
|
func newserviceCollector() (Collector, error) {
|
||||||
const subsystem = "service"
|
const subsystem = "service"
|
||||||
|
|||||||
@@ -11,9 +11,14 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagSmtpServerBlacklist = "collector.smtp.server-blacklist"
|
||||||
|
FlagSmtpServerWhitelist = "collector.smtp.server-whitelist"
|
||||||
|
)
|
||||||
|
|
||||||
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 *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 *string
|
||||||
)
|
)
|
||||||
|
|
||||||
type SMTPCollector struct {
|
type SMTPCollector struct {
|
||||||
@@ -64,6 +69,11 @@ type SMTPCollector struct {
|
|||||||
serverBlacklistPattern *regexp.Regexp
|
serverBlacklistPattern *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newSMTPCollectorFlags(app *kingpin.Application) {
|
||||||
|
serverWhitelist = app.Flag(FlagSmtpServerWhitelist, "Regexp of virtual servers to whitelist. Server name must both match whitelist and not match blacklist to be included.").Default(".+").String()
|
||||||
|
serverBlacklist = app.Flag(FlagSmtpServerBlacklist, "Regexp of virtual servers to blacklist. Server name must both match whitelist and not match blacklist to be included.").String()
|
||||||
|
}
|
||||||
|
|
||||||
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"
|
||||||
|
|||||||
@@ -35,11 +35,12 @@ import (
|
|||||||
"github.com/prometheus/common/expfmt"
|
"github.com/prometheus/common/expfmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FlagTextFileDirectory = "collector.textfile.directory"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
textFileDirectory = kingpin.Flag(
|
textFileDirectory *string
|
||||||
"collector.textfile.directory",
|
|
||||||
"Directory to read text files with metrics from.",
|
|
||||||
).Default(getDefaultPath()).String()
|
|
||||||
|
|
||||||
mtimeDesc = prometheus.NewDesc(
|
mtimeDesc = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, "textfile", "mtime_seconds"),
|
prometheus.BuildFQName(Namespace, "textfile", "mtime_seconds"),
|
||||||
@@ -55,6 +56,14 @@ type textFileCollector struct {
|
|||||||
mtime *float64
|
mtime *float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newTextFileCollectorFlags ...
|
||||||
|
func newTextFileCollectorFlags(app *kingpin.Application) {
|
||||||
|
textFileDirectory = app.Flag(
|
||||||
|
FlagTextFileDirectory,
|
||||||
|
"Directory to read text files with metrics from.",
|
||||||
|
).Default(getDefaultPath()).String()
|
||||||
|
}
|
||||||
|
|
||||||
// newTextFileCollector returns a new Collector exposing metrics read from files
|
// 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) {
|
||||||
|
|||||||
32
exporter.go
32
exporter.go
@@ -259,51 +259,55 @@ func initWbem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
app := kingpin.New("windows_exporter", "A metrics collector for Windows.")
|
||||||
var (
|
var (
|
||||||
configFile = kingpin.Flag(
|
configFile = app.Flag(
|
||||||
"config.file",
|
"config.file",
|
||||||
"YAML configuration file to use. Values set in this file will be overridden by CLI flags.",
|
"YAML configuration file to use. Values set in this file will be overridden by CLI flags.",
|
||||||
).String()
|
).String()
|
||||||
webConfig = webflag.AddFlags(kingpin.CommandLine, ":9182")
|
webConfig = webflag.AddFlags(app, ":9182")
|
||||||
metricsPath = kingpin.Flag(
|
metricsPath = app.Flag(
|
||||||
"telemetry.path",
|
"telemetry.path",
|
||||||
"URL path for surfacing collected metrics.",
|
"URL path for surfacing collected metrics.",
|
||||||
).Default("/metrics").String()
|
).Default("/metrics").String()
|
||||||
disableExporterMetrics = kingpin.Flag(
|
disableExporterMetrics = app.Flag(
|
||||||
"web.disable-exporter-metrics",
|
"web.disable-exporter-metrics",
|
||||||
"Exclude metrics about the exporter itself (promhttp_*, process_*, go_*).",
|
"Exclude metrics about the exporter itself (promhttp_*, process_*, go_*).",
|
||||||
).Bool()
|
).Bool()
|
||||||
maxRequests = kingpin.Flag(
|
maxRequests = app.Flag(
|
||||||
"telemetry.max-requests",
|
"telemetry.max-requests",
|
||||||
"Maximum number of concurrent requests. 0 to disable.",
|
"Maximum number of concurrent requests. 0 to disable.",
|
||||||
).Default("5").Int()
|
).Default("5").Int()
|
||||||
enabledCollectors = kingpin.Flag(
|
enabledCollectors = app.Flag(
|
||||||
"collectors.enabled",
|
"collectors.enabled",
|
||||||
"Comma-separated list of collectors to use. Use '[defaults]' as a placeholder for all the collectors enabled by default.").
|
"Comma-separated list of collectors to use. Use '[defaults]' as a placeholder for all the collectors enabled by default.").
|
||||||
Default(defaultCollectors).String()
|
Default(defaultCollectors).String()
|
||||||
printCollectors = kingpin.Flag(
|
printCollectors = app.Flag(
|
||||||
"collectors.print",
|
"collectors.print",
|
||||||
"If true, print available collectors and exit.",
|
"If true, print available collectors and exit.",
|
||||||
).Bool()
|
).Bool()
|
||||||
timeoutMargin = kingpin.Flag(
|
timeoutMargin = app.Flag(
|
||||||
"scrape.timeout-margin",
|
"scrape.timeout-margin",
|
||||||
"Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads.",
|
"Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads.",
|
||||||
).Default("0.5").Float64()
|
).Default("0.5").Float64()
|
||||||
)
|
)
|
||||||
log.AddFlags(kingpin.CommandLine)
|
log.AddFlags(app)
|
||||||
kingpin.Version(version.Print("windows_exporter"))
|
app.Version(version.Print("windows_exporter"))
|
||||||
kingpin.HelpFlag.Short('h')
|
app.HelpFlag.Short('h')
|
||||||
|
|
||||||
|
// Initialize collectors before loading and parsing CLI arguments
|
||||||
|
collector.RegisterCollectorsFlags(app)
|
||||||
|
|
||||||
// Load values from configuration file(s). Executable flags must first be parsed, in order
|
// Load values from configuration file(s). Executable flags must first be parsed, in order
|
||||||
// to load the specified file(s).
|
// to load the specified file(s).
|
||||||
kingpin.Parse()
|
kingpin.MustParse(app.Parse(os.Args[1:]))
|
||||||
log.Debug("Logging has Started")
|
log.Debug("Logging has Started")
|
||||||
if *configFile != "" {
|
if *configFile != "" {
|
||||||
resolver, err := config.NewResolver(*configFile)
|
resolver, err := config.NewResolver(*configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("could not load config file: %v\n", err)
|
log.Fatalf("could not load config file: %v\n", err)
|
||||||
}
|
}
|
||||||
err = resolver.Bind(kingpin.CommandLine, os.Args[1:])
|
err = resolver.Bind(app, os.Args[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("%v\n", err)
|
log.Fatalf("%v\n", err)
|
||||||
}
|
}
|
||||||
@@ -314,7 +318,7 @@ func main() {
|
|||||||
*webConfig.WebListenAddresses = (*webConfig.WebListenAddresses)[1:]
|
*webConfig.WebListenAddresses = (*webConfig.WebListenAddresses)[1:]
|
||||||
|
|
||||||
// Parse flags once more to include those discovered in configuration file(s).
|
// Parse flags once more to include those discovered in configuration file(s).
|
||||||
kingpin.Parse()
|
kingpin.MustParse(app.Parse(os.Args[1:]))
|
||||||
}
|
}
|
||||||
|
|
||||||
if *printCollectors {
|
if *printCollectors {
|
||||||
|
|||||||
Reference in New Issue
Block a user