memory.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
  3. * Licensed to the public under the Apache License 2.0.
  4. */
  5. 'use strict';
  6. 'require baseclass';
  7. 'require uci';
  8. return baseclass.extend({
  9. title: _('Memory'),
  10. rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
  11. var p = [];
  12. var hide_free = uci.get("luci_statistics", "collectd_memory", "HideFree") == "1" ? true : false;
  13. var memory = {
  14. title: "%H: Memory usage",
  15. vlabel: "MB",
  16. number_format: "%5.1lf%s",
  17. y_min: "0",
  18. alt_autoscale_max: true,
  19. data: {
  20. instances: {
  21. memory: [
  22. ...(hide_free ? [] : ["free"]),
  23. "buffered",
  24. "cached",
  25. "used"
  26. ]
  27. },
  28. options: {
  29. memory_buffered: {
  30. color: "0000ff",
  31. title: "Buffered"
  32. },
  33. memory_cached: {
  34. color: "ff00ff",
  35. title: "Cached"
  36. },
  37. memory_used: {
  38. color: "ff0000",
  39. title: "Used"
  40. },
  41. memory_free: {
  42. color: "00ff00",
  43. title: "Free"
  44. }
  45. }
  46. }
  47. };
  48. var percent = {
  49. title: "%H: Memory usage",
  50. vlabel: "Percent",
  51. number_format: "%5.1lf%%",
  52. y_min: "0",
  53. alt_autoscale_max: true,
  54. data: {
  55. instances: {
  56. percent: [
  57. ...(hide_free ? [] : ["free"]),
  58. "buffered",
  59. "cached",
  60. "used"
  61. ]
  62. },
  63. options: {
  64. percent_buffered: {
  65. color: "0000ff",
  66. title: "Buffered"
  67. },
  68. percent_cached: {
  69. color: "ff00ff",
  70. title: "Cached"
  71. },
  72. percent_used: {
  73. color: "ff0000",
  74. title: "Used"
  75. },
  76. percent_free: {
  77. color: "00ff00",
  78. title: "Free"
  79. }
  80. }
  81. }
  82. };
  83. var types = graph.dataTypes(host, plugin, plugin_instance);
  84. for (var i = 0; i < types.length; i++)
  85. if (types[i] == 'percent')
  86. p.push(percent);
  87. else if (types[i] == 'memory')
  88. p.push(memory);
  89. return p;
  90. }
  91. });