diff --git a/internal/collector/iis/iis_w3svc_w3wp.go b/internal/collector/iis/iis_w3svc_w3wp.go index 6a33b23fa5..3fdfd04efa 100644 --- a/internal/collector/iis/iis_w3svc_w3wp.go +++ b/internal/collector/iis/iis_w3svc_w3wp.go @@ -432,8 +432,7 @@ func (c *Collector) collectW3SVCW3WP(ch chan<- prometheus.Metric) error { pid := workerProcessNameExtractor.ReplaceAllString(name, "$1") name := workerProcessNameExtractor.ReplaceAllString(name, "$2") - if name == "" || name == "_Total" || - c.config.AppExclude.MatchString(name) || + if name == "" || c.config.AppExclude.MatchString(name) || !c.config.AppInclude.MatchString(name) { continue } diff --git a/internal/collector/nps/nps.go b/internal/collector/nps/nps.go index 6b19e26c44..a7379dc1ec 100644 --- a/internal/collector/nps/nps.go +++ b/internal/collector/nps/nps.go @@ -298,7 +298,7 @@ func (c *Collector) collectAccept(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect NPS Authentication Server metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("perflib query for NPS Authentication Server returned empty result set") } @@ -390,7 +390,7 @@ func (c *Collector) collectAccounting(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect NPS Accounting Server metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("perflib query for NPS Accounting Server returned empty result set") } diff --git a/internal/collector/process/process.go b/internal/collector/process/process.go index 678845d08e..6835c4bf27 100644 --- a/internal/collector/process/process.go +++ b/internal/collector/process/process.go @@ -324,9 +324,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { // Duplicate processes are suffixed #, and an index number. Remove those. name, _, _ = strings.Cut(name, "#") - if name == "_Total" || - c.config.ProcessExclude.MatchString(name) || - !c.config.ProcessInclude.MatchString(name) { + if c.config.ProcessExclude.MatchString(name) || !c.config.ProcessInclude.MatchString(name) { continue } diff --git a/internal/collector/vmware/vmware.go b/internal/collector/vmware/vmware.go index 7fab38352b..31d4274d5a 100644 --- a/internal/collector/vmware/vmware.go +++ b/internal/collector/vmware/vmware.go @@ -337,7 +337,7 @@ func (c *Collector) collectCpu(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect VM Memory metrics: %w", err) } - data, ok := perfData["_Total"] + data, ok := perfData[perfdata.InstanceTotal] if !ok { return errors.New("query for VM CPU returned empty result set") } diff --git a/internal/perfdata/collector.go b/internal/perfdata/collector.go index a6f2128163..f71028bb45 100644 --- a/internal/perfdata/collector.go +++ b/internal/perfdata/collector.go @@ -50,7 +50,7 @@ func NewCollector(object string, instances []string, counters []string) (*Collec object: object, counters: make(map[string]Counter, len(counters)), handle: handle, - totalCounterRequested: slices.Contains(instances, "_Total"), + totalCounterRequested: slices.Contains(instances, InstanceTotal), mu: sync.RWMutex{}, } @@ -186,7 +186,7 @@ func (c *Collector) Collect() (map[string]map[string]CounterValues, error) { for _, item := range items { if item.RawValue.CStatus == PdhCstatusValidData || item.RawValue.CStatus == PdhCstatusNewData { instanceName := windows.UTF16PtrToString(item.SzName) - if strings.HasSuffix(instanceName, "_Total") && !c.totalCounterRequested { + if strings.HasSuffix(instanceName, InstanceTotal) && !c.totalCounterRequested { continue }