mirror of
https://github.com/prometheus-community/windows_exporter
synced 2024-12-29 01:42:04 +00:00
Merge pull request #1337 from jkroepke/remove-old-flags
This commit is contained in:
commit
c6b6a239aa
@ -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