MEMORY_STATS.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.transformReply = exports.transformArguments = void 0;
  4. function transformArguments() {
  5. return ['MEMORY', 'STATS'];
  6. }
  7. exports.transformArguments = transformArguments;
  8. const FIELDS_MAPPING = {
  9. 'peak.allocated': 'peakAllocated',
  10. 'total.allocated': 'totalAllocated',
  11. 'startup.allocated': 'startupAllocated',
  12. 'replication.backlog': 'replicationBacklog',
  13. 'clients.slaves': 'clientsReplicas',
  14. 'clients.normal': 'clientsNormal',
  15. 'aof.buffer': 'aofBuffer',
  16. 'lua.caches': 'luaCaches',
  17. 'overhead.total': 'overheadTotal',
  18. 'keys.count': 'keysCount',
  19. 'keys.bytes-per-key': 'keysBytesPerKey',
  20. 'dataset.bytes': 'datasetBytes',
  21. 'dataset.percentage': 'datasetPercentage',
  22. 'peak.percentage': 'peakPercentage',
  23. 'allocator.allocated': 'allocatorAllocated',
  24. 'allocator.active': 'allocatorActive',
  25. 'allocator.resident': 'allocatorResident',
  26. 'allocator-fragmentation.ratio': 'allocatorFragmentationRatio',
  27. 'allocator-fragmentation.bytes': 'allocatorFragmentationBytes',
  28. 'allocator-rss.ratio': 'allocatorRssRatio',
  29. 'allocator-rss.bytes': 'allocatorRssBytes',
  30. 'rss-overhead.ratio': 'rssOverheadRatio',
  31. 'rss-overhead.bytes': 'rssOverheadBytes',
  32. 'fragmentation': 'fragmentation',
  33. 'fragmentation.bytes': 'fragmentationBytes'
  34. }, DB_FIELDS_MAPPING = {
  35. 'overhead.hashtable.main': 'overheadHashtableMain',
  36. 'overhead.hashtable.expires': 'overheadHashtableExpires'
  37. };
  38. function transformReply(rawReply) {
  39. const reply = {
  40. db: {}
  41. };
  42. for (let i = 0; i < rawReply.length; i += 2) {
  43. const key = rawReply[i];
  44. if (key.startsWith('db.')) {
  45. const dbTuples = rawReply[i + 1], db = {};
  46. for (let j = 0; j < dbTuples.length; j += 2) {
  47. db[DB_FIELDS_MAPPING[dbTuples[j]]] = dbTuples[j + 1];
  48. }
  49. reply.db[key.substring(3)] = db;
  50. continue;
  51. }
  52. reply[FIELDS_MAPPING[key]] = Number(rawReply[i + 1]);
  53. }
  54. return reply;
  55. }
  56. exports.transformReply = transformReply;