cafe2ac70ed5f31f02a05aa7a432f8dec94333e5
[openwrt-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 '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",
19                                 vlabel: "n",
20                                 number_format: "%5.0lf",
21                                 data: {
22                                         types: [ "routes" ],
23                                         options: {
24                                                 routes: {
25                                                         color: "ff0000",
26                                                         title: "Total number of routes"
27                                                 }
28                                         }
29                                 }
30                         }, {
31                                 title: "%H: Average route ETX",
32                                 vlabel: "ETX",
33                                 detail: true,
34                                 number_format: "%5.1lf",
35                                 data: {
36                                         instances: [ "average" ], /* falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert */
37                                         types: [ "route_etx" ],
38                                         options: {
39                                                 route_etx: {
40                                                         title: "Average route ETX"
41                                                 }
42                                         }
43                                 }
44                         }, {
45                                 title: "%H: Average route metric",
46                                 vlabel: "metric",
47                                 detail: true,
48                                 number_format: "%5.1lf",
49                                 data: {
50                                         instances: [ "average" ], /* falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert */
51                                         types: [ "route_metric" ],
52                                         options: {
53                                                 route_metric: {
54                                                         title: "Average route metric"
55                                                 }
56                                         }
57                                 }
58                         });
59                 }
60                 else if (plugin_instance == "links") {
61                         g.push({
62                                 /* diagram data description */
63                                 title: "%H: Total amount of OLSR neighbours",
64                                 vlabel: "n",
65                                 number_format: "%5.0lf",
66                                 data: {
67                                         instances: [ "" ],
68                                         types: [ "links" ],
69                                         options: {
70                                                 links: {
71                                                         color: "00ff00",
72                                                         title: "Number of neighbours"
73                                                 }
74                                         }
75                                 }
76                         });
77
78                         var instances = graph.dataInstances(host, plugin, plugin_instance, "signal_quality").sort();
79
80                         /* define one diagram per host, containing the rx and lq values */
81                         for (var i = 0; i < instances.length; i += 2) {
82                                 var dsn1 = "signal_quality_%s_value".format(instances[i].replace(/\W+/g, '_')),
83                                     dsn2 = "signal_quality_%s_value".format(instances[i+1].replace(/\W+/g, '_')),
84                                     host = instances[i].match(/^[^-]+-([^-]+)-.+$/),
85                                     host = host ? host[1] : 'avg',
86                                     opts = {};
87
88                                 opts[dsn1] = { color: "00ff00", title: "LQ (%s)".format(host) };
89                                 opts[dsn2] = { color: "0000ff", title: "NLQ (%s)".format(host), flip: true };
90
91                                 g.push({
92                                         title: "%%H: Signal Quality (%s)".format(host),
93                                         vlabel: "ETX",
94                                         number_format: "%5.2lf", detail: true,
95                                         data: {
96                                                 types: [ "signal_quality" ],
97
98                                                 instances: {
99                                                         signal_quality: [ instances[i], instances[i+1] ],
100                                                 },
101
102                                                 options: opts
103                                         }
104                                 });
105                         }
106                 }
107                 else if (plugin_instance == "topology") {
108                         g.push({
109                                 title: "%H: Total amount of OLSR links",
110                                 vlabel: "n",
111                                 number_format: "%5.0lf",
112                                 data: {
113                                         instances: [ "" ],
114                                         types: [ "links" ],
115                                         options: {
116                                                 links: {
117                                                         color: "0000ff",
118                                                         title: "Total number of links"
119                                                 }
120                                         }
121                                 }
122                         }, {
123                                 title: "%H: Average signal quality",
124                                 vlabel: "n",
125                                 number_format: "%5.2lf",
126                                 detail: true,
127                                 data: {
128                                         instances: [ "average" ], /* exclude possible per-ip stuff */
129                                         types: [ "signal_quality" ],
130                                         options: {
131                                                 signal_quality: {
132                                                         color: "0000ff",
133                                                         title: "Average signal quality"
134                                                 }
135                                         }
136                                 }
137                         });
138                 }
139
140                 return g;
141         }
142 });
git clone https://git.99rst.org/PROJECT