mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-28 07:36:37 +00:00
adds whitelist for exchange collectors (#642)
adds enable flag for exchange collectors Signed-off-by: Björn Fischer <bfischer@inovex.de>
This commit is contained in:
@@ -119,3 +119,12 @@ func boolToFloat(b bool) float64 {
|
|||||||
}
|
}
|
||||||
return 0.0
|
return 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func find(slice []string, val string) bool {
|
||||||
|
for _, item := range slice {
|
||||||
|
if item == val {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ type exchangeCollector struct {
|
|||||||
RPCOperationsPerSec *prometheus.Desc
|
RPCOperationsPerSec *prometheus.Desc
|
||||||
UserCount *prometheus.Desc
|
UserCount *prometheus.Desc
|
||||||
|
|
||||||
ActiveCollFuncs []func(ctx *ScrapeContext, ch chan<- prometheus.Metric) error
|
enabledCollectors []string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -86,6 +86,11 @@ var (
|
|||||||
"collectors.exchange.list",
|
"collectors.exchange.list",
|
||||||
"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(
|
||||||
|
"collectors.exchange.enabled",
|
||||||
|
"Comma-separated list of collectors to use. Defaults to all, if not specified.",
|
||||||
|
).Default("").String()
|
||||||
)
|
)
|
||||||
|
|
||||||
// newExchangeCollector returns a new Collector
|
// newExchangeCollector returns a new Collector
|
||||||
@@ -139,6 +144,8 @@ func newExchangeCollector() (Collector, error) {
|
|||||||
MailboxServerProxyFailureRate: desc("http_proxy_mailbox_proxy_failure_rate", "% of failures between this CAS and MBX servers over the last 200 samples", "name"),
|
MailboxServerProxyFailureRate: desc("http_proxy_mailbox_proxy_failure_rate", "% of failures between this CAS and MBX servers over the last 200 samples", "name"),
|
||||||
PingCommandsPending: desc("activesync_ping_cmds_pending", "Number of ping commands currently pending in the queue"),
|
PingCommandsPending: desc("activesync_ping_cmds_pending", "Number of ping commands currently pending in the queue"),
|
||||||
SyncCommandsPerSec: desc("activesync_sync_cmds_total", "Number of sync commands processed per second. Clients use this command to synchronize items within a folder"),
|
SyncCommandsPerSec: desc("activesync_sync_cmds_total", "Number of sync commands processed per second. Clients use this command to synchronize items within a folder"),
|
||||||
|
|
||||||
|
enabledCollectors: make([]string, 0, len(exchangeAllCollectorNames)),
|
||||||
}
|
}
|
||||||
|
|
||||||
collectorDesc := map[string]string{
|
collectorDesc := map[string]string{
|
||||||
@@ -161,12 +168,27 @@ func newExchangeCollector() (Collector, error) {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *argExchangeCollectorsEnabled == "" {
|
||||||
|
for _, collectorName := range exchangeAllCollectorNames {
|
||||||
|
c.enabledCollectors = append(c.enabledCollectors, collectorName)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, collectorName := range strings.Split(*argExchangeCollectorsEnabled, ",") {
|
||||||
|
if find(exchangeAllCollectorNames, collectorName) {
|
||||||
|
c.enabledCollectors = append(c.enabledCollectors, collectorName)
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("Unknown exchange collector: %s", collectorName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &c, nil
|
return &c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect collects exchange metrics and sends them to prometheus
|
// Collect collects exchange metrics and sends them to prometheus
|
||||||
func (c *exchangeCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {
|
func (c *exchangeCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {
|
||||||
for collectorName, collectorFunc := range map[string]func(ctx *ScrapeContext, ch chan<- prometheus.Metric) error{
|
|
||||||
|
collectorFuncs := map[string]func(ctx *ScrapeContext, ch chan<- prometheus.Metric) error{
|
||||||
"ADAccessProcesses": c.collectADAccessProcesses,
|
"ADAccessProcesses": c.collectADAccessProcesses,
|
||||||
"TransportQueues": c.collectTransportQueues,
|
"TransportQueues": c.collectTransportQueues,
|
||||||
"HttpProxy": c.collectHTTPProxy,
|
"HttpProxy": c.collectHTTPProxy,
|
||||||
@@ -176,8 +198,10 @@ func (c *exchangeCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Met
|
|||||||
"Autodiscover": c.collectAutoDiscover,
|
"Autodiscover": c.collectAutoDiscover,
|
||||||
"WorkloadManagement": c.collectWorkloadManagementWorkloads,
|
"WorkloadManagement": c.collectWorkloadManagementWorkloads,
|
||||||
"RpcClientAccess": c.collectRPC,
|
"RpcClientAccess": c.collectRPC,
|
||||||
} {
|
}
|
||||||
if err := collectorFunc(ctx, ch); err != nil {
|
|
||||||
|
for _, collectorName := range c.enabledCollectors {
|
||||||
|
if err := collectorFuncs[collectorName](ctx, ch); err != nil {
|
||||||
log.Errorf("Error in %s: %s", collectorName, err)
|
log.Errorf("Error in %s: %s", collectorName, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ Enabled by default? | No
|
|||||||
### `--collectors.exchange.list`
|
### `--collectors.exchange.list`
|
||||||
Lists the Perflib Objects that are queried for data along with the perlfib object id
|
Lists the Perflib Objects that are queried for data along with the perlfib object id
|
||||||
|
|
||||||
|
### `--collectors.exchange.enabled`
|
||||||
|
Comma-separated list of collectors to use, for example: `--collectors.exchange.enabled=AvailabilityService,OutlookWebAccess`. Matching is case-sensetive. Depending on the exchange installation not all performance counters are available. Use `--collectors.exchange.list` to obtain a list of supported collectors.
|
||||||
|
|
||||||
## Metrics
|
## Metrics
|
||||||
Name | Description
|
Name | Description
|
||||||
--------------|---------------
|
--------------|---------------
|
||||||
|
|||||||
Reference in New Issue
Block a user