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