df.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Licensed to the public under the Apache License 2.0. */
  2. 'use strict';
  3. 'require baseclass';
  4. return baseclass.extend({
  5. title: _('Disk Space Usage'),
  6. rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
  7. var df_complex = {
  8. title: "%H: Disk space usage on %pi",
  9. vlabel: "Bytes",
  10. number_format: "%5.1lf%sB",
  11. data: {
  12. instances: {
  13. df_complex: [ "free", "used", "reserved" ]
  14. },
  15. options: {
  16. df_complex_free: {
  17. color: "00ff00",
  18. overlay: false,
  19. title: "free"
  20. },
  21. df_complex_used: {
  22. color: "ff0000",
  23. overlay: false,
  24. title: "used"
  25. },
  26. df_complex_reserved: {
  27. color: "0000ff",
  28. overlay: false,
  29. title: "reserved"
  30. }
  31. }
  32. }
  33. };
  34. var percent_bytes = {
  35. title: "%H: Disk space usage on %pi",
  36. vlabel: "Percent",
  37. number_format: "%5.2lf %%",
  38. data: {
  39. instances: {
  40. percent_bytes: [ "free", "used", "reserved" ]
  41. },
  42. options: {
  43. percent_bytes_free: {
  44. color: "00ff00",
  45. overlay: false,
  46. title: "free"
  47. },
  48. percent_bytes_used: {
  49. color: "ff0000",
  50. overlay: false,
  51. title: "used"
  52. },
  53. percent_bytes_reserved: {
  54. color: "0000ff",
  55. overlay: false,
  56. title: "reserved"
  57. }
  58. }
  59. }
  60. };
  61. var types = graph.dataTypes(host, plugin, plugin_instance);
  62. var p = [];
  63. for (var i = 0; i < types.length; i++)
  64. if (types[i] == 'percent_bytes')
  65. p.push(percent_bytes);
  66. else if (types[i] == 'df_complex')
  67. p.push(df_complex);
  68. return p;
  69. }
  70. });