diff --git a/src/butler.js b/src/butler.js index 28f162c7..bd81529f 100644 --- a/src/butler.js +++ b/src/butler.js @@ -26,9 +26,7 @@ const start = async () => { // Load globals dynamically/async to ensure singleton pattern works const settingsObj = (await import('./globals.js')).default; const globals = await settingsObj.init(); - console.log(`globals initialised`); - console.log(`globals.initialised: ${globals.initialised}`); - globals.logger.verbose('MAIN: Globals initialised.'); + globals.logger.verbose(`START: Globals init done: ${globals.initialised}`); const setupServiceMonitorTimer = (await import('./lib/service_monitor.js')).default; diff --git a/src/globals.js b/src/globals.js index 3685d6a7..be5e4cec 100644 --- a/src/globals.js +++ b/src/globals.js @@ -446,7 +446,7 @@ class Settings { // Indicate that we have finished initialising this.initialised = true; - console.log('globals init done'); + this.logger.verbose('GLOBALS: Init done'); // eslint-disable-next-line no-constructor-return return instance; diff --git a/src/lib/service_monitor.js b/src/lib/service_monitor.js index de38ebe0..0b143c83 100644 --- a/src/lib/service_monitor.js +++ b/src/lib/service_monitor.js @@ -206,11 +206,7 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => { // Get details about this service const serviceDetails = await details(logger, service.name, host.host); - if ( - serviceStatus === 'STOPPED' && - config.has('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.stopped.enable') && - config.get('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.stopped.enable') === true - ) { + if (serviceStatus === 'STOPPED') { logger.warn(`Service "${serviceDetails.displayName}" on host "${host.host}" is stopped`); // Update state machine @@ -235,6 +231,8 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => { // New Relic if ( + config.has('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.stopped.enable') && + config.get('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.stopped.enable') === true && config.has('Butler.serviceMonitor.alertDestination.newRelic.enable') && config.get('Butler.serviceMonitor.alertDestination.newRelic.enable') === true ) { @@ -343,11 +341,7 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => { }); } } - } else if ( - serviceStatus === 'RUNNING' && - config.has('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.running.enable') && - config.get('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.running.enable') === true - ) { + } else if (serviceStatus === 'RUNNING') { logger.verbose(`Service "${service.name}" is running`); // Update state machine @@ -377,6 +371,8 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => { // New Relic if ( + config.has('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.running.enable') && + config.get('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.running.enable') === true && config.has('Butler.serviceMonitor.alertDestination.newRelic.enable') && config.get('Butler.serviceMonitor.alertDestination.newRelic.enable') === true ) {