Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions pkg/nagflux/nagflux.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,18 @@ For further informations / bugs reports: https://github.com/ConSol-Monitoring/na
switch <-signalChannel {
case syscall.SIGINT, syscall.SIGTERM:
log.Warn("Got Interrupted")
stoppables = append(stoppables, []Stoppable{livestatusCollector, livestatusCache, nagiosCollector, nagfluxCollector}...)
if livestatusCollector != nil {
stoppables = append(stoppables, livestatusCollector)
}
if livestatusCache != nil {
stoppables = append(stoppables, livestatusCache)
}
if nagiosCollector != nil {
stoppables = append(stoppables, nagiosCollector)
}
if nagfluxCollector != nil {
stoppables = append(stoppables, nagfluxCollector)
}
cleanUp(stoppables, resultQueues)
quit <- true
return
Expand Down Expand Up @@ -317,9 +328,7 @@ func waitForDumpfileCollector(dump *nagflux.DumpfileCollector) {
func cleanUp(itemsToStop []Stoppable, resultQueues collector.ResultQueues) {
log.Info("Cleaning up...")
for i := len(itemsToStop) - 1; i >= 0; i-- {
if itemsToStop[i] != nil {
itemsToStop[i].Stop()
}
itemsToStop[i].Stop()
}
for _, q := range resultQueues {
log.Debugf("Remaining queries %d", len(q))
Expand All @@ -329,13 +338,8 @@ func cleanUp(itemsToStop []Stoppable, resultQueues collector.ResultQueues) {
// Depending on the configuration, we might not have added any active watchers.
// Exit the program if that is the case
func checkActiveModuleCount(stoppables []Stoppable) {
activeItemCount := 0
for _, stoppable := range stoppables {
if stoppable != nil {
activeItemCount++
}
}
activeItemCount := len(stoppables)
if activeItemCount == 0 {
log.Fatalf("No active watcher/spooler/listeneder were constructed after processing the config file, enable at least an item.")
log.Fatalf("No active watcher/spooler/listener were constructed after processing the config file, enable at least an item.")
}
}