olsrd.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. return baseclass.extend({
  8. title: _('OLSRd'),
  9. rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
  10. var g = [];
  11. if (plugin_instance == "routes") {
  12. g.push({
  13. /* diagram data description */
  14. title: "%H: Total amount of OLSR routes",
  15. vlabel: "n",
  16. number_format: "%5.0lf",
  17. data: {
  18. types: [ "routes" ],
  19. options: {
  20. routes: {
  21. color: "ff0000",
  22. title: "Total number of routes"
  23. }
  24. }
  25. }
  26. }, {
  27. title: "%H: Average route ETX",
  28. vlabel: "ETX",
  29. detail: true,
  30. number_format: "%5.1lf",
  31. data: {
  32. instances: [ "average" ], /* falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert */
  33. types: [ "route_etx" ],
  34. options: {
  35. route_etx: {
  36. title: "Average route ETX"
  37. }
  38. }
  39. }
  40. }, {
  41. title: "%H: Average route metric",
  42. vlabel: "metric",
  43. detail: true,
  44. number_format: "%5.1lf",
  45. data: {
  46. instances: [ "average" ], /* falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert */
  47. types: [ "route_metric" ],
  48. options: {
  49. route_metric: {
  50. title: "Average route metric"
  51. }
  52. }
  53. }
  54. });
  55. }
  56. else if (plugin_instance == "links") {
  57. g.push({
  58. /* diagram data description */
  59. title: "%H: Total amount of OLSR neighbours",
  60. vlabel: "n",
  61. number_format: "%5.0lf",
  62. data: {
  63. instances: [ "" ],
  64. types: [ "links" ],
  65. options: {
  66. links: {
  67. color: "00ff00",
  68. title: "Number of neighbours"
  69. }
  70. }
  71. }
  72. });
  73. var instances = graph.dataInstances(host, plugin, plugin_instance, "signal_quality").sort();
  74. /* define one diagram per host, containing the rx and lq values */
  75. for (var i = 0; i < instances.length; i += 2) {
  76. var dsn1 = "signal_quality_%s_value".format(instances[i].replace(/\W+/g, '_')),
  77. dsn2 = "signal_quality_%s_value".format(instances[i+1].replace(/\W+/g, '_')),
  78. host = instances[i].match(/^[^-]+-([^-]+)-.+$/),
  79. host = host ? host[1] : 'avg',
  80. opts = {};
  81. opts[dsn1] = { color: "00ff00", title: "LQ (%s)".format(host) };
  82. opts[dsn2] = { color: "0000ff", title: "NLQ (%s)".format(host), flip: true };
  83. g.push({
  84. title: "%%H: Signal Quality (%s)".format(host),
  85. vlabel: "ETX",
  86. number_format: "%5.2lf", detail: true,
  87. data: {
  88. types: [ "signal_quality" ],
  89. instances: {
  90. signal_quality: [ instances[i], instances[i+1] ],
  91. },
  92. options: opts
  93. }
  94. });
  95. }
  96. }
  97. else if (plugin_instance == "topology") {
  98. g.push({
  99. title: "%H: Total amount of OLSR links",
  100. vlabel: "n",
  101. number_format: "%5.0lf",
  102. data: {
  103. instances: [ "" ],
  104. types: [ "links" ],
  105. options: {
  106. links: {
  107. color: "0000ff",
  108. title: "Total number of links"
  109. }
  110. }
  111. }
  112. }, {
  113. title: "%H: Average signal quality",
  114. vlabel: "n",
  115. number_format: "%5.2lf",
  116. detail: true,
  117. data: {
  118. instances: [ "average" ], /* exclude possible per-ip stuff */
  119. types: [ "signal_quality" ],
  120. options: {
  121. signal_quality: {
  122. color: "0000ff",
  123. title: "Average signal quality"
  124. }
  125. }
  126. }
  127. });
  128. }
  129. return g;
  130. }
  131. });