1
0

olsrd.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. -- Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
  2. -- Licensed to the public under the Apache License 2.0.
  3. module("luci.statistics.rrdtool.definitions.olsrd", package.seeall)
  4. function rrdargs( graph, plugin, plugin_instance, dtype )
  5. local g = { }
  6. if plugin_instance == "routes" then
  7. g[#g+1] = {
  8. -- diagram data description
  9. title = "%H: Total amount of OLSR routes", vlabel = "n",
  10. number_format = "%5.0lf", data = {
  11. types = { "routes" },
  12. options = {
  13. routes = {
  14. color = "ff0000",
  15. title = "Total number of routes"
  16. }
  17. }
  18. }
  19. }
  20. g[#g+1] = {
  21. title = "%H: Average route ETX", vlabel = "ETX", detail = true,
  22. number_format = "%5.1lf",data = {
  23. instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
  24. types = { "route_etx" },
  25. options = {
  26. route_etx = {
  27. title = "Average route ETX"
  28. }
  29. }
  30. }
  31. }
  32. g[#g+1] = {
  33. title = "%H: Average route metric", vlabel = "metric", detail = true,
  34. number_format = "%5.1lf", data = {
  35. instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
  36. types = { "route_metric" },
  37. options = {
  38. route_metric = {
  39. title = "Average route metric"
  40. }
  41. }
  42. }
  43. }
  44. elseif plugin_instance == "links" then
  45. g[#g+1] = {
  46. -- diagram data description
  47. title = "%H: Total amount of OLSR neighbours", vlabel = "n",
  48. number_format = "%5.0lf", data = {
  49. instances = { "" },
  50. types = { "links" },
  51. options = {
  52. links = {
  53. color = "00ff00",
  54. title = "Number of neighbours"
  55. }
  56. }
  57. }
  58. }
  59. local instances = graph.tree:data_instances(plugin, plugin_instance, "signal_quality")
  60. table.sort(instances)
  61. -- define one diagram per host, containing the rx and lq values
  62. local i
  63. for i = 1, #instances, 2 do
  64. local dsn1 = "signal_quality_%s_value" % instances[i]:gsub("[^%w]+", "_")
  65. local dsn2 = "signal_quality_%s_value" % instances[i+1]:gsub("[^%w]+", "_")
  66. local host = instances[i]:match("^[^%-]+%-([^%-]+)%-.+")
  67. g[#g+1] = {
  68. title = "%H: Signal Quality" .. " (" .. (host or "avg") ..")", vlabel = "ETX",
  69. number_format = "%5.2lf", detail = true,
  70. data = {
  71. types = { "signal_quality" },
  72. instances = {
  73. signal_quality = { instances[i], instances[i+1] },
  74. },
  75. options = {
  76. [dsn1] = {
  77. color = "00ff00",
  78. title = "LQ (%s)" % (host or "avg"),
  79. },
  80. [dsn2] = {
  81. color = "0000ff",
  82. title = "NLQ (%s)" % (host or "avg"),
  83. flip = true
  84. }
  85. }
  86. }
  87. }
  88. end
  89. elseif plugin_instance == "topology" then
  90. g[#g+1] = {
  91. title= "%H: Total amount of OLSR links", vlabel = "n",
  92. number_format = "%5.0lf", data = {
  93. instances = { "" },
  94. types = { "links" },
  95. options = {
  96. links = {
  97. color = "0000ff",
  98. title = "Total number of links"
  99. }
  100. }
  101. }
  102. }
  103. g[#g+1] = {
  104. title= "%H: Average signal quality", vlabel = "n",
  105. number_format = "%5.2lf", detail = true,
  106. data = {
  107. instances = { "average" }, -- exclude possible per-ip stuff
  108. types = { "signal_quality" },
  109. options = {
  110. signal_quality = {
  111. color = "0000ff",
  112. title = "Average signal quality"
  113. }
  114. }
  115. }
  116. }
  117. end
  118. return g
  119. end