From 6d0dee979a95bfd8bbb435c7a6e45209e705d641 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 27 Mar 2020 19:59:26 -0400 Subject: [PATCH] allow admins to inspect index/metadata caches --- lib/commands/admin-rpc.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/commands/admin-rpc.js b/lib/commands/admin-rpc.js index a7cb59798..32e9b9947 100644 --- a/lib/commands/admin-rpc.js +++ b/lib/commands/admin-rpc.js @@ -19,6 +19,26 @@ var getFileDescriptorLimit = function (env, server, cb) { Ulimit(cb); }; +var getCacheStats = function (env, server, cb) { + var metaCount = 0; + var channelCount = 0; + + var meta = env.metadata_cache; + for (var x in meta) { + if (meta.hasOwnProperty(x)) { metaCount++; } + } + + var channels = env.channel_cache; + for (var y in channels) { + if (channels.hasOwnProperty(y)) { channelCount++; } + } + + cb(void 0, { + metadata: metaCount, + channel: channelCount, + }); +}; + var getActiveSessions = function (Env, Server, cb) { var stats = Server.getSessionStats(); cb(void 0, [ @@ -137,6 +157,7 @@ var commands = { GET_FILE_DESCRIPTOR_COUNT: getFileDescriptorCount, GET_FILE_DESCRIPTOR_LIMIT: getFileDescriptorLimit, SET_DEFAULT_STORAGE_LIMIT: setDefaultStorageLimit, + GET_CACHE_STATS: getCacheStats, }; Admin.command = function (Env, safeKey, data, _cb, Server) {