mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-25 06:06:35 +00:00
Merge pull request #1337 from jkroepke/remove-old-flags
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
package iis
|
package iis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -14,17 +13,12 @@ import (
|
|||||||
"github.com/go-kit/log/level"
|
"github.com/go-kit/log/level"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Name = "iis"
|
Name = "iis"
|
||||||
FlagIISSiteOldExclude = "collector.iis.site-blacklist"
|
|
||||||
FlagIISSiteOldInclude = "collector.iis.site-whitelist"
|
|
||||||
FlagIISAppOldExclude = "collector.iis.app-blacklist"
|
|
||||||
FlagIISAppOldInclude = "collector.iis.app-whitelist"
|
|
||||||
|
|
||||||
FlagIISSiteExclude = "collector.iis.site-exclude"
|
FlagIISSiteExclude = "collector.iis.site-exclude"
|
||||||
FlagIISSiteInclude = "collector.iis.site-include"
|
FlagIISSiteInclude = "collector.iis.site-include"
|
||||||
@@ -86,21 +80,11 @@ func getIISVersion(logger log.Logger) simple_version {
|
|||||||
type collector struct {
|
type collector struct {
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
oldSiteInclude *string
|
|
||||||
oldSiteExclude *string
|
|
||||||
oldAppInclude *string
|
|
||||||
oldAppExclude *string
|
|
||||||
|
|
||||||
siteInclude *string
|
siteInclude *string
|
||||||
siteExclude *string
|
siteExclude *string
|
||||||
appInclude *string
|
appInclude *string
|
||||||
appExclude *string
|
appExclude *string
|
||||||
|
|
||||||
siteIncludeSet bool
|
|
||||||
siteExcludeSet bool
|
|
||||||
appIncludeSet bool
|
|
||||||
appExcludeSet bool
|
|
||||||
|
|
||||||
// Web Service
|
// Web Service
|
||||||
CurrentAnonymousUsers *prometheus.Desc
|
CurrentAnonymousUsers *prometheus.Desc
|
||||||
CurrentBlockedAsyncIORequests *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 {
|
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||||
c := &collector{
|
c := &collector{
|
||||||
oldSiteInclude: app.Flag(FlagIISSiteOldInclude, "DEPRECATED: Use --collector.iis.site-include").Hidden().String(),
|
siteInclude: app.Flag(
|
||||||
oldSiteExclude: app.Flag(FlagIISSiteOldExclude, "DEPRECATED: Use --collector.iis.site-exclude").Hidden().String(),
|
FlagIISSiteInclude,
|
||||||
oldAppInclude: app.Flag(FlagIISAppOldInclude, "DEPRECATED: Use --collector.iis.app-include").Hidden().String(),
|
"Regexp of sites to include. Site name must both match include and not match exclude to be included.",
|
||||||
oldAppExclude: app.Flag(FlagIISAppOldExclude, "DEPRECATED: Use --collector.iis.app-exclude").Hidden().String(),
|
).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
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,40 +277,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) Build() 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)
|
c.iis_version = getIISVersion(c.logger)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
package logical_disk
|
package logical_disk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
@@ -12,14 +11,11 @@ import (
|
|||||||
"github.com/go-kit/log/level"
|
"github.com/go-kit/log/level"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Name = "logical_disk"
|
Name = "logical_disk"
|
||||||
FlagLogicalDiskVolumeOldExclude = "collector.logical_disk.volume-blacklist"
|
|
||||||
FlagLogicalDiskVolumeOldInclude = "collector.logical_disk.volume-whitelist"
|
|
||||||
|
|
||||||
FlagLogicalDiskVolumeExclude = "collector.logical_disk.volume-exclude"
|
FlagLogicalDiskVolumeExclude = "collector.logical_disk.volume-exclude"
|
||||||
FlagLogicalDiskVolumeInclude = "collector.logical_disk.volume-include"
|
FlagLogicalDiskVolumeInclude = "collector.logical_disk.volume-include"
|
||||||
@@ -39,15 +35,9 @@ var ConfigDefaults = Config{
|
|||||||
type collector struct {
|
type collector struct {
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
volumeOldInclude *string
|
|
||||||
volumeOldExclude *string
|
|
||||||
|
|
||||||
volumeInclude *string
|
volumeInclude *string
|
||||||
volumeExclude *string
|
volumeExclude *string
|
||||||
|
|
||||||
volumeIncludeSet bool
|
|
||||||
volumeExcludeSet bool
|
|
||||||
|
|
||||||
RequestsQueued *prometheus.Desc
|
RequestsQueued *prometheus.Desc
|
||||||
AvgReadQueue *prometheus.Desc
|
AvgReadQueue *prometheus.Desc
|
||||||
AvgWriteQueue *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 {
|
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||||
c := &collector{}
|
c := &collector{
|
||||||
|
volumeInclude: app.Flag(
|
||||||
c.volumeInclude = app.Flag(
|
FlagLogicalDiskVolumeInclude,
|
||||||
FlagLogicalDiskVolumeInclude,
|
"Regexp of volumes to include. Volume name must both match include and not match exclude to be included.",
|
||||||
"Regexp of volumes to include. Volume name must both match include and not match exclude to be included.",
|
).Default(ConfigDefaults.VolumeInclude).String(),
|
||||||
).Default(ConfigDefaults.VolumeInclude).PreAction(func(_ *kingpin.ParseContext) error {
|
volumeExclude: app.Flag(
|
||||||
c.volumeIncludeSet = true
|
FlagLogicalDiskVolumeExclude,
|
||||||
return nil
|
"Regexp of volumes to exclude. Volume name must both match include and not match exclude to be included.",
|
||||||
}).String()
|
).Default(ConfigDefaults.VolumeExclude).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()
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -126,23 +100,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) Build() 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(
|
c.RequestsQueued = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "requests_queued"),
|
prometheus.BuildFQName(types.Namespace, Name, "requests_queued"),
|
||||||
"The number of requests queued to the disk (LogicalDisk.CurrentDiskQueueLength)",
|
"The number of requests queued to the disk (LogicalDisk.CurrentDiskQueueLength)",
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
package net
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
@@ -12,16 +11,12 @@ import (
|
|||||||
"github.com/go-kit/log/level"
|
"github.com/go-kit/log/level"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Name = "net"
|
Name = "net"
|
||||||
|
|
||||||
FlagNicOldExclude = "collector.net.nic-blacklist"
|
|
||||||
FlagNicOldInclude = "collector.net.nic-whitelist"
|
|
||||||
|
|
||||||
FlagNicExclude = "collector.net.nic-exclude"
|
FlagNicExclude = "collector.net.nic-exclude"
|
||||||
FlagNicInclude = "collector.net.nic-include"
|
FlagNicInclude = "collector.net.nic-include"
|
||||||
)
|
)
|
||||||
@@ -42,15 +37,9 @@ var nicNameToUnderscore = regexp.MustCompile("[^a-zA-Z0-9]")
|
|||||||
type collector struct {
|
type collector struct {
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
nicOldInclude *string
|
|
||||||
nicOldExclude *string
|
|
||||||
|
|
||||||
nicInclude *string
|
nicInclude *string
|
||||||
nicExclude *string
|
nicExclude *string
|
||||||
|
|
||||||
nicIncludeSet bool
|
|
||||||
nicExcludeSet bool
|
|
||||||
|
|
||||||
BytesReceivedTotal *prometheus.Desc
|
BytesReceivedTotal *prometheus.Desc
|
||||||
BytesSentTotal *prometheus.Desc
|
BytesSentTotal *prometheus.Desc
|
||||||
BytesTotal *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 {
|
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(
|
nicExclude: app.Flag(
|
||||||
FlagNicInclude,
|
FlagNicExclude,
|
||||||
"Regexp of NIC:s to include. NIC name must both match include and not match exclude to be included.",
|
"Regexp of NIC:s to exclude. NIC name must both match include and not match exclude to be included.",
|
||||||
).Default(ConfigDefaults.NicInclude).PreAction(func(_ *kingpin.ParseContext) error {
|
).Default(ConfigDefaults.NicExclude).String(),
|
||||||
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()
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -126,22 +100,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) Build() 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(
|
c.BytesReceivedTotal = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "bytes_received_total"),
|
prometheus.BuildFQName(types.Namespace, Name, "bytes_received_total"),
|
||||||
"(Network.BytesReceivedPerSec)",
|
"(Network.BytesReceivedPerSec)",
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
package process
|
package process
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -20,10 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Name = "process"
|
Name = "process"
|
||||||
FlagProcessOldExclude = "collector.process.blacklist"
|
|
||||||
FlagProcessOldInclude = "collector.process.whitelist"
|
|
||||||
|
|
||||||
FlagProcessExclude = "collector.process.exclude"
|
FlagProcessExclude = "collector.process.exclude"
|
||||||
FlagProcessInclude = "collector.process.include"
|
FlagProcessInclude = "collector.process.include"
|
||||||
)
|
)
|
||||||
@@ -41,15 +37,9 @@ var ConfigDefaults = Config{
|
|||||||
type collector struct {
|
type collector struct {
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
processOldInclude *string
|
|
||||||
processOldExclude *string
|
|
||||||
|
|
||||||
processInclude *string
|
processInclude *string
|
||||||
processExclude *string
|
processExclude *string
|
||||||
|
|
||||||
processIncludeSet bool
|
|
||||||
processExcludeSet bool
|
|
||||||
|
|
||||||
enableWorkerProcess *bool
|
enableWorkerProcess *bool
|
||||||
|
|
||||||
StartTime *prometheus.Desc
|
StartTime *prometheus.Desc
|
||||||
@@ -86,38 +76,22 @@ func New(logger log.Logger, config *Config) types.Collector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewWithFlags(app *kingpin.Application) 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(
|
processExclude: app.Flag(
|
||||||
FlagProcessInclude,
|
FlagProcessExclude,
|
||||||
"Regexp of processes to include. Process name must both match include and not match exclude to be included.",
|
"Regexp of processes to exclude. Process name must both match include and not match exclude to be included.",
|
||||||
).Default(".*").PreAction(func(_ *kingpin.ParseContext) error {
|
).Default(ConfigDefaults.ProcessExclude).String(),
|
||||||
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()
|
|
||||||
|
|
||||||
|
enableWorkerProcess: kingpin.Flag(
|
||||||
|
"collector.process.iis",
|
||||||
|
"Enable IIS worker process name queries. May cause the collector to leak memory.",
|
||||||
|
).Default("false").Bool(),
|
||||||
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,23 +108,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) Build() 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) {
|
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!")
|
_ = 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
|
package scheduled_task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -15,14 +14,11 @@ import (
|
|||||||
"github.com/go-ole/go-ole"
|
"github.com/go-ole/go-ole"
|
||||||
"github.com/go-ole/go-ole/oleutil"
|
"github.com/go-ole/go-ole/oleutil"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Name = "scheduled_task"
|
Name = "scheduled_task"
|
||||||
FlagScheduledTaskOldExclude = "collector.scheduled_task.blacklist"
|
|
||||||
FlagScheduledTaskOldInclude = "collector.scheduled_task.whitelist"
|
|
||||||
|
|
||||||
FlagScheduledTaskExclude = "collector.scheduled_task.exclude"
|
FlagScheduledTaskExclude = "collector.scheduled_task.exclude"
|
||||||
FlagScheduledTaskInclude = "collector.scheduled_task.include"
|
FlagScheduledTaskInclude = "collector.scheduled_task.include"
|
||||||
@@ -41,15 +37,9 @@ var ConfigDefaults = Config{
|
|||||||
type collector struct {
|
type collector struct {
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
taskOldExclude *string
|
|
||||||
taskOldInclude *string
|
|
||||||
|
|
||||||
taskExclude *string
|
taskExclude *string
|
||||||
taskInclude *string
|
taskInclude *string
|
||||||
|
|
||||||
taskIncludeSet bool
|
|
||||||
taskExcludeSet bool
|
|
||||||
|
|
||||||
LastResult *prometheus.Desc
|
LastResult *prometheus.Desc
|
||||||
MissedRuns *prometheus.Desc
|
MissedRuns *prometheus.Desc
|
||||||
State *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 {
|
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(
|
taskExclude: app.Flag(
|
||||||
FlagScheduledTaskInclude,
|
FlagScheduledTaskExclude,
|
||||||
"Regexp of tasks to include. Task path must both match include and not match exclude to be included.",
|
"Regexp of tasks to exclude. Task path must both match include and not match exclude to be included.",
|
||||||
).Default(ConfigDefaults.TaskInclude).PreAction(func(_ *kingpin.ParseContext) error {
|
).Default(ConfigDefaults.TaskExclude).String(),
|
||||||
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()
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -142,23 +117,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) Build() 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()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
package smtp
|
package smtp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
@@ -12,14 +11,11 @@ import (
|
|||||||
"github.com/go-kit/log/level"
|
"github.com/go-kit/log/level"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Name = "smtp"
|
Name = "smtp"
|
||||||
FlagSmtpServerOldExclude = "collector.smtp.server-blacklist"
|
|
||||||
FlagSmtpServerOldInclude = "collector.smtp.server-whitelist"
|
|
||||||
|
|
||||||
FlagSmtpServerExclude = "collector.smtp.server-exclude"
|
FlagSmtpServerExclude = "collector.smtp.server-exclude"
|
||||||
FlagSmtpServerInclude = "collector.smtp.server-include"
|
FlagSmtpServerInclude = "collector.smtp.server-include"
|
||||||
@@ -38,15 +34,9 @@ var ConfigDefaults = Config{
|
|||||||
type collector struct {
|
type collector struct {
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
serverOldInclude *string
|
|
||||||
serverOldExclude *string
|
|
||||||
|
|
||||||
serverInclude *string
|
serverInclude *string
|
||||||
serverExclude *string
|
serverExclude *string
|
||||||
|
|
||||||
serverIncludeSet bool
|
|
||||||
serverExcludeSet bool
|
|
||||||
|
|
||||||
BadmailedMessagesBadPickupFileTotal *prometheus.Desc
|
BadmailedMessagesBadPickupFileTotal *prometheus.Desc
|
||||||
BadmailedMessagesGeneralFailureTotal *prometheus.Desc
|
BadmailedMessagesGeneralFailureTotal *prometheus.Desc
|
||||||
BadmailedMessagesHopCountExceededTotal *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 {
|
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(
|
serverExclude: app.Flag(
|
||||||
FlagSmtpServerInclude,
|
FlagSmtpServerExclude,
|
||||||
"Regexp of virtual servers to include. Server name must both match include and not match exclude to be included.",
|
"Regexp of virtual servers to exclude. Server name must both match include and not match exclude to be included.",
|
||||||
).Default(ConfigDefaults.ServerInclude).PreAction(func(_ *kingpin.ParseContext) error {
|
).Default(ConfigDefaults.ServerExclude).String(),
|
||||||
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()
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -153,23 +128,6 @@ func (c *collector) GetPerfCounter() ([]string, error) {
|
|||||||
func (c *collector) Build() 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.")
|
_ = 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(
|
c.BadmailedMessagesBadPickupFileTotal = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "badmailed_messages_bad_pickup_file_total"),
|
prometheus.BuildFQName(types.Namespace, Name, "badmailed_messages_bad_pickup_file_total"),
|
||||||
"Total number of malformed pickup messages sent to badmail",
|
"Total number of malformed pickup messages sent to badmail",
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
Name = "textfile"
|
Name = "textfile"
|
||||||
FlagTextFileDirectory = "collector.textfile.directory"
|
|
||||||
FlagTextFileDirectories = "collector.textfile.directories"
|
FlagTextFileDirectories = "collector.textfile.directories"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,7 +52,6 @@ var ConfigDefaults = Config{
|
|||||||
type collector struct {
|
type collector struct {
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
textFileDirectory *string
|
|
||||||
textFileDirectories *string
|
textFileDirectories *string
|
||||||
|
|
||||||
directories string
|
directories string
|
||||||
@@ -68,10 +66,8 @@ func New(logger log.Logger, config *Config) types.Collector {
|
|||||||
config = &ConfigDefaults
|
config = &ConfigDefaults
|
||||||
}
|
}
|
||||||
|
|
||||||
textFileDirectory := ""
|
|
||||||
c := &collector{
|
c := &collector{
|
||||||
textFileDirectories: &config.TextFileDirectories,
|
textFileDirectories: &config.TextFileDirectories,
|
||||||
textFileDirectory: &textFileDirectory,
|
|
||||||
}
|
}
|
||||||
c.SetLogger(logger)
|
c.SetLogger(logger)
|
||||||
return c
|
return c
|
||||||
@@ -79,10 +75,6 @@ func New(logger log.Logger, config *Config) types.Collector {
|
|||||||
|
|
||||||
func NewWithFlags(app *kingpin.Application) types.Collector {
|
func NewWithFlags(app *kingpin.Application) types.Collector {
|
||||||
return &collector{
|
return &collector{
|
||||||
textFileDirectory: app.Flag(
|
|
||||||
FlagTextFileDirectory,
|
|
||||||
"DEPRECATED: Use --collector.textfile.directories",
|
|
||||||
).Default("").Hidden().String(),
|
|
||||||
textFileDirectories: app.Flag(
|
textFileDirectories: app.Flag(
|
||||||
FlagTextFileDirectories,
|
FlagTextFileDirectories,
|
||||||
"Directory or Directories to read text files with metrics from.",
|
"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 {
|
func (c *collector) Build() error {
|
||||||
c.directories = ""
|
c.directories = ""
|
||||||
if utils.HasValue(c.textFileDirectory) || utils.HasValue(c.textFileDirectories) {
|
if utils.HasValue(c.textFileDirectories) {
|
||||||
c.directories = *c.textFileDirectory + "," + *c.textFileDirectories
|
c.directories = strings.Trim(*c.textFileDirectories, ",")
|
||||||
c.directories = strings.Trim(c.directories, ",")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = level.Info(c.logger).Log("msg", fmt.Sprintf("textfile collector directories: %s", c.directories))
|
_ = level.Info(c.logger).Log("msg", fmt.Sprintf("textfile collector directories: %s", c.directories))
|
||||||
|
|
||||||
c.MtimeDesc = prometheus.NewDesc(
|
c.MtimeDesc = prometheus.NewDesc(
|
||||||
|
|||||||
Reference in New Issue
Block a user