@@ -286,7 +286,18 @@ For further informations / bugs reports: https://github.com/ConSol-Monitoring/na
286286 switch <- signalChannel {
287287 case syscall .SIGINT , syscall .SIGTERM :
288288 log .Warn ("Got Interrupted" )
289- stoppables = append (stoppables , []Stoppable {livestatusCollector , livestatusCache , nagiosCollector , nagfluxCollector }... )
289+ if livestatusCollector != nil {
290+ stoppables = append (stoppables , livestatusCollector )
291+ }
292+ if livestatusCache != nil {
293+ stoppables = append (stoppables , livestatusCache )
294+ }
295+ if nagiosCollector != nil {
296+ stoppables = append (stoppables , nagiosCollector )
297+ }
298+ if nagfluxCollector != nil {
299+ stoppables = append (stoppables , nagfluxCollector )
300+ }
290301 cleanUp (stoppables , resultQueues )
291302 quit <- true
292303 return
@@ -317,9 +328,7 @@ func waitForDumpfileCollector(dump *nagflux.DumpfileCollector) {
317328func cleanUp (itemsToStop []Stoppable , resultQueues collector.ResultQueues ) {
318329 log .Info ("Cleaning up..." )
319330 for i := len (itemsToStop ) - 1 ; i >= 0 ; i -- {
320- if itemsToStop [i ] != nil {
321- itemsToStop [i ].Stop ()
322- }
331+ itemsToStop [i ].Stop ()
323332 }
324333 for _ , q := range resultQueues {
325334 log .Debugf ("Remaining queries %d" , len (q ))
@@ -329,13 +338,8 @@ func cleanUp(itemsToStop []Stoppable, resultQueues collector.ResultQueues) {
329338// Depending on the configuration, we might not have added any active watchers.
330339// Exit the program if that is the case
331340func checkActiveModuleCount (stoppables []Stoppable ) {
332- activeItemCount := 0
333- for _ , stoppable := range stoppables {
334- if stoppable != nil {
335- activeItemCount ++
336- }
337- }
341+ activeItemCount := len (stoppables )
338342 if activeItemCount == 0 {
339- log .Fatalf ("No active watcher/spooler/listeneder were constructed after processing the config file, enable at least an item." )
343+ log .Fatalf ("No active watcher/spooler/listener were constructed after processing the config file, enable at least an item." )
340344 }
341345}
0 commit comments