mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-05 01:56:35 +00:00
move global Name Tables
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -6,6 +6,14 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Initialize global name tables
|
||||||
|
// TODO: profiling, add option to disable name tables if necessary
|
||||||
|
// Not sure if we should resolve the names at all or just have the caller do it on demand
|
||||||
|
// (for many use cases the index is sufficient)
|
||||||
|
|
||||||
|
var CounterNameTable = *QueryNameTable("Counter 009")
|
||||||
|
var HelpNameTable = *QueryNameTable("Help 009")
|
||||||
|
|
||||||
func (p *perfObjectType) LookupName() string {
|
func (p *perfObjectType) LookupName() string {
|
||||||
return CounterNameTable.LookupString(p.ObjectNameTitleIndex)
|
return CounterNameTable.LookupString(p.ObjectNameTitleIndex)
|
||||||
}
|
}
|
||||||
@@ -27,7 +35,7 @@ func (t *NameTable) LookupIndex(str string) uint32 {
|
|||||||
return t.byString[str]
|
return t.byString[str]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query a perflib name table from the registry. Specify the type and the language
|
// QueryNameTable Query a perflib name table from the registry. Specify the type and the language
|
||||||
// code (i.e. "Counter 009" or "Help 009") for English language.
|
// code (i.e. "Counter 009" or "Help 009") for English language.
|
||||||
func QueryNameTable(tableName string) *NameTable {
|
func QueryNameTable(tableName string) *NameTable {
|
||||||
nameTable := new(NameTable)
|
nameTable := new(NameTable)
|
||||||
|
|||||||
@@ -123,9 +123,6 @@ import (
|
|||||||
// TODO: There's a LittleEndian field in the PERF header - we ought to check it
|
// TODO: There's a LittleEndian field in the PERF header - we ought to check it
|
||||||
var bo = binary.LittleEndian
|
var bo = binary.LittleEndian
|
||||||
|
|
||||||
var CounterNameTable NameTable
|
|
||||||
var HelpNameTable NameTable
|
|
||||||
|
|
||||||
const averageCount64Type = 1073874176
|
const averageCount64Type = 1073874176
|
||||||
|
|
||||||
// Top-level performance object (like "Process").
|
// Top-level performance object (like "Process").
|
||||||
@@ -263,16 +260,6 @@ func queryRawData(query string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
// Initialize global name tables
|
|
||||||
// TODO: profiling, add option to disable name tables if necessary
|
|
||||||
// Not sure if we should resolve the names at all or just have the caller do it on demand
|
|
||||||
// (for many use cases the index is sufficient)
|
|
||||||
|
|
||||||
CounterNameTable = *QueryNameTable("Counter 009")
|
|
||||||
HelpNameTable = *QueryNameTable("Help 009")
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Query all performance counters that match a given query.
|
Query all performance counters that match a given query.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user