mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 15:09:05 +01:00
Likwid receives signal at first Read, check when re-initializing
This commit is contained in:
parent
f1d3cabdc6
commit
83b4343310
@ -16,6 +16,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -54,6 +55,7 @@ type LikwidEventsetConfig struct {
|
|||||||
gid C.int
|
gid C.int
|
||||||
eorder []*C.char
|
eorder []*C.char
|
||||||
estr *C.char
|
estr *C.char
|
||||||
|
go_estr string
|
||||||
results map[int]map[string]interface{}
|
results map[int]map[string]interface{}
|
||||||
metrics map[int]map[string]float64
|
metrics map[int]map[string]float64
|
||||||
}
|
}
|
||||||
@ -101,8 +103,14 @@ func eventsToEventStr(events map[string]string) string {
|
|||||||
|
|
||||||
func genLikwidEventSet(input LikwidCollectorEventsetConfig) LikwidEventsetConfig {
|
func genLikwidEventSet(input LikwidCollectorEventsetConfig) LikwidEventsetConfig {
|
||||||
tmplist := make([]string, 0)
|
tmplist := make([]string, 0)
|
||||||
|
clist := make([]string, 0)
|
||||||
|
for k := range input.Events {
|
||||||
|
clist = append(clist, k)
|
||||||
|
}
|
||||||
|
sort.Strings(clist)
|
||||||
elist := make([]*C.char, 0)
|
elist := make([]*C.char, 0)
|
||||||
for k, v := range input.Events {
|
for _, k := range clist {
|
||||||
|
v := input.Events[k]
|
||||||
tmplist = append(tmplist, fmt.Sprintf("%s:%s", v, k))
|
tmplist = append(tmplist, fmt.Sprintf("%s:%s", v, k))
|
||||||
c_counter := C.CString(k)
|
c_counter := C.CString(k)
|
||||||
elist = append(elist, c_counter)
|
elist = append(elist, c_counter)
|
||||||
@ -124,6 +132,7 @@ func genLikwidEventSet(input LikwidCollectorEventsetConfig) LikwidEventsetConfig
|
|||||||
gid: -1,
|
gid: -1,
|
||||||
eorder: elist,
|
eorder: elist,
|
||||||
estr: C.CString(estr),
|
estr: C.CString(estr),
|
||||||
|
go_estr: estr,
|
||||||
results: res,
|
results: res,
|
||||||
metrics: met,
|
metrics: met,
|
||||||
}
|
}
|
||||||
@ -193,7 +202,7 @@ func (m *LikwidCollector) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
m.setup()
|
m.setup()
|
||||||
|
|
||||||
m.meta = map[string]string{"source": m.name, "group": "PerfCounter"}
|
m.meta = map[string]string{"group": "PerfCounter"}
|
||||||
cclog.ComponentDebug(m.name, "Get cpulist and init maps and lists")
|
cclog.ComponentDebug(m.name, "Get cpulist and init maps and lists")
|
||||||
cpulist := topo.CpuList()
|
cpulist := topo.CpuList()
|
||||||
m.cpulist = make([]C.int, len(cpulist))
|
m.cpulist = make([]C.int, len(cpulist))
|
||||||
@ -425,6 +434,9 @@ func (m *LikwidCollector) calcGlobalMetrics(interval time.Duration, output chan
|
|||||||
|
|
||||||
func (m *LikwidCollector) LateInit() error {
|
func (m *LikwidCollector) LateInit() error {
|
||||||
var ret C.int
|
var ret C.int
|
||||||
|
if m.initialized {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
switch m.config.AccessMode {
|
switch m.config.AccessMode {
|
||||||
case "direct":
|
case "direct":
|
||||||
C.HPMmode(0)
|
C.HPMmode(0)
|
||||||
@ -475,7 +487,17 @@ func (m *LikwidCollector) LateInit() error {
|
|||||||
for i, evset := range m.config.Eventsets {
|
for i, evset := range m.config.Eventsets {
|
||||||
var gid C.int
|
var gid C.int
|
||||||
if len(evset.Events) > 0 {
|
if len(evset.Events) > 0 {
|
||||||
|
skip := false
|
||||||
likwidGroup := genLikwidEventSet(evset)
|
likwidGroup := genLikwidEventSet(evset)
|
||||||
|
for _, g := range m.likwidGroups {
|
||||||
|
if likwidGroup.go_estr == g.go_estr {
|
||||||
|
skip = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if skip {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// Now we add the list of events to likwid
|
// Now we add the list of events to likwid
|
||||||
gid = C.perfmon_addEventSet(likwidGroup.estr)
|
gid = C.perfmon_addEventSet(likwidGroup.estr)
|
||||||
if gid >= 0 {
|
if gid >= 0 {
|
||||||
@ -520,9 +542,14 @@ func (m *LikwidCollector) Read(interval time.Duration, output chan lp.CCMetric)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !m.initialized {
|
if !m.initialized {
|
||||||
if m.LateInit() != nil {
|
m.lock.Lock()
|
||||||
|
err = m.LateInit()
|
||||||
|
if err != nil {
|
||||||
|
m.lock.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
m.initialized = true
|
||||||
|
m.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.initialized && !skip {
|
if m.initialized && !skip {
|
||||||
|
Loading…
Reference in New Issue
Block a user