summaryrefslogtreecommitdiffstats
path: root/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js
blob: f4d9c484a5ca86e715bb58a8ea44178513569ecb (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
/* Licensed to the public under the Apache License 2.0. */

'use strict';
'require baseclass';

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

	rrdargs(graph, host, plugin, plugin_instance, dtype) {
		const rv = [];
		const types = graph.dataTypes(host, plugin, plugin_instance);

		if (types.indexOf('temperature') > -1) {
			rv.push({
				per_instance: true,
				title: "%H: %pi - %di",
				vlabel: "\xb0C",
				number_format: "%4.1lf\xb0C",
				data: {
					types: [ "temperature" ],
					options: {
						temperature__value: {
							color: "ff0000",
							title: "Temperature"
						}
					}
				}
			});
		}
		if (types.indexOf('humidity') > -1) {
			rv.push({
				per_instance: true,
				title: "%H: %pi - %di",
				vlabel: "%RH",
				number_format: "%4.1lf %%RH",
				data: {
					types: [ "humidity" ],
					options: {
						humidity__value: {
							color: "0000ff",
							title: "Humidity"
						}
					}
				}
			});
		}
		if (types.indexOf('voltage') > -1) {
			rv.push({
				per_instance: true,
				title: "%H: %pi - %di",
				vlabel: "V",
				number_format: "%4.1lf V",
				data: {
					types: [ "voltage" ],
					options: {
						voltage__value: {
							color: "0000ff",
							title: "Voltage"
						}
					}
				}
			});
		}
		if (types.indexOf('current') > -1) {
			rv.push({
				per_instance: true,
				title: "%H: %pi - %di",
				vlabel: "A",
				number_format: "%4.1lf A",
				data: {
					types: [ "current" ],
					options: {
						current__value: {
							color: "00ff00",
							title: "Current"
						}
					}
				}
			});
		}
		if (types.indexOf('power') > -1) {
			rv.push({
				per_instance: true,
				title: "%H: %pi - %di",
				vlabel: "W",
				number_format: "%4.1lf W",
				data: {
					types: [ "power" ],
					options: {
						power__value: {
							color: "ff0000",
							title: "Power"
						}
					}
				}
			});
		}
		if (types.indexOf('fanspeed') > -1) {
			rv.push({
				per_instance: true,
				title: "%H: %pi - %di",
				vlabel: "rpm",
				number_format: "%4lf rpm",
				data: {
					types: [ "fanspeed" ],
					options: {
						fanspeed__value: {
							color: "0000ff",
							title: "Fan speed"
						}
					}
				}
			});
		}

		return rv;
	}
});