applications/luci-statistics: rework handling of index and detail graphs
[project/luci.git] / applications / luci-statistics / luasrc / statistics / rrdtool / definitions / olsrd.lua
index 0ba3835..3ee3910 100644 (file)
@@ -15,8 +15,7 @@ module("luci.statistics.rrdtool.definitions.olsrd", package.seeall)
 
 local tree = luci.statistics.datatree.Instance()
 
-function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
-
+function rrdargs( graph, plugin, plugin_instance, dtype )
        local g = { }
 
        if plugin_instance == "routes" then
@@ -35,33 +34,31 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
                        }
                }
 
-               if not is_index then
-                       g[#g+1] = {
-                               title = "%H: Average route ETX", vlabel = "ETX",
-                               number_format = "%5.1lf",data = {
-                                       instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
-                                       types = { "route_etx" },
-                                       options = {
-                                               route_etx = {
-                                                       title = "Average route ETX"
-                                               }
+               g[#g+1] = {
+                       title = "%H: Average route ETX", vlabel = "ETX", detail = true,
+                       number_format = "%5.1lf",data = {
+                               instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
+                               types = { "route_etx" },
+                               options = {
+                                       route_etx = {
+                                               title = "Average route ETX"
                                        }
                                }
                        }
+               }
 
-                       g[#g+1] = {
-                               title = "%H: Average route metric", vlabel = "metric",
-                               number_format = "%5.1lf", data = {
-                                       instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
-                                       types = { "route_metric" },
-                                       options = {
-                                               route_metric = {
-                                                       title = "Average route metric"
-                                               }
+               g[#g+1] = {
+                       title = "%H: Average route metric", vlabel = "metric", detail = true,
+                       number_format = "%5.1lf", data = {
+                               instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
+                               types = { "route_metric" },
+                               options = {
+                                       route_metric = {
+                                               title = "Average route metric"
                                        }
                                }
                        }
-               end
+               }
 
        elseif plugin_instance == "links" then
 
@@ -80,40 +77,39 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
                        }
                }
 
-               if not is_index then
-                       local instances = tree:data_instances(plugin, plugin_instance, "signal_quality")
-                       table.sort(instances)
+               local instances = tree:data_instances(plugin, plugin_instance, "signal_quality")
+               table.sort(instances)
 
-                       -- define one diagram per host, containing the rx and lq values
-                       local i
-                       for i = 1, #instances, 2 do
-                               local dsn1 = "signal_quality_%s_value" % instances[i]:gsub("[^%w]+", "_")
-                               local dsn2 = "signal_quality_%s_value" % instances[i+1]:gsub("[^%w]+", "_")
-                               local host = instances[i]:match("^[^%-]+%-([^%-]+)%-.+")
+               -- define one diagram per host, containing the rx and lq values
+               local i
+               for i = 1, #instances, 2 do
+                       local dsn1 = "signal_quality_%s_value" % instances[i]:gsub("[^%w]+", "_")
+                       local dsn2 = "signal_quality_%s_value" % instances[i+1]:gsub("[^%w]+", "_")
+                       local host = instances[i]:match("^[^%-]+%-([^%-]+)%-.+")
 
-                               g[#g+1] = {
+                       g[#g+1] = {
                                title = "%H: Signal Quality" .. " (" .. (host or "avg") ..")", vlabel = "ETX",
-                               number_format = "%5.2lf", data = {
-                                               types = { "signal_quality" },
+                               number_format = "%5.2lf", detail = true,
+                               data = {
+                                       types = { "signal_quality" },
        
-                                               instances = {
-                                                       signal_quality = { instances[i], instances[i+1] },
-                                               },
+                                       instances = {
+                                               signal_quality = { instances[i], instances[i+1] },
+                                       },
 
-                                               options = {
-                                                       [dsn1] = {
-                                                               color = "00ff00",
-                                                               title = "LQ (%s)" % (host or "avg"),
-                                                       },
-                                                       [dsn2] = {
-                                                               color = "0000ff",
-                                                               title = "NLQ (%s)" % (host or "avg"),
-                                                               flip  = true
-                                                       }
+                                       options = {
+                                               [dsn1] = {
+                                                       color = "00ff00",
+                                                       title = "LQ (%s)" % (host or "avg"),
+                                               },
+                                               [dsn2] = {
+                                                       color = "0000ff",
+                                                       title = "NLQ (%s)" % (host or "avg"),
+                                                       flip  = true
                                                }
                                        }
                                }
-                       end
+                       }
                end
 
        elseif plugin_instance == "topology" then
@@ -124,7 +120,7 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
                                instances = { "" },
                                types = { "links" },
                                options = {
-                                       links = { -- or: links__value is aber egal weils eh nur eines davon gibt
+                                       links = {
                                                color = "0000ff",
                                                title = "Total number of links"
                                        }
@@ -132,21 +128,20 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
                        }
                }
 
-               if not is_index then
-                       g[#g+1] = {
-                               title= "%H: Average signal quality", vlabel = "n",
-                               number_format = "%5.2lf", data = {
-                                       instances = { "average" }, -- exclude possible per-ip stuff
-                                       types = { "signal_quality" },
-                                       options = {
-                                               signal_quality = {
-                                                       color = "0000ff",
-                                                       title = "Average signal quality"
-                                               }
+               g[#g+1] = {
+                       title= "%H: Average signal quality", vlabel = "n",
+                       number_format = "%5.2lf", detail = true,
+                       data = {
+                               instances = { "average" }, -- exclude possible per-ip stuff
+                               types = { "signal_quality" },
+                               options = {
+                                       signal_quality = {
+                                               color = "0000ff",
+                                               title = "Average signal quality"
                                        }
                                }
                        }
-               end
+               }
        end
 
        return g