93cb266dc00795a04d1e70264d6892904f1b9747
[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[dns2] = { color: "0000ff", title: "NLQ (%s)".format(host), flip: true };
90
91                                 g.push({
92                                         title: "%H: Signal Quality (%s)".format(host), vlabel: "ETX",
93                                         number_format: "%5.2lf", detail: true,
94                                         data: {
95                                                 types: [ "signal_quality" ],
96
97                                                 instances: {
98                                                         signal_quality: [ instances[i], instances[i+1] ],
99                                                 },
100
101                                                 options: opts
102                                         }
103                                 });
104                         }
105                 }
106                 else if (plugin_instance == "topology") {
107                         g.push({
108                                 title: "%H: Total amount of OLSR links",
109                                 vlabel: "n",
110                                 number_format: "%5.0lf",
111                                 data: {
112                                         instances: [ "" ],
113                                         types: [ "links" ],
114                                         options: {
115                                                 links: {
116                                                         color: "0000ff",
117                                                         title: "Total number of links"
118                                                 }
119                                         }
120                                 }
121                         }, {
122                                 title: "%H: Average signal quality",
123                                 vlabel: "n",
124                                 number_format: "%5.2lf",
125                                 detail: true,
126                                 data: {
127                                         instances: [ "average" ], /* exclude possible per-ip stuff */
128                                         types: [ "signal_quality" ],
129                                         options: {
130                                                 signal_quality: {
131                                                         color: "0000ff",
132                                                         title: "Average signal quality"
133                                                 }
134                                         }
135                                 }
136                         });
137                 }
138
139                 return g;
140         }
141 });
git clone https://git.99rst.org/PROJECT