mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 04:27:25 +01:00
Do not mess up with the orignal configuration
This commit is contained in:
parent
ce7eef8d30
commit
9840d0193d
@ -31,11 +31,9 @@ type RAPLCollector struct {
|
|||||||
// Exclude IDs for RAPL zones, e.g.
|
// Exclude IDs for RAPL zones, e.g.
|
||||||
// * 0 for zone 0
|
// * 0 for zone 0
|
||||||
// * 0:1 for zone 0 subzone 1
|
// * 0:1 for zone 0 subzone 1
|
||||||
ExcludeByID []string `json:"exclude_device_by_id,omitempty"`
|
ExcludeByID []string `json:"exclude_device_by_id,omitempty"`
|
||||||
isIDExcluded map[string]bool
|
|
||||||
// Exclude names for RAPL zones, e.g. psys, dram, core, uncore, package-0
|
// Exclude names for RAPL zones, e.g. psys, dram, core, uncore, package-0
|
||||||
ExcludeByName []string `json:"exclude_device_by_name,omitempty"`
|
ExcludeByName []string `json:"exclude_device_by_name,omitempty"`
|
||||||
isNameExcluded map[string]bool
|
|
||||||
}
|
}
|
||||||
RAPLZoneInfo []RAPLZoneInfo
|
RAPLZoneInfo []RAPLZoneInfo
|
||||||
meta map[string]string // default meta information
|
meta map[string]string // default meta information
|
||||||
@ -44,14 +42,6 @@ type RAPLCollector struct {
|
|||||||
// Init initializes the running average power limit (RAPL) collector
|
// Init initializes the running average power limit (RAPL) collector
|
||||||
func (m *RAPLCollector) Init(config json.RawMessage) error {
|
func (m *RAPLCollector) Init(config json.RawMessage) error {
|
||||||
|
|
||||||
// Release resources only needed in Init()
|
|
||||||
defer func() {
|
|
||||||
m.config.ExcludeByID = nil
|
|
||||||
m.config.isIDExcluded = nil
|
|
||||||
m.config.ExcludeByName = nil
|
|
||||||
m.config.isNameExcluded = nil
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Check if already initialized
|
// Check if already initialized
|
||||||
if m.init {
|
if m.init {
|
||||||
return nil
|
return nil
|
||||||
@ -77,16 +67,16 @@ func (m *RAPLCollector) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Configure excluded RAPL zones
|
// Configure excluded RAPL zones
|
||||||
m.config.isIDExcluded = make(map[string]bool)
|
isIDExcluded := make(map[string]bool)
|
||||||
if m.config.ExcludeByID != nil {
|
if m.config.ExcludeByID != nil {
|
||||||
for _, ID := range m.config.ExcludeByID {
|
for _, ID := range m.config.ExcludeByID {
|
||||||
m.config.isIDExcluded[ID] = true
|
isIDExcluded[ID] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.config.isNameExcluded = make(map[string]bool)
|
isNameExcluded := make(map[string]bool)
|
||||||
if m.config.ExcludeByName != nil {
|
if m.config.ExcludeByName != nil {
|
||||||
for _, name := range m.config.ExcludeByName {
|
for _, name := range m.config.ExcludeByName {
|
||||||
m.config.isNameExcluded[name] = true
|
isNameExcluded[name] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,8 +145,8 @@ func (m *RAPLCollector) Init(config json.RawMessage) error {
|
|||||||
zoneID := strings.TrimPrefix(zonePath, zonePrefix)
|
zoneID := strings.TrimPrefix(zonePath, zonePrefix)
|
||||||
z := readZoneInfo(zonePath)
|
z := readZoneInfo(zonePath)
|
||||||
if z.ok &&
|
if z.ok &&
|
||||||
!m.config.isIDExcluded[zoneID] &&
|
!isIDExcluded[zoneID] &&
|
||||||
!m.config.isNameExcluded[z.name] {
|
!isNameExcluded[z.name] {
|
||||||
|
|
||||||
// Add RAPL monitoring attributes for a zone
|
// Add RAPL monitoring attributes for a zone
|
||||||
m.RAPLZoneInfo =
|
m.RAPLZoneInfo =
|
||||||
@ -186,8 +176,8 @@ func (m *RAPLCollector) Init(config json.RawMessage) error {
|
|||||||
sz := readZoneInfo(subZonePath)
|
sz := readZoneInfo(subZonePath)
|
||||||
if len(zoneID) > 0 && len(z.name) > 0 &&
|
if len(zoneID) > 0 && len(z.name) > 0 &&
|
||||||
sz.ok &&
|
sz.ok &&
|
||||||
!m.config.isIDExcluded[zoneID+":"+subZoneID] &&
|
!isIDExcluded[zoneID+":"+subZoneID] &&
|
||||||
!m.config.isNameExcluded[sz.name] {
|
!isNameExcluded[sz.name] {
|
||||||
m.RAPLZoneInfo =
|
m.RAPLZoneInfo =
|
||||||
append(
|
append(
|
||||||
m.RAPLZoneInfo,
|
m.RAPLZoneInfo,
|
||||||
|
Loading…
Reference in New Issue
Block a user