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