diff --git a/lib/commands/admin-rpc.js b/lib/commands/admin-rpc.js index 32e9b9947..ed1d5b8a4 100644 --- a/lib/commands/admin-rpc.js +++ b/lib/commands/admin-rpc.js @@ -20,22 +20,36 @@ var getFileDescriptorLimit = function (env, server, cb) { }; var getCacheStats = function (env, server, cb) { + var metaSize = 0; + var channelSize = 0; 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++; } + try { + var meta = env.metadata_cache; + for (var x in meta) { + if (meta.hasOwnProperty(x)) { + metaCount++; + metaSize += JSON.stringify(meta[x]).length; + } + } + + var channels = env.channel_cache; + for (var y in channels) { + if (channels.hasOwnProperty(y)) { + channelCount++; + channelSize += JSON.stringify(channels[y]).length; + } + } + } catch (err) { + return void cb(err && err.message); } cb(void 0, { metadata: metaCount, + metaSize: metaSize, channel: channelCount, + channelSize: channelSize, }); };