Skip to content

Commit

Permalink
Removed syslogMetrics sync.Map{} leftover (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
pstrobl96 authored Mar 16, 2024
1 parent 2c2384a commit c70a0f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion syslog/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (collector *Collector) Collect(ch chan<- prometheus.Metric) {

mutex.RLock()

for mac, v := range syslogMetricsNew {
for mac, v := range syslogMetrics {
log.Trace().Msgf("Loading data for %s", mac)

ip := strings.Split(v["ip"]["value"], ":")[0]
Expand Down
7 changes: 3 additions & 4 deletions syslog/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ type patterns struct {

var (
// syslogMetrics is a map of mac addresses and their metrics
syslogMetrics = sync.Map{}

mutex sync.RWMutex

syslogMetricsNew = map[string]map[string]map[string]string{} // mac -> metric -> field -> value ; field can be value or label
syslogMetrics = map[string]map[string]map[string]string{} // mac -> metric -> field -> value ; field can be value or label

// regexpPatterns is a map that stores the regular expression patterns for different types of log messages.
// Each pattern is associated with a set of named capture groups and corresponding field names.
Expand Down Expand Up @@ -88,7 +87,7 @@ func HandleMetrics(listenUDP string) {
continue
} else {
mutex.Lock()
loadedPart := syslogMetricsNew[mac]
loadedPart := syslogMetrics[mac]

if loadedPart == nil {
loadedPart = make(map[string]map[string]string) // if found but empty, create a new map, at start it will be empty everytime
Expand Down Expand Up @@ -159,7 +158,7 @@ func HandleMetrics(listenUDP string) {
}
}

syslogMetricsNew[mac] = loadedPart
syslogMetrics[mac] = loadedPart

mutex.Unlock()
}
Expand Down

0 comments on commit c70a0f7

Please sign in to comment.