2023-11-04 19:51:35 +00:00
|
|
|
//go:build windows
|
|
|
|
|
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
2024-09-13 21:10:57 +00:00
|
|
|
"os"
|
2023-11-04 19:51:35 +00:00
|
|
|
"strings"
|
|
|
|
|
2024-10-03 18:23:56 +00:00
|
|
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
2023-11-04 19:51:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func ExpandEnabledCollectors(enabled string) []string {
|
2024-08-10 20:05:33 +00:00
|
|
|
expanded := strings.ReplaceAll(enabled, types.DefaultCollectorsPlaceholder, types.DefaultCollectors)
|
2023-11-04 19:51:35 +00:00
|
|
|
separated := strings.Split(expanded, ",")
|
|
|
|
unique := map[string]bool{}
|
2024-09-10 22:34:10 +00:00
|
|
|
|
2023-11-04 19:51:35 +00:00
|
|
|
for _, s := range separated {
|
|
|
|
if s != "" {
|
|
|
|
unique[s] = true
|
|
|
|
}
|
|
|
|
}
|
2024-09-10 22:34:10 +00:00
|
|
|
|
2023-11-04 19:51:35 +00:00
|
|
|
result := make([]string, 0, len(unique))
|
|
|
|
for s := range unique {
|
|
|
|
result = append(result, s)
|
|
|
|
}
|
2024-09-10 22:34:10 +00:00
|
|
|
|
2023-11-04 19:51:35 +00:00
|
|
|
return result
|
|
|
|
}
|
2024-09-13 21:10:57 +00:00
|
|
|
|
|
|
|
func PDHEnabled() bool {
|
|
|
|
if v, ok := os.LookupEnv("WINDOWS_EXPORTER_PERF_COUNTERS_ENGINE"); ok && v == "pdh" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|