mirror of
https://github.com/ptarmiganlabs/butler-sos.git
synced 2025-12-19 17:58:18 -05:00
Address code review feedback: fix typo and prevent overlapping executions
- Fix spelling: 'retrived' -> 'retrieved' in proxysessionmetrics.js - Add flag to prevent overlapping health check executions - Change back to sequential server processing to avoid overwhelming Sense servers - Add warning log when skipping intervals due to long-running health checks Co-authored-by: mountaindude <1029262+mountaindude@users.noreply.github.com>
This commit is contained in:
@@ -156,18 +156,33 @@ export async function getHealthStatsFromSense(serverName, host, tags, headers, r
|
||||
*
|
||||
* This function creates an interval that runs every pollingInterval milliseconds (as defined in config)
|
||||
* and calls getHealthStatsFromSense for each server in the serverList global variable.
|
||||
* Uses a flag to prevent overlapping executions if health checks take longer than the polling interval.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function setupHealthMetricsTimer() {
|
||||
let isCollecting = false;
|
||||
|
||||
// Configure timer for getting healthcheck data
|
||||
setInterval(async () => {
|
||||
// Prevent overlapping executions
|
||||
if (isCollecting) {
|
||||
globals.logger.warn(
|
||||
'HEALTH: Previous health check collection still in progress, skipping this interval'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
isCollecting = true;
|
||||
try {
|
||||
globals.logger.verbose('HEALTH: Event started: Statistics collection');
|
||||
|
||||
// Process all servers concurrently with error handling
|
||||
const healthCheckPromises = globals.serverList.map(async (server) => {
|
||||
// Process servers sequentially to avoid overwhelming the Sense servers
|
||||
for (const server of globals.serverList) {
|
||||
try {
|
||||
globals.logger.verbose(`HEALTH: Getting stats for server: ${server.serverName}`);
|
||||
globals.logger.verbose(
|
||||
`HEALTH: Getting stats for server: ${server.serverName}`
|
||||
);
|
||||
globals.logger.debug(`HEALTH: Server details: ${JSON.stringify(server)}`);
|
||||
|
||||
// Get per-server tags
|
||||
@@ -182,9 +197,9 @@ export function setupHealthMetricsTimer() {
|
||||
`HEALTH: Unexpected error processing health stats for server '${server.serverName}': ${globals.getErrorMessage(err)}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Wait for all health checks to complete
|
||||
await Promise.allSettled(healthCheckPromises);
|
||||
}
|
||||
} finally {
|
||||
isCollecting = false;
|
||||
}
|
||||
}, globals.config.get('Butler-SOS.serversToMonitor.pollingInterval'));
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ export async function getProxySessionStatsFromSense(
|
||||
influxTags,
|
||||
retryCount = 0
|
||||
) {
|
||||
// Current user sessions are retrived using this API:
|
||||
// Current user sessions are retrieved using this API:
|
||||
// https://help.qlik.com/en-US/sense-developer/February2021/Subsystems/ProxyServiceAPI/Content/Sense_ProxyServiceAPI/ProxyServiceAPI-Proxy-API.htm
|
||||
|
||||
// Get certificate configuration options
|
||||
|
||||
Reference in New Issue
Block a user