diff --git a/src/server/views/helpers/queueHelpers.js b/src/server/views/helpers/queueHelpers.js index 2e0f2e00..242ad8ad 100644 --- a/src/server/views/helpers/queueHelpers.js +++ b/src/server/views/helpers/queueHelpers.js @@ -31,12 +31,31 @@ function formatBytes(num) { return (neg ? '-' : '') + numStr + ' ' + unit; } +function parseRedisServerInfo(redisServerInfo) { + if (typeof redisServerInfo !== 'string') { + return {}; + } + + const serverInfo = {}; + redisServerInfo + .split('\r\n') + .map((line) => line.trim()) + .filter((line) => !!line && !line.startsWith('#')) // remove comments and empty lines + .forEach((line) => { + const idx = line.indexOf(':'); + if (idx > 0) { + serverInfo[line.substring(0, idx)] = line.substring(idx + 1); + } + }); + return serverInfo; +} + const Helpers = { getStats: async function (queue) { const client = await queue.client; - await client.info(); // update queue.client.serverInfo + const info = await client.info(); - const stats = _.pickBy(client.serverInfo, (value, key) => + const stats = _.pickBy(parseRedisServerInfo(info), (value, key) => _.includes(this._usefulMetrics, key) ); stats.used_memory = formatBytes(parseInt(stats.used_memory, 10));