6 /^[0-9]+(?:\.[0-9]+)?v$/, 'voltage',
7 /^(?:ain|in|vccp|vdd|vid|vin|volt|voltbatt|vrm)[0-9]*$/, 'voltage',
8 /^(?:cpu_temp|remote_temp|temp)[0-9]*$/, 'temperature',
9 /^(?:fan)[0-9]*$/, 'fanspeed',
10 /^(?:power)[0-9]*$/, 'power'
13 return L
.Class
.extend({
14 title
: _('Sensors Plugin Configuration'),
15 description
: _('The sensors plugin uses the Linux Sensors framework to gather environmental statistics.'),
17 addFormOptions: function(s
) {
20 o
= s
.option(form
.Flag
, 'enable', _('Enable this plugin'));
22 o
= s
.option(form
.DynamicList
, 'Sensor', _('Sensor list'));
25 o
.depends('enable', '1');
26 o
.load = function(section_id
) {
27 return fs
.exec_direct('/usr/sbin/sensors', ['-j'], 'json').then(L
.bind(function(output
) {
28 for (var bus
in output
) {
29 for (var sensor
in output
[bus
]) {
30 if (!L
.isObject(output
[bus
][sensor
]))
33 for (var j
= 0; j
< sensorTypes
.length
; j
+= 2) {
34 if (sensor
.match(sensorTypes
[j
])) {
35 this.value('%s/%s-%s'.format(bus
, sensorTypes
[j
+ 1], sensor
));
42 return this.super('load', [section_id
]);
46 o
= s
.option(form
.Flag
, 'IgnoreSelected', _('Monitor all except specified'));
47 o
.depends('enable', '1');
50 configSummary: function(section
) {
51 var sensors
= L
.toArray(section
.Sensor
),
52 invert
= section
.IgnoreSelected
== '1';
54 if (invert
&& sensors
.length
)
55 return N_(sensors
.length
, 'Monitoring all but one sensor', 'Monitoring all but %d sensors').format(sensors
.length
);
56 else if (sensors
.length
)
57 return N_(sensors
.length
, 'Monitoring one sensor', 'Monitoring %d sensors').format(sensors
.length
);
59 return _('Monitoring all sensors');