Refactor collectors

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2023-11-04 20:51:35 +01:00
parent 569f5450cd
commit 0711268d3c
207 changed files with 15220 additions and 13648 deletions

22
pkg/perflib/utils.go Normal file
View File

@@ -0,0 +1,22 @@
package perflib
import (
"strconv"
)
func MapCounterToIndex(name string) string {
return strconv.Itoa(int(CounterNameTable.LookupIndex(name)))
}
func GetPerflibSnapshot(objNames string) (map[string]*PerfObject, error) {
objects, err := QueryPerformanceData(objNames)
if err != nil {
return nil, err
}
indexed := make(map[string]*PerfObject)
for _, obj := range objects {
indexed[obj.Name] = obj
}
return indexed, nil
}