Skip to content

Commit

Permalink
*: don't exclude resources, if exclude option is empty.
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Oct 10, 2024
1 parent 72df515 commit bafe38c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions internal/collector/iis/iis.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.AppExclude == nil {
if config.AppExclude == nil || config.AppExclude.String() == "" {
config.AppExclude = ConfigDefaults.AppExclude
}

if config.AppInclude == nil {
config.AppInclude = ConfigDefaults.AppInclude
}

if config.SiteExclude == nil {
if config.SiteExclude == nil || config.SiteExclude.String() == "" {
config.SiteExclude = ConfigDefaults.SiteExclude
}

Expand All @@ -199,22 +199,22 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.iis.app-exclude",
"Regexp of apps to exclude. App name must both match include and not match exclude to be included.",
).Default(c.config.AppExclude.String()).StringVar(&appExclude)
).Default("").StringVar(&appExclude)

app.Flag(
"collector.iis.app-include",
"Regexp of apps to include. App name must both match include and not match exclude to be included.",
).Default(c.config.AppInclude.String()).StringVar(&appInclude)
).Default(".+").StringVar(&appInclude)

app.Flag(
"collector.iis.site-exclude",
"Regexp of sites to exclude. Site name must both match include and not match exclude to be included.",
).Default(c.config.SiteExclude.String()).StringVar(&siteExclude)
).Default("").StringVar(&siteExclude)

app.Flag(
"collector.iis.site-include",
"Regexp of sites to include. Site name must both match include and not match exclude to be included.",
).Default(c.config.SiteInclude.String()).StringVar(&siteInclude)
).Default(".+").StringVar(&siteInclude)

app.Action(func(*kingpin.ParseContext) error {
var err error
Expand Down
6 changes: 3 additions & 3 deletions internal/collector/logical_disk/logical_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.VolumeExclude == nil {
if config.VolumeExclude == nil || config.VolumeExclude.String() == "" {
config.VolumeExclude = ConfigDefaults.VolumeExclude
}

Expand All @@ -99,12 +99,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.logical_disk.volume-exclude",
"Regexp of volumes to exclude. Volume name must both match include and not match exclude to be included.",
).Default(c.config.VolumeExclude.String()).StringVar(&volumeExclude)
).Default("").StringVar(&volumeExclude)

app.Flag(
"collector.logical_disk.volume-include",
"Regexp of volumes to include. Volume name must both match include and not match exclude to be included.",
).Default(c.config.VolumeInclude.String()).StringVar(&volumeInclude)
).Default(".+").StringVar(&volumeInclude)

app.Action(func(*kingpin.ParseContext) error {
var err error
Expand Down
6 changes: 3 additions & 3 deletions internal/collector/net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.NicExclude == nil {
if config.NicExclude == nil || config.NicExclude.String() == "" {
config.NicExclude = ConfigDefaults.NicExclude
}

Expand Down Expand Up @@ -100,12 +100,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.net.nic-exclude",
"Regexp of NIC:s to exclude. NIC name must both match include and not match exclude to be included.",
).Default(c.config.NicExclude.String()).StringVar(&nicExclude)
).Default("").StringVar(&nicExclude)

app.Flag(
"collector.net.nic-include",
"Regexp of NIC:s to include. NIC name must both match include and not match exclude to be included.",
).Default(c.config.NicInclude.String()).StringVar(&nicInclude)
).Default(".+").StringVar(&nicInclude)

app.Flag(
"collector.net.enabled",
Expand Down
6 changes: 3 additions & 3 deletions internal/collector/physical_disk/physical_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.DiskExclude == nil {
if config.DiskExclude == nil || config.DiskExclude.String() == "" {
config.DiskExclude = ConfigDefaults.DiskExclude
}

Expand All @@ -76,12 +76,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.physical_disk.disk-exclude",
"Regexp of disks to exclude. Disk number must both match include and not match exclude to be included.",
).Default(c.config.DiskExclude.String()).StringVar(&diskExclude)
).Default("").StringVar(&diskExclude)

app.Flag(
"collector.physical_disk.disk-include",
"Regexp of disks to include. Disk number must both match include and not match exclude to be included.",
).Default(c.config.DiskInclude.String()).StringVar(&diskInclude)
).Default(".+").StringVar(&diskInclude)

app.Action(func(*kingpin.ParseContext) error {
var err error
Expand Down
6 changes: 3 additions & 3 deletions internal/collector/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.PrinterExclude == nil {
if config.PrinterExclude == nil || config.PrinterExclude.String() == "" {
config.PrinterExclude = ConfigDefaults.PrinterExclude
}

Expand All @@ -77,12 +77,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.printer.include",
"Regular expression to match printers to collect metrics for",
).Default(c.config.PrinterInclude.String()).StringVar(&printerInclude)
).Default(".+").StringVar(&printerInclude)

app.Flag(
"collector.printer.exclude",
"Regular expression to match printers to exclude",
).Default(c.config.PrinterExclude.String()).StringVar(&printerExclude)
).Default("").StringVar(&printerExclude)

app.Action(func(*kingpin.ParseContext) error {
var err error
Expand Down
6 changes: 3 additions & 3 deletions internal/collector/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.ProcessExclude == nil {
if config.ProcessExclude == nil || config.ProcessExclude.String() == "" {
config.ProcessExclude = ConfigDefaults.ProcessExclude
}

Expand All @@ -92,12 +92,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.process.exclude",
"Regexp of processes to exclude. Process name must both match include and not match exclude to be included.",
).Default(c.config.ProcessExclude.String()).StringVar(&processExclude)
).Default("").StringVar(&processExclude)

app.Flag(
"collector.process.include",
"Regexp of processes to include. Process name must both match include and not match exclude to be included.",
).Default(c.config.ProcessInclude.String()).StringVar(&processInclude)
).Default(".+").StringVar(&processInclude)

app.Flag(
"collector.process.iis",
Expand Down
6 changes: 3 additions & 3 deletions internal/collector/scheduled_task/scheduled_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.TaskExclude == nil {
if config.TaskExclude == nil || config.TaskExclude.String() == "" {
config.TaskExclude = ConfigDefaults.TaskExclude
}

Expand All @@ -106,12 +106,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.scheduled_task.exclude",
"Regexp of tasks to exclude. Task path must both match include and not match exclude to be included.",
).Default(c.config.TaskExclude.String()).StringVar(&taskExclude)
).Default("").StringVar(&taskExclude)

app.Flag(
"collector.scheduled_task.include",
"Regexp of tasks to include. Task path must both match include and not match exclude to be included.",
).Default(c.config.TaskInclude.String()).StringVar(&taskInclude)
).Default(".+").StringVar(&taskInclude)

app.Action(func(*kingpin.ParseContext) error {
var err error
Expand Down
6 changes: 3 additions & 3 deletions internal/collector/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.ServiceExclude == nil {
if config.ServiceExclude == nil || config.ServiceExclude.String() == "" {
config.ServiceExclude = ConfigDefaults.ServiceExclude
}

Expand All @@ -72,12 +72,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.service.exclude",
"Regexp of service to exclude. Service name (not the display name!) must both match include and not match exclude to be included.",
).Default(c.config.ServiceExclude.String()).StringVar(&serviceExclude)
).Default("").StringVar(&serviceExclude)

app.Flag(
"collector.service.include",
"Regexp of service to include. Process name (not the display name!) must both match include and not match exclude to be included.",
).Default(c.config.ServiceInclude.String()).StringVar(&serviceInclude)
).Default(".+").StringVar(&serviceInclude)

app.Action(func(*kingpin.ParseContext) error {
var err error
Expand Down
6 changes: 3 additions & 3 deletions internal/collector/smtp/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}

if config.ServerExclude == nil {
if config.ServerExclude == nil || config.ServerExclude.String() == "" {
config.ServerExclude = ConfigDefaults.ServerExclude
}

Expand All @@ -103,12 +103,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.smtp.server-exclude",
"Regexp of virtual servers to exclude. Server name must both match include and not match exclude to be included.",
).Default(c.config.ServerExclude.String()).StringVar(&serverExclude)
).Default("").StringVar(&serverExclude)

app.Flag(
"collector.smtp.server-include",
"Regexp of virtual servers to include. Server name must both match include and not match exclude to be included.",
).Default(c.config.ServerInclude.String()).StringVar(&serverInclude)
).Default(".+").StringVar(&serverInclude)

app.Action(func(*kingpin.ParseContext) error {
var err error
Expand Down

0 comments on commit bafe38c

Please sign in to comment.