improve admin rpc for diagnosing memory used by the cache

pull/1/head
ansuz 5 years ago
parent 77961e3954
commit e6ec891d9a

@ -20,22 +20,36 @@ var getFileDescriptorLimit = function (env, server, cb) {
}; };
var getCacheStats = function (env, server, cb) { var getCacheStats = function (env, server, cb) {
var metaSize = 0;
var channelSize = 0;
var metaCount = 0; var metaCount = 0;
var channelCount = 0; var channelCount = 0;
var meta = env.metadata_cache; try {
for (var x in meta) { var meta = env.metadata_cache;
if (meta.hasOwnProperty(x)) { metaCount++; } for (var x in meta) {
} if (meta.hasOwnProperty(x)) {
metaCount++;
var channels = env.channel_cache; metaSize += JSON.stringify(meta[x]).length;
for (var y in channels) { }
if (channels.hasOwnProperty(y)) { channelCount++; } }
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, { cb(void 0, {
metadata: metaCount, metadata: metaCount,
metaSize: metaSize,
channel: channelCount, channel: channelCount,
channelSize: channelSize,
}); });
}; };

Loading…
Cancel
Save