4ccc417da7775635be6f92e0b7e941666bb0cb5c
[oweals/luci.git] /
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
8 return L.Class.extend({
9         title: _('OLSRd'),
10
11         rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
12                 var g = [];
13
14                 if (plugin_instance == "routes") {
15                         g.push({
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                                 title: "%H: Average route ETX", vlabel: "ETX", detail: true,
29                                 number_format: "%5.1lf", data: {
30                                         instances: [ "average" ], /* falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert */
31                                         types: [ "route_etx" ],
32                                         options: {
33                                                 route_etx: {
34                                                         title: "Average route ETX"
35                                                 }
36                                         }
37                                 }
38                         }, {
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                 else if (plugin_instance == "links") {
52                         g.push({
53                                 /* diagram data description */
54                                 title: "%H: Total amount of OLSR neighbours", vlabel: "n",
55                                 number_format: "%5.0lf", data: {
56                                         instances: [ "" ],
57                                         types: [ "links" ],
58                                         options: {
59                                                 links: {
60                                                         color: "00ff00",
61                                                         title: "Number of neighbours"
62                                                 }
63                                         }
64                                 }
65                         });
66
67                         var instances = graph.dataInstances(host, plugin, plugin_instance, "signal_quality").sort();
68
69                         /* define one diagram per host, containing the rx and lq values */
70                         for (var i = 0; i < instances.length; i += 2) {
71                                 var dsn1 = "signal_quality_%s_value".format(instances[i].replace(/\W+/g, '_')),
72                                     dsn2 = "signal_quality_%s_value".format(instances[i+1].replace(/\W+/g, '_')),
73                                     host = instances[i].match(/^[^-]+-([^-]+)-.+$/),
74                                     host = host ? host[1] : 'avg',
75                                     opts = {};
76
77                                 opts[dsn1] = { color: "00ff00", title: "LQ (%s)".format(host) };
78                                 opts[dns2] = { color: "0000ff", title: "NLQ (%s)".format(host), flip: true };
79
80                                 g.push({
81                                         title: "%H: Signal Quality (%s)".format(host), vlabel: "ETX",
82                                         number_format: "%5.2lf", detail: true,
83                                         data: {
84                                                 types: [ "signal_quality" ],
85
86                                                 instances: {
87                                                         signal_quality: [ instances[i], instances[i+1] ],
88                                                 },
89
90                                                 options: opts
91                                         }
92                                 });
93                         }
94                 }
95                 else if (plugin_instance == "topology") {
96                         g.push({
97                                 title: "%H: Total amount of OLSR links", vlabel: "n",
98                                 number_format: "%5.0lf", data: {
99                                         instances: [ "" ],
100                                         types: [ "links" ],
101                                         options: {
102                                                 links: {
103                                                         color: "0000ff",
104                                                         title: "Total number of links"
105                                                 }
106                                         }
107                                 }
108                         }, {
109                                 title: "%H: Average signal quality", vlabel: "n",
110                                 number_format: "%5.2lf", detail: true,
111                                 data: {
112                                         instances: [ "average" ], /* exclude possible per-ip stuff */
113                                         types: [ "signal_quality" ],
114                                         options: {
115                                                 signal_quality: {
116                                                         color: "0000ff",
117                                                         title: "Average signal quality"
118                                                 }
119                                         }
120                                 }
121                         });
122                 }
123
124                 return g;
125         }
126 });