Skip to content

Commit

Permalink
fix(winsvc-monitor): Making verbose logging less spammy
Browse files Browse the repository at this point in the history
Fixes #1234
  • Loading branch information
Göran Sander committed Oct 3, 2024
1 parent 6babb0f commit f8981b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/lib/qseow/service_monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,14 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => {
const hostsToCheck = config.get('Butler.serviceMonitor.monitor');

hostsToCheck.forEach(async (host) => {
logger.verbose(`Checking status of Windows services on host ${host.host}`);
logger.debug(`Checking status of Windows services on host ${host.host}`);
const servicesToCheck = host.services;

// Get status of all services on host
logger.verbose(`Getting status of all Windows services on host ${host.host}`);
const serviceStatusAll = await statusAll(logger, host.host);

servicesToCheck.forEach(async (service) => {
logger.verbose(`Checking status of Windows service ${service.name} (="${service.friendlyName}") on host ${host.host}`);
logger.debug(`Checking status of Windows service ${service.name} (="${service.friendlyName}") on host ${host.host}`);

// Does this service exist in the serviceStatusAll array?
const svcMonitored = serviceStatusAll.find((svc) => svc.name === service.name);
Expand All @@ -196,7 +195,7 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => {

// Get status of this service
const serviceStatus = await status(logger, service.name, host.host);
logger.verbose(`Got reply: Service ${service.name} (="${service.friendlyName}") on host ${host.host} status: ${serviceStatus}`);
logger.debug(`Got reply: Service ${service.name} (="${service.friendlyName}") on host ${host.host} status: ${serviceStatus}`);

// Get details about this service
const serviceDetails = await details(logger, service.name, host.host);
Expand Down
8 changes: 4 additions & 4 deletions src/lib/qseow/winsvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ export function status(logger, serviceName, host = null) {
let command = '';
if (host === null) {
// Run command for get states of all services on local machine
logger.verbose(`WINSVC STATUS: Getting status of service ${serviceName} on local machine`);
logger.debug(`WINSVC STATUS: Getting status of service ${serviceName} on local machine`);
command = `sc.exe query "${serviceName}"`;
} else {
// A host other that local machine is specfied
logger.verbose(`WINSVC STATUS: Getting status of service ${serviceName} on host ${host}`);
logger.debug(`WINSVC STATUS: Getting status of service ${serviceName} on host ${host}`);
command = `sc.exe \\\\${host} query "${serviceName}"`;
}

Expand Down Expand Up @@ -327,12 +327,12 @@ export function details(logger, serviceName, host = null) {
let command = '';
if (host === null) {
// Run command for get states of all services on local machine
logger.verbose(`WINSVC DETAILS: Getting details of service ${serviceName} on local machine`);
logger.debug(`WINSVC DETAILS: Getting details of service ${serviceName} on local machine`);

command = `sc.exe qc "${serviceName}"`;
} else {
// A host other that local machine is specfied
logger.verbose(`WINSVC DETAILS: Getting details of service ${serviceName} on host ${host}`);
logger.debug(`WINSVC DETAILS: Getting details of service ${serviceName} on host ${host}`);

command = `sc.exe \\\\${host} qc "${serviceName}"`;
}
Expand Down

0 comments on commit f8981b3

Please sign in to comment.