summaryrefslogtreecommitdiffstats
path: root/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/olsrd.js
blob: cafe2ac70ed5f31f02a05aa7a432f8dec94333e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
 * Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
 * Licensed to the public under the Apache License 2.0.
 */

'use strict';
'require baseclass';

return baseclass.extend({
	title: _('OLSRd'),

	rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
		var g = [];

		if (plugin_instance == "routes") {
			g.push({
				/* diagram data description */
				title: "%H: Total amount of OLSR routes",
				vlabel: "n",
				number_format: "%5.0lf",
				data: {
					types: [ "routes" ],
					options: {
						routes: {
							color: "ff0000",
							title: "Total number of routes"
						}
					}
				}
			}, {
				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"
						}
					}
				}
			}, {
				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"
						}
					}
				}
			});
		}
		else if (plugin_instance == "links") {
			g.push({
				/* diagram data description */
				title: "%H: Total amount of OLSR neighbours",
				vlabel: "n",
				number_format: "%5.0lf",
				data: {
					instances: [ "" ],
					types: [ "links" ],
					options: {
						links: {
							color: "00ff00",
							title: "Number of neighbours"
						}
					}
				}
			});

			var instances = graph.dataInstances(host, plugin, plugin_instance, "signal_quality").sort();

			/* define one diagram per host, containing the rx and lq values */
			for (var i = 0; i < instances.length; i += 2) {
				var dsn1 = "signal_quality_%s_value".format(instances[i].replace(/\W+/g, '_')),
				    dsn2 = "signal_quality_%s_value".format(instances[i+1].replace(/\W+/g, '_')),
				    host = instances[i].match(/^[^-]+-([^-]+)-.+$/),
				    host = host ? host[1] : 'avg',
				    opts = {};

				opts[dsn1] = { color: "00ff00", title: "LQ (%s)".format(host) };
				opts[dsn2] = { color: "0000ff", title: "NLQ (%s)".format(host), flip: true };

				g.push({
					title: "%%H: Signal Quality (%s)".format(host),
					vlabel: "ETX",
					number_format: "%5.2lf", detail: true,
					data: {
						types: [ "signal_quality" ],

						instances: {
							signal_quality: [ instances[i], instances[i+1] ],
						},

						options: opts
					}
				});
			}
		}
		else if (plugin_instance == "topology") {
			g.push({
				title: "%H: Total amount of OLSR links",
				vlabel: "n",
				number_format: "%5.0lf",
				data: {
					instances: [ "" ],
					types: [ "links" ],
					options: {
						links: {
							color: "0000ff",
							title: "Total number of links"
						}
					}
				}
			}, {
				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"
						}
					}
				}
			});
		}

		return g;
	}
});