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