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