mirror of
https://github.com/prometheus-community/windows_exporter
synced 2024-12-23 23:12:13 +00:00
Merge branch 'master' into feature/collector/smb
This commit is contained in:
commit
189ae539b5
20
.github/workflows/stale.yml
vendored
Normal file
20
.github/workflows/stale.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
name: 'Close stale issues and PRs'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 1 * * *'
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v8
|
||||
with:
|
||||
stale-issue-message: 'This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.'
|
||||
exempt-issue-labels: 'lifecycle/frozen'
|
||||
days-before-stale: 90
|
||||
days-before-close: 30
|
||||
enable-statistics: true
|
@ -122,7 +122,7 @@ msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,service --% EXTRA_FLAGS="--c
|
||||
|
||||
On some older versions of Windows you may need to surround parameter values with double quotes to get the install command parsing properly:
|
||||
```powershell
|
||||
msiexec /i C:\Users\Administrator\Downloads\windows_exporter.msi ENABLED_COLLECTORS="ad,iis,logon,memory,process,tcp,thermalzone" TEXTFILE_DIR="C:\custom_metrics\"
|
||||
msiexec /i C:\Users\Administrator\Downloads\windows_exporter.msi ENABLED_COLLECTORS="ad,iis,logon,memory,process,tcp,textfile,thermalzone" TEXTFILE_DIR="C:\custom_metrics\"
|
||||
```
|
||||
|
||||
Powershell versions 7.3 and above require [PSNativeCommandArgumentPassing](https://learn.microsoft.com/en-us/powershell/scripting/learn/experimental-features?view=powershell-7.3) to be set to `Legacy` when using `--% EXTRA_FLAGS`:
|
||||
|
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.21
|
||||
|
||||
require (
|
||||
github.com/Microsoft/hcsshim v0.11.4
|
||||
github.com/alecthomas/kingpin/v2 v2.3.2
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0
|
||||
github.com/dimchansky/utfbom v1.1.1
|
||||
github.com/go-kit/log v0.2.1
|
||||
github.com/go-ole/go-ole v1.3.0
|
||||
|
4
go.sum
4
go.sum
@ -4,8 +4,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
|
||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
|
||||
github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w=
|
||||
github.com/alecthomas/kingpin/v2 v2.3.2 h1:H0aULhgmSzN8xQ3nX1uxtdlTHYoPLu5AhHxWrKI6ocU=
|
||||
github.com/alecthomas/kingpin/v2 v2.3.2/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY=
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
|
@ -74,6 +74,7 @@ type collector struct {
|
||||
ConnectionCount *prometheus.Desc
|
||||
RPCOperationsPerSec *prometheus.Desc
|
||||
UserCount *prometheus.Desc
|
||||
ActiveUserCountMapiHttpEmsmdb *prometheus.Desc
|
||||
|
||||
enabledCollectors []string
|
||||
}
|
||||
@ -89,6 +90,7 @@ var exchangeAllCollectorNames = []string{
|
||||
"Autodiscover",
|
||||
"WorkloadManagement",
|
||||
"RpcClientAccess",
|
||||
"MapiHttpEmsmdb",
|
||||
}
|
||||
|
||||
func New(logger log.Logger, config *Config) types.Collector {
|
||||
@ -138,6 +140,7 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
"MSExchangeAutodiscover",
|
||||
"MSExchange WorkloadManagement Workloads",
|
||||
"MSExchange RpcClientAccess",
|
||||
"MSExchange MapiHttp Emsmdb",
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -189,6 +192,7 @@ func (c *collector) Build() error {
|
||||
c.MailboxServerProxyFailureRate = desc("http_proxy_mailbox_proxy_failure_rate", "% of failures between this CAS and MBX servers over the last 200 samples", "name")
|
||||
c.PingCommandsPending = desc("activesync_ping_cmds_pending", "Number of ping commands currently pending in the queue")
|
||||
c.SyncCommandsPerSec = desc("activesync_sync_cmds_total", "Number of sync commands processed per second. Clients use this command to synchronize items within a folder")
|
||||
c.ActiveUserCountMapiHttpEmsmdb = desc("mapihttp_emsmdb_active_user_count", "Number of unique outlook users that have shown some kind of activity in the last 2 minutes")
|
||||
|
||||
c.enabledCollectors = make([]string, 0, len(exchangeAllCollectorNames))
|
||||
|
||||
@ -202,6 +206,7 @@ func (c *collector) Build() error {
|
||||
"Autodiscover": "[29240] MSExchange Autodiscover",
|
||||
"WorkloadManagement": "[19430] MSExchange WorkloadManagement Workloads",
|
||||
"RpcClientAccess": "[29336] MSExchange RpcClientAccess",
|
||||
"MapiHttpEmsmdb": "[26463] MSExchange MapiHttp Emsmdb",
|
||||
}
|
||||
|
||||
if *c.exchangeListAllCollectors {
|
||||
@ -241,6 +246,7 @@ func (c *collector) Collect(ctx *types.ScrapeContext, ch chan<- prometheus.Metri
|
||||
"Autodiscover": c.collectAutoDiscover,
|
||||
"WorkloadManagement": c.collectWorkloadManagementWorkloads,
|
||||
"RpcClientAccess": c.collectRPC,
|
||||
"MapiHttpEmsmdb": c.collectMapiHttpEmsmdb,
|
||||
}
|
||||
|
||||
for _, collectorName := range c.enabledCollectors {
|
||||
@ -663,6 +669,28 @@ func (c *collector) collectAutoDiscover(ctx *types.ScrapeContext, ch chan<- prom
|
||||
return nil
|
||||
}
|
||||
|
||||
// perflib [26463] MSExchange MapiHttp Emsmdb
|
||||
type perflibMapiHttpEmsmdb struct {
|
||||
ActiveUserCount float64 `perflib:"Active User Count"`
|
||||
}
|
||||
|
||||
func (c *collector) collectMapiHttpEmsmdb(ctx *types.ScrapeContext, ch chan<- prometheus.Metric) error {
|
||||
var data []perflibMapiHttpEmsmdb
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange MapiHttp Emsmdb"], &data, c.logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, mapihttp := range data {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ActiveUserCountMapiHttpEmsmdb,
|
||||
prometheus.GaugeValue,
|
||||
mapihttp.ActiveUserCount,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// toLabelName converts strings to lowercase and replaces all whitespaces and dots with underscores
|
||||
func (c *collector) toLabelName(name string) string {
|
||||
s := strings.ReplaceAll(strings.Join(strings.Fields(strings.ToLower(name)), "_"), ".", "_")
|
||||
|
@ -3,7 +3,6 @@
|
||||
package iis
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
@ -14,17 +13,12 @@ import (
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
const (
|
||||
Name = "iis"
|
||||
FlagIISSiteOldExclude = "collector.iis.site-blacklist"
|
||||
FlagIISSiteOldInclude = "collector.iis.site-whitelist"
|
||||
FlagIISAppOldExclude = "collector.iis.app-blacklist"
|
||||
FlagIISAppOldInclude = "collector.iis.app-whitelist"
|
||||
Name = "iis"
|
||||
|
||||
FlagIISSiteExclude = "collector.iis.site-exclude"
|
||||
FlagIISSiteInclude = "collector.iis.site-include"
|
||||
@ -86,21 +80,11 @@ func getIISVersion(logger log.Logger) simple_version {
|
||||
type collector struct {
|
||||
logger log.Logger
|
||||
|
||||
oldSiteInclude *string
|
||||
oldSiteExclude *string
|
||||
oldAppInclude *string
|
||||
oldAppExclude *string
|
||||
|
||||
siteInclude *string
|
||||
siteExclude *string
|
||||
appInclude *string
|
||||
appExclude *string
|
||||
|
||||
siteIncludeSet bool
|
||||
siteExcludeSet bool
|
||||
appIncludeSet bool
|
||||
appExcludeSet bool
|
||||
|
||||
// Web Service
|
||||
CurrentAnonymousUsers *prometheus.Desc
|
||||
CurrentBlockedAsyncIORequests *prometheus.Desc
|
||||
@ -251,44 +235,27 @@ func New(logger log.Logger, config *Config) types.Collector {
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||
c := &collector{
|
||||
oldSiteInclude: app.Flag(FlagIISSiteOldInclude, "DEPRECATED: Use --collector.iis.site-include").Hidden().String(),
|
||||
oldSiteExclude: app.Flag(FlagIISSiteOldExclude, "DEPRECATED: Use --collector.iis.site-exclude").Hidden().String(),
|
||||
oldAppInclude: app.Flag(FlagIISAppOldInclude, "DEPRECATED: Use --collector.iis.app-include").Hidden().String(),
|
||||
oldAppExclude: app.Flag(FlagIISAppOldExclude, "DEPRECATED: Use --collector.iis.app-exclude").Hidden().String(),
|
||||
siteInclude: app.Flag(
|
||||
FlagIISSiteInclude,
|
||||
"Regexp of sites to include. Site name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.SiteInclude).String(),
|
||||
|
||||
siteExclude: app.Flag(
|
||||
FlagIISSiteExclude,
|
||||
"Regexp of sites to exclude. Site name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.SiteExclude).String(),
|
||||
|
||||
appInclude: app.Flag(
|
||||
FlagIISAppInclude,
|
||||
"Regexp of apps to include. App name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.AppInclude).String(),
|
||||
|
||||
appExclude: app.Flag(
|
||||
FlagIISAppExclude,
|
||||
"Regexp of apps to exclude. App name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.AppExclude).String(),
|
||||
}
|
||||
|
||||
c.siteInclude = app.Flag(
|
||||
FlagIISSiteInclude,
|
||||
"Regexp of sites to include. Site name must both match include and not match exclude to be included.",
|
||||
).Default(".+").PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.siteIncludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.siteExclude = app.Flag(
|
||||
FlagIISSiteExclude,
|
||||
"Regexp of sites to exclude. Site name must both match include and not match exclude to be included.",
|
||||
).Default("").PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.siteExcludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.appInclude = app.Flag(
|
||||
FlagIISAppInclude,
|
||||
"Regexp of apps to include. App name must both match include and not match exclude to be included.",
|
||||
).Default(".+").PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.appIncludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.appExclude = app.Flag(
|
||||
FlagIISAppExclude,
|
||||
"Regexp of apps to include. App name must both match include and not match exclude to be included.",
|
||||
).Default("").PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.siteExcludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
@ -310,40 +277,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
}
|
||||
|
||||
func (c *collector) Build() error {
|
||||
if utils.HasValue(c.oldSiteExclude) {
|
||||
if !c.siteExcludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.iis.site-blacklist is DEPRECATED and will be removed in a future release, use --collector.iis.site-exclude")
|
||||
*c.siteExclude = *c.oldSiteExclude
|
||||
} else {
|
||||
return errors.New("--collector.iis.site-blacklist and --collector.iis.site-exclude are mutually exclusive")
|
||||
}
|
||||
}
|
||||
if utils.HasValue(c.oldSiteInclude) {
|
||||
if !c.siteIncludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.iis.site-whitelist is DEPRECATED and will be removed in a future release, use --collector.iis.site-include")
|
||||
*c.siteInclude = *c.oldSiteInclude
|
||||
} else {
|
||||
return errors.New("--collector.iis.site-whitelist and --collector.iis.site-include are mutually exclusive")
|
||||
}
|
||||
}
|
||||
|
||||
if utils.HasValue(c.oldAppExclude) {
|
||||
if !c.appExcludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.iis.app-blacklist is DEPRECATED and will be removed in a future release, use --collector.iis.app-exclude")
|
||||
*c.appExclude = *c.oldAppExclude
|
||||
} else {
|
||||
return errors.New("--collector.iis.app-blacklist and --collector.iis.app-exclude are mutually exclusive")
|
||||
}
|
||||
}
|
||||
if utils.HasValue(c.oldAppInclude) {
|
||||
if !c.appIncludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.iis.app-whitelist is DEPRECATED and will be removed in a future release, use --collector.iis.app-include")
|
||||
*c.appInclude = *c.oldAppInclude
|
||||
} else {
|
||||
return errors.New("--collector.iis.app-whitelist and --collector.iis.app-include are mutually exclusive")
|
||||
}
|
||||
}
|
||||
|
||||
c.iis_version = getIISVersion(c.logger)
|
||||
|
||||
var err error
|
||||
|
@ -3,7 +3,6 @@
|
||||
package logical_disk
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
@ -12,14 +11,11 @@ import (
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
Name = "logical_disk"
|
||||
FlagLogicalDiskVolumeOldExclude = "collector.logical_disk.volume-blacklist"
|
||||
FlagLogicalDiskVolumeOldInclude = "collector.logical_disk.volume-whitelist"
|
||||
Name = "logical_disk"
|
||||
|
||||
FlagLogicalDiskVolumeExclude = "collector.logical_disk.volume-exclude"
|
||||
FlagLogicalDiskVolumeInclude = "collector.logical_disk.volume-include"
|
||||
@ -39,15 +35,9 @@ var ConfigDefaults = Config{
|
||||
type collector struct {
|
||||
logger log.Logger
|
||||
|
||||
volumeOldInclude *string
|
||||
volumeOldExclude *string
|
||||
|
||||
volumeInclude *string
|
||||
volumeExclude *string
|
||||
|
||||
volumeIncludeSet bool
|
||||
volumeExcludeSet bool
|
||||
|
||||
RequestsQueued *prometheus.Desc
|
||||
AvgReadQueue *prometheus.Desc
|
||||
AvgWriteQueue *prometheus.Desc
|
||||
@ -83,32 +73,16 @@ func New(logger log.Logger, config *Config) types.Collector {
|
||||
}
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||
c := &collector{}
|
||||
|
||||
c.volumeInclude = app.Flag(
|
||||
FlagLogicalDiskVolumeInclude,
|
||||
"Regexp of volumes to include. Volume name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.VolumeInclude).PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.volumeIncludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.volumeExclude = app.Flag(
|
||||
FlagLogicalDiskVolumeExclude,
|
||||
"Regexp of volumes to exclude. Volume name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.VolumeExclude).PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.volumeExcludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.volumeOldInclude = app.Flag(
|
||||
FlagLogicalDiskVolumeOldInclude,
|
||||
"DEPRECATED: Use --collector.logical_disk.volume-include",
|
||||
).Hidden().String()
|
||||
c.volumeOldExclude = app.Flag(
|
||||
FlagLogicalDiskVolumeOldExclude,
|
||||
"DEPRECATED: Use --collector.logical_disk.volume-exclude",
|
||||
).Hidden().String()
|
||||
c := &collector{
|
||||
volumeInclude: app.Flag(
|
||||
FlagLogicalDiskVolumeInclude,
|
||||
"Regexp of volumes to include. Volume name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.VolumeInclude).String(),
|
||||
volumeExclude: app.Flag(
|
||||
FlagLogicalDiskVolumeExclude,
|
||||
"Regexp of volumes to exclude. Volume name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.VolumeExclude).String(),
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
@ -126,23 +100,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
}
|
||||
|
||||
func (c *collector) Build() error {
|
||||
if utils.HasValue(c.volumeOldExclude) {
|
||||
if !c.volumeExcludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.logical_disk.volume-blacklist is DEPRECATED and will be removed in a future release, use --collector.logical_disk.volume-exclude")
|
||||
*c.volumeExclude = *c.volumeOldExclude
|
||||
} else {
|
||||
return errors.New("--collector.logical_disk.volume-blacklist and --collector.logical_disk.volume-exclude are mutually exclusive")
|
||||
}
|
||||
}
|
||||
if utils.HasValue(c.volumeOldInclude) {
|
||||
if !c.volumeIncludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.logical_disk.volume-whitelist is DEPRECATED and will be removed in a future release, use --collector.logical_disk.volume-include")
|
||||
*c.volumeInclude = *c.volumeOldInclude
|
||||
} else {
|
||||
return errors.New("--collector.logical_disk.volume-whitelist and --collector.logical_disk.volume-include are mutually exclusive")
|
||||
}
|
||||
}
|
||||
|
||||
c.RequestsQueued = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "requests_queued"),
|
||||
"The number of requests queued to the disk (LogicalDisk.CurrentDiskQueueLength)",
|
||||
|
@ -3,7 +3,6 @@
|
||||
package net
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
@ -12,16 +11,12 @@ import (
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
Name = "net"
|
||||
|
||||
FlagNicOldExclude = "collector.net.nic-blacklist"
|
||||
FlagNicOldInclude = "collector.net.nic-whitelist"
|
||||
|
||||
FlagNicExclude = "collector.net.nic-exclude"
|
||||
FlagNicInclude = "collector.net.nic-include"
|
||||
)
|
||||
@ -42,15 +37,9 @@ var nicNameToUnderscore = regexp.MustCompile("[^a-zA-Z0-9]")
|
||||
type collector struct {
|
||||
logger log.Logger
|
||||
|
||||
nicOldInclude *string
|
||||
nicOldExclude *string
|
||||
|
||||
nicInclude *string
|
||||
nicExclude *string
|
||||
|
||||
nicIncludeSet bool
|
||||
nicExcludeSet bool
|
||||
|
||||
BytesReceivedTotal *prometheus.Desc
|
||||
BytesSentTotal *prometheus.Desc
|
||||
BytesTotal *prometheus.Desc
|
||||
@ -83,32 +72,17 @@ func New(logger log.Logger, config *Config) types.Collector {
|
||||
}
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||
c := &collector{}
|
||||
c := &collector{
|
||||
nicInclude: app.Flag(
|
||||
FlagNicInclude,
|
||||
"Regexp of NIC:s to include. NIC name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.NicInclude).String(),
|
||||
|
||||
c.nicInclude = app.Flag(
|
||||
FlagNicInclude,
|
||||
"Regexp of NIC:s to include. NIC name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.NicInclude).PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.nicIncludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.nicExclude = app.Flag(
|
||||
FlagNicExclude,
|
||||
"Regexp of NIC:s to exclude. NIC name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.NicExclude).PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.nicExcludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.nicOldInclude = app.Flag(
|
||||
FlagNicOldInclude,
|
||||
"DEPRECATED: Use --collector.net.nic-include",
|
||||
).Hidden().String()
|
||||
c.nicOldExclude = app.Flag(
|
||||
FlagNicOldExclude,
|
||||
"DEPRECATED: Use --collector.net.nic-exclude",
|
||||
).Hidden().String()
|
||||
nicExclude: app.Flag(
|
||||
FlagNicExclude,
|
||||
"Regexp of NIC:s to exclude. NIC name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.NicExclude).String(),
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
@ -126,22 +100,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
}
|
||||
|
||||
func (c *collector) Build() error {
|
||||
if utils.HasValue(c.nicOldExclude) {
|
||||
if !c.nicExcludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.net.nic-blacklist is DEPRECATED and will be removed in a future release, use --collector.net.nic-exclude")
|
||||
*c.nicExclude = *c.nicOldExclude
|
||||
} else {
|
||||
return errors.New("--collector.net.nic-blacklist and --collector.net.nic-exclude are mutually exclusive")
|
||||
}
|
||||
}
|
||||
if utils.HasValue(c.nicOldInclude) {
|
||||
if !c.nicIncludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.net.nic-whitelist is DEPRECATED and will be removed in a future release, use --collector.net.nic-include")
|
||||
*c.nicInclude = *c.nicOldInclude
|
||||
} else {
|
||||
return errors.New("--collector.net.nic-whitelist and --collector.net.nic-include are mutually exclusive")
|
||||
}
|
||||
}
|
||||
c.BytesReceivedTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "bytes_received_total"),
|
||||
"(Network.BytesReceivedPerSec)",
|
||||
|
@ -3,7 +3,6 @@
|
||||
package process
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@ -20,10 +19,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
Name = "process"
|
||||
FlagProcessOldExclude = "collector.process.blacklist"
|
||||
FlagProcessOldInclude = "collector.process.whitelist"
|
||||
|
||||
Name = "process"
|
||||
FlagProcessExclude = "collector.process.exclude"
|
||||
FlagProcessInclude = "collector.process.include"
|
||||
)
|
||||
@ -41,15 +37,9 @@ var ConfigDefaults = Config{
|
||||
type collector struct {
|
||||
logger log.Logger
|
||||
|
||||
processOldInclude *string
|
||||
processOldExclude *string
|
||||
|
||||
processInclude *string
|
||||
processExclude *string
|
||||
|
||||
processIncludeSet bool
|
||||
processExcludeSet bool
|
||||
|
||||
enableWorkerProcess *bool
|
||||
|
||||
StartTime *prometheus.Desc
|
||||
@ -86,38 +76,22 @@ func New(logger log.Logger, config *Config) types.Collector {
|
||||
}
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||
c := &collector{}
|
||||
c := &collector{
|
||||
processInclude: app.Flag(
|
||||
FlagProcessInclude,
|
||||
"Regexp of processes to include. Process name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.ProcessInclude).String(),
|
||||
|
||||
c.processInclude = app.Flag(
|
||||
FlagProcessInclude,
|
||||
"Regexp of processes to include. Process name must both match include and not match exclude to be included.",
|
||||
).Default(".*").PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.processIncludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.processExclude = app.Flag(
|
||||
FlagProcessExclude,
|
||||
"Regexp of processes to exclude. Process name must both match include and not match exclude to be included.",
|
||||
).Default("").PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.processExcludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.enableWorkerProcess = kingpin.Flag(
|
||||
"collector.process.iis",
|
||||
"Enable IIS worker process name queries. May cause the collector to leak memory.",
|
||||
).Default("false").Bool()
|
||||
|
||||
c.processOldInclude = app.Flag(
|
||||
FlagProcessOldInclude,
|
||||
"DEPRECATED: Use --collector.process.include",
|
||||
).Hidden().String()
|
||||
c.processOldExclude = app.Flag(
|
||||
FlagProcessOldExclude,
|
||||
"DEPRECATED: Use --collector.process.exclude",
|
||||
).Hidden().String()
|
||||
processExclude: app.Flag(
|
||||
FlagProcessExclude,
|
||||
"Regexp of processes to exclude. Process name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.ProcessExclude).String(),
|
||||
|
||||
enableWorkerProcess: kingpin.Flag(
|
||||
"collector.process.iis",
|
||||
"Enable IIS worker process name queries. May cause the collector to leak memory.",
|
||||
).Default("false").Bool(),
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
@ -134,23 +108,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
}
|
||||
|
||||
func (c *collector) Build() error {
|
||||
if utils.HasValue(c.processOldExclude) {
|
||||
if !c.processExcludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.process.blacklist is DEPRECATED and will be removed in a future release, use --collector.process.exclude")
|
||||
*c.processExclude = *c.processOldExclude
|
||||
} else {
|
||||
return errors.New("--collector.process.blacklist and --collector.process.exclude are mutually exclusive")
|
||||
}
|
||||
}
|
||||
if utils.HasValue(c.processOldInclude) {
|
||||
if !c.processIncludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.process.whitelist is DEPRECATED and will be removed in a future release, use --collector.process.include")
|
||||
*c.processInclude = *c.processOldInclude
|
||||
} else {
|
||||
return errors.New("--collector.process.whitelist and --collector.process.include are mutually exclusive")
|
||||
}
|
||||
}
|
||||
|
||||
if c.processInclude != nil && *c.processInclude == ".*" && utils.IsEmpty(c.processExclude) {
|
||||
_ = level.Warn(c.logger).Log("msg", "No filters specified for process collector. This will generate a very large number of metrics!")
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
package scheduled_task
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"runtime"
|
||||
@ -15,14 +14,11 @@ import (
|
||||
"github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
Name = "scheduled_task"
|
||||
FlagScheduledTaskOldExclude = "collector.scheduled_task.blacklist"
|
||||
FlagScheduledTaskOldInclude = "collector.scheduled_task.whitelist"
|
||||
Name = "scheduled_task"
|
||||
|
||||
FlagScheduledTaskExclude = "collector.scheduled_task.exclude"
|
||||
FlagScheduledTaskInclude = "collector.scheduled_task.include"
|
||||
@ -41,15 +37,9 @@ var ConfigDefaults = Config{
|
||||
type collector struct {
|
||||
logger log.Logger
|
||||
|
||||
taskOldExclude *string
|
||||
taskOldInclude *string
|
||||
|
||||
taskExclude *string
|
||||
taskInclude *string
|
||||
|
||||
taskIncludeSet bool
|
||||
taskExcludeSet bool
|
||||
|
||||
LastResult *prometheus.Desc
|
||||
MissedRuns *prometheus.Desc
|
||||
State *prometheus.Desc
|
||||
@ -99,32 +89,17 @@ func New(logger log.Logger, config *Config) types.Collector {
|
||||
}
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||
c := &collector{}
|
||||
c := &collector{
|
||||
taskInclude: app.Flag(
|
||||
FlagScheduledTaskInclude,
|
||||
"Regexp of tasks to include. Task path must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.TaskInclude).String(),
|
||||
|
||||
c.taskInclude = app.Flag(
|
||||
FlagScheduledTaskInclude,
|
||||
"Regexp of tasks to include. Task path must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.TaskInclude).PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.taskIncludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.taskExclude = app.Flag(
|
||||
FlagScheduledTaskExclude,
|
||||
"Regexp of tasks to exclude. Task path must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.TaskExclude).PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.taskExcludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.taskOldInclude = app.Flag(
|
||||
FlagScheduledTaskOldInclude,
|
||||
"DEPRECATED: Use --collector.scheduled_task.include",
|
||||
).Hidden().String()
|
||||
c.taskOldExclude = app.Flag(
|
||||
FlagScheduledTaskOldExclude,
|
||||
"DEPRECATED: Use --collector.scheduled_task.exclude",
|
||||
).Hidden().String()
|
||||
taskExclude: app.Flag(
|
||||
FlagScheduledTaskExclude,
|
||||
"Regexp of tasks to exclude. Task path must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.TaskExclude).String(),
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
@ -142,23 +117,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
}
|
||||
|
||||
func (c *collector) Build() error {
|
||||
if utils.HasValue(c.taskOldExclude) {
|
||||
if !c.taskExcludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.scheduled_task.blacklist is DEPRECATED and will be removed in a future release, use --collector.scheduled_task.exclude")
|
||||
*c.taskExclude = *c.taskOldExclude
|
||||
} else {
|
||||
return errors.New("--collector.scheduled_task.blacklist and --collector.scheduled_task.exclude are mutually exclusive")
|
||||
}
|
||||
}
|
||||
if utils.HasValue(c.taskOldInclude) {
|
||||
if !c.taskIncludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.scheduled_task.whitelist is DEPRECATED and will be removed in a future release, use --collector.scheduled_task.include")
|
||||
*c.taskInclude = *c.taskOldInclude
|
||||
} else {
|
||||
return errors.New("--collector.scheduled_task.whitelist and --collector.scheduled_task.include are mutually exclusive")
|
||||
}
|
||||
}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
package smtp
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
@ -12,14 +11,11 @@ import (
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
Name = "smtp"
|
||||
FlagSmtpServerOldExclude = "collector.smtp.server-blacklist"
|
||||
FlagSmtpServerOldInclude = "collector.smtp.server-whitelist"
|
||||
Name = "smtp"
|
||||
|
||||
FlagSmtpServerExclude = "collector.smtp.server-exclude"
|
||||
FlagSmtpServerInclude = "collector.smtp.server-include"
|
||||
@ -38,15 +34,9 @@ var ConfigDefaults = Config{
|
||||
type collector struct {
|
||||
logger log.Logger
|
||||
|
||||
serverOldInclude *string
|
||||
serverOldExclude *string
|
||||
|
||||
serverInclude *string
|
||||
serverExclude *string
|
||||
|
||||
serverIncludeSet bool
|
||||
serverExcludeSet bool
|
||||
|
||||
BadmailedMessagesBadPickupFileTotal *prometheus.Desc
|
||||
BadmailedMessagesGeneralFailureTotal *prometheus.Desc
|
||||
BadmailedMessagesHopCountExceededTotal *prometheus.Desc
|
||||
@ -108,32 +98,17 @@ func New(logger log.Logger, config *Config) types.Collector {
|
||||
}
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||
c := &collector{}
|
||||
c := &collector{
|
||||
serverInclude: app.Flag(
|
||||
FlagSmtpServerInclude,
|
||||
"Regexp of virtual servers to include. Server name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.ServerInclude).String(),
|
||||
|
||||
c.serverInclude = app.Flag(
|
||||
FlagSmtpServerInclude,
|
||||
"Regexp of virtual servers to include. Server name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.ServerInclude).PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.serverIncludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.serverExclude = app.Flag(
|
||||
FlagSmtpServerExclude,
|
||||
"Regexp of virtual servers to exclude. Server name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.ServerExclude).PreAction(func(_ *kingpin.ParseContext) error {
|
||||
c.serverExcludeSet = true
|
||||
return nil
|
||||
}).String()
|
||||
|
||||
c.serverOldInclude = app.Flag(
|
||||
FlagSmtpServerOldInclude,
|
||||
"DEPRECATED: Use --collector.smtp.server-include",
|
||||
).Hidden().String()
|
||||
c.serverOldExclude = app.Flag(
|
||||
FlagSmtpServerOldExclude,
|
||||
"DEPRECATED: Use --collector.smtp.server-exclude",
|
||||
).Hidden().String()
|
||||
serverExclude: app.Flag(
|
||||
FlagSmtpServerExclude,
|
||||
"Regexp of virtual servers to exclude. Server name must both match include and not match exclude to be included.",
|
||||
).Default(ConfigDefaults.ServerExclude).String(),
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
@ -153,23 +128,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
func (c *collector) Build() error {
|
||||
_ = level.Info(c.logger).Log("msg", "smtp collector is in an experimental state! Metrics for this collector have not been tested.")
|
||||
|
||||
if utils.HasValue(c.serverOldExclude) {
|
||||
if !c.serverExcludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.smtp.server-blacklist is DEPRECATED and will be removed in a future release, use --collector.smtp.server-exclude")
|
||||
*c.serverExclude = *c.serverOldExclude
|
||||
} else {
|
||||
return errors.New("--collector.smtp.server-blacklist and --collector.smtp.server-exclude are mutually exclusive")
|
||||
}
|
||||
}
|
||||
if utils.HasValue(c.serverOldInclude) {
|
||||
if !c.serverIncludeSet {
|
||||
_ = level.Warn(c.logger).Log("msg", "--collector.smtp.server-whitelist is DEPRECATED and will be removed in a future release, use --collector.smtp.server-include")
|
||||
*c.serverInclude = *c.serverOldInclude
|
||||
} else {
|
||||
return errors.New("--collector.smtp.server-whitelist and --collector.smtp.server-include are mutually exclusive")
|
||||
}
|
||||
}
|
||||
|
||||
c.BadmailedMessagesBadPickupFileTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "badmailed_messages_bad_pickup_file_total"),
|
||||
"Total number of malformed pickup messages sent to badmail",
|
||||
|
@ -38,7 +38,6 @@ import (
|
||||
|
||||
const (
|
||||
Name = "textfile"
|
||||
FlagTextFileDirectory = "collector.textfile.directory"
|
||||
FlagTextFileDirectories = "collector.textfile.directories"
|
||||
)
|
||||
|
||||
@ -53,7 +52,6 @@ var ConfigDefaults = Config{
|
||||
type collector struct {
|
||||
logger log.Logger
|
||||
|
||||
textFileDirectory *string
|
||||
textFileDirectories *string
|
||||
|
||||
directories string
|
||||
@ -68,10 +66,8 @@ func New(logger log.Logger, config *Config) types.Collector {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
textFileDirectory := ""
|
||||
c := &collector{
|
||||
textFileDirectories: &config.TextFileDirectories,
|
||||
textFileDirectory: &textFileDirectory,
|
||||
}
|
||||
c.SetLogger(logger)
|
||||
return c
|
||||
@ -79,10 +75,6 @@ func New(logger log.Logger, config *Config) types.Collector {
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||
return &collector{
|
||||
textFileDirectory: app.Flag(
|
||||
FlagTextFileDirectory,
|
||||
"DEPRECATED: Use --collector.textfile.directories",
|
||||
).Default("").Hidden().String(),
|
||||
textFileDirectories: app.Flag(
|
||||
FlagTextFileDirectories,
|
||||
"Directory or Directories to read text files with metrics from.",
|
||||
@ -104,10 +96,10 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
|
||||
func (c *collector) Build() error {
|
||||
c.directories = ""
|
||||
if utils.HasValue(c.textFileDirectory) || utils.HasValue(c.textFileDirectories) {
|
||||
c.directories = *c.textFileDirectory + "," + *c.textFileDirectories
|
||||
c.directories = strings.Trim(c.directories, ",")
|
||||
if utils.HasValue(c.textFileDirectories) {
|
||||
c.directories = strings.Trim(*c.textFileDirectories, ",")
|
||||
}
|
||||
|
||||
_ = level.Info(c.logger).Log("msg", fmt.Sprintf("textfile collector directories: %s", c.directories))
|
||||
|
||||
c.MtimeDesc = prometheus.NewDesc(
|
||||
|
Loading…
Reference in New Issue
Block a user