6 return baseclass
.extend({
7 title
: _('DF Plugin Configuration'),
8 description
: _('The df plugin collects statistics about the disk space usage on different devices, mount points or filesystem types.'),
10 addFormOptions: function(s
) {
13 o
= s
.option(form
.Flag
, 'enable', _('Enable this plugin'));
15 o
= s
.option(form
.DynamicList
, 'Devices', _('Monitor devices'));
17 o
.depends('enable', '1');
18 o
.load = function(section_id
) {
19 return fs
.lines('/proc/partitions').then(L
.bind(function(lines
) {
22 for (var i
= 0; i
< lines
.length
; i
++) {
23 var line
= L
.toArray(lines
[i
]);
25 parts
.push('/dev/' + line
[3]);
30 for (var i
= 0; i
< parts
.length
; i
++)
33 return this.super('load', [section_id
]);
37 o
= s
.option(form
.DynamicList
, 'MountPoints', _('Monitor mount points'));
38 o
.default = '/overlay';
40 o
.depends('enable', '1');
41 o
.load = function(section_id
) {
42 return fs
.lines('/proc/mounts').then(L
.bind(function(lines
) {
45 for (var i
= 0; i
< lines
.length
; i
++) {
46 var line
= L
.toArray(lines
[i
]);
47 mounts
[line
[1]] = true;
50 mounts
= Object
.keys(mounts
).sort();
52 for (var i
= 0; i
< mounts
.length
; i
++)
53 this.value(mounts
[i
]);
55 return this.super('load', [section_id
]);
59 o
= s
.option(form
.DynamicList
, 'FSTypes', _('Monitor filesystem types'));
62 o
.depends('enable', '1');
63 o
.load = function(section_id
) {
65 fs
.lines('/etc/filesystems'),
66 fs
.lines('/proc/filesystems')
67 ]).then(L
.bind(function(lines
) {
68 var fslines
= lines
[0].concat(lines
[1]),
71 for (var i
= 0; i
< fslines
.length
; i
++) {
72 var line
= L
.toArray(fslines
[i
]);
74 if (line
.length
== 2 && line
[0] == 'nodev')
77 fstypes
[line
.pop()] = true;
80 fstypes
= Object
.keys(fstypes
).sort();
82 for (var i
= 0; i
< fstypes
.length
; i
++)
83 this.value(fstypes
[i
]);
85 return this.super('load', [section_id
]);
89 o
= s
.option(form
.Flag
, 'IgnoreSelected', _('Monitor all except specified'));
90 o
.depends('enable', '1');
92 o
= s
.option(form
.Flag
, 'ValuesPercentage', _('Free space, reserved space and used space is reported as relative values'));
93 o
.depends('enable', '1');
96 configSummary: function(section
) {
97 var devs
= L
.toArray(section
.Devices
),
98 mounts
= L
.toArray(section
.MountPoints
),
99 fstypes
= L
.toArray(section
.FSTypes
),
100 count
= devs
.length
+ mounts
.length
+ fstypes
.length
,
101 invert
= section
.IgnoreSelected
== '1';
104 return _('Monitoring all partitions');
106 return (invert
? _('Monitoring all except %s, %s, %s') : _('Monitoring %s, %s, %s')).format(
107 N_(devs
.length
, 'one device', '%d devices').format(devs
.length
),
108 N_(mounts
.length
, 'one mount', '%d mounts').format(mounts
.length
),
109 N_(fstypes
.length
, 'one filesystem type', '%d filesystem types').format(fstypes
.length
)