mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-23 21:26:36 +00:00
22
pkg/perflib/utils.go
Normal file
22
pkg/perflib/utils.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user