chore: Remove registry based perfdata collector (#1742)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2024-11-17 21:51:12 +01:00
committed by GitHub
parent 6206b695c6
commit e6a15d4ec4
213 changed files with 8079 additions and 12405 deletions

View File

@@ -1,27 +1,21 @@
//go:build windows
package exchange
import (
"errors"
"fmt"
"log/slog"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
v1 "github.com/prometheus-community/windows_exporter/internal/perfdata/v1"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// Perflib: [24914] MSExchange Availability Service.
type perflibAvailabilityService struct {
RequestsSec float64 `perflib:"Availability Requests (sec)"`
}
func (c *Collector) buildAvailabilityService() error {
counters := []string{}
var err error
c.perfDataCollectorAvailabilityService, err = perfdata.NewCollector(perfdata.V2, "MSExchange Availability Service", perfdata.AllInstances, counters)
c.perfDataCollectorAvailabilityService, err = perfdata.NewCollector("MSExchange Availability Service", perfdata.InstanceAll, counters)
if err != nil {
return fmt.Errorf("failed to create MSExchange Availability Service collector: %w", err)
}
@@ -29,25 +23,7 @@ func (c *Collector) buildAvailabilityService() error {
return nil
}
func (c *Collector) collectAvailabilityService(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
var data []perflibAvailabilityService
if err := v1.UnmarshalObject(ctx.PerfObjects["MSExchange Availability Service"], &data, logger); err != nil {
return err
}
for _, availservice := range data {
ch <- prometheus.MustNewConstMetric(
c.availabilityRequestsSec,
prometheus.CounterValue,
availservice.RequestsSec,
)
}
return nil
}
func (c *Collector) collectPDHAvailabilityService(ch chan<- prometheus.Metric) error {
func (c *Collector) collectAvailabilityService(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorAvailabilityService.Collect()
if err != nil {
return fmt.Errorf("failed to collect MSExchange Availability Service metrics: %w", err)