6ba571e8b810f622e3f9cac2f5c89a7926ba8011
10 fs
.list('/usr/lib/collectd'),
11 fs
.list('/usr/share/luci/statistics/plugins')
12 ]).then(function(data
) {
13 var installed
= data
[0],
17 for (var i
= 0; i
< plugins
.length
; i
++) {
18 tasks
.push(fs
.read_direct('/usr/share/luci/statistics/plugins/' + plugins
[i
].name
, 'json').then(L
.bind(function(name
, spec
) {
19 return L
.resolveDefault(L
.require('view.statistics.plugins.' + name
)).then(function(form
) {
24 installed
: installed
.filter(function(e
) { return e
.name
== name
+ '.so' }).length
> 0
27 }, this, plugins
[i
].name
.replace(/\.json$/, ''))));
30 return Promise
.all(tasks
);
34 render: function(plugins
) {
37 for (var i
= 0; i
< plugins
.length
; i
++)
38 plugins
[plugins
[i
].name
] = plugins
[i
];
40 m
= new form
.Map('luci_statistics', _('Collectd Settings'));
43 s
= m
.section(form
.NamedSection
, 'collectd', 'statistics', _('Collectd Settings'));
45 o
= s
.option(form
.Value
, 'Hostname', _('Hostname'));
47 return fs
.trimmed('/proc/sys/kernel/hostname').then(L
.bind(function(name
) {
48 this.placeholder
= name
;
49 return uci
.get('collectd', 'statistics', 'hostname');
53 o
= s
.option(form
.Value
, 'BaseDir', _('Base Directory'));
54 o
.default = '/var/run/collectd';
56 o
= s
.option(form
.Value
, 'Include', _('Directory for sub-configurations'));
57 o
.default = '/etc/collectd/conf.d/*.conf';
59 o
= s
.option(form
.Value
, 'PluginDir', _('Directory for collectd plugins'));
60 o
.default = '/usr/lib/collectd/';
62 o
= s
.option(form
.Value
, 'PIDFile', _('Used PID file'));
63 o
.default = '/var/run/collectd.pid';
65 o
= s
.option(form
.Value
, 'TypesDB', _('Datasets definition file'));
66 o
.default = '/etc/collectd/types.db';
68 o
= s
.option(form
.Value
, 'Interval', _('Data collection interval'), _('Seconds'));
71 o
= s
.option(form
.Value
, 'ReadThreads', _('Number of threads for data collection'));
74 o
= s
.option(form
.Flag
, 'FQDNLookup', _('Try to lookup fully qualified hostname'));
75 o
.default = o
.disabled
;
77 o
.depends('Hostname', '');
80 'general', _('General plugins'),
81 'network', _('Network plugins'),
82 'output', _('Output plugins')
85 for (var i
= 0; i
< groupNames
.length
; i
+= 2) {
86 s
= m
.section(form
.GridSection
, 'statistics_' + groupNames
[i
], groupNames
[i
+ 1]);
88 s
.cfgsections
= L
.bind(function(category
) {
89 return this.map
.data
.sections('luci_statistics', 'statistics')
90 .map(function(s
) { return s
['.name'] })
91 .filter(function(section_id
) {
92 var name
= section_id
.replace(/^collectd_/, ''),
93 plugin
= plugins
[name
];
95 return (section_id
.indexOf('collectd_') == 0 && plugin
!= null &&
96 plugin
.installed
&& plugin
.spec
.category
== category
);
100 s
.sectiontitle = function(section_id
) {
101 var name
= section_id
.replace(/^collectd_/, ''),
102 plugin
= plugins
[name
];
104 return plugin
? plugin
.spec
.title
: name
107 o
= s
.option(form
.Flag
, 'enable', _('Enabled'));
111 o
= s
.option(form
.DummyValue
, '_dummy', _('Status'));
114 o
.textvalue = function(section_id
) {
115 var name
= section_id
.replace(/^collectd_/, ''),
116 section
= uci
.get('luci_statistics', section_id
),
117 plugin
= plugins
[name
];
119 if (section
.enable
!= '1')
120 return E('em', {}, [_('Plugin is disabled')]);
122 var summary
= plugin
? plugin
.form
.configSummary(section
) : null;
123 return summary
|| E('em', _('none'));
126 s
.modaltitle = function(section_id
) {
127 var name
= section_id
.replace(/^collectd_/, ''),
128 plugin
= plugins
[name
];
130 return plugin
? plugin
.form
.title
: null;
133 s
.addModalOptions = function(s
) {
134 var name
= s
.section
.replace(/^collectd_/, ''),
135 plugin
= plugins
[name
];
140 s
.description
= plugin
.form
.description
;
142 plugin
.form
.addFormOptions(s
);
145 s
.renderRowActions = function(section_id
) {
146 var name
= section_id
.replace(/^collectd_/, ''),
147 plugin
= plugins
[name
];
149 var trEl
= this.super('renderRowActions', [ section_id
, _('Configureā¦') ]);
151 if (!plugin
|| !plugin
.form
.addFormOptions
)
152 L
.dom
.content(trEl
, null);