secubox-openwrt/package/secubox/luci-app-glances/htdocs/luci-static/resources/glances/api.js
CyberMind-FR 4004f2bfe8 feat(glances): Add Glances system monitoring module
Add secubox-app-glances and luci-app-glances packages:

secubox-app-glances:
- LXC container with nicolargo/glances:latest-full Docker image
- Web UI on port 61208, API on port 61209
- UCI configuration for monitoring options and alert thresholds
- glancesctl management script

luci-app-glances:
- Dashboard view with service status and quick actions
- Embedded Web UI view with iframe
- Settings view for configuration
- RPCD backend with proper ACL permissions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 07:38:37 +01:00

115 lines
2.0 KiB
JavaScript

'use strict';
'require baseclass';
'require rpc';
var callGetStatus = rpc.declare({
object: 'luci.glances',
method: 'get_status'
});
var callGetConfig = rpc.declare({
object: 'luci.glances',
method: 'get_config'
});
var callGetMonitoringConfig = rpc.declare({
object: 'luci.glances',
method: 'get_monitoring_config'
});
var callGetAlertsConfig = rpc.declare({
object: 'luci.glances',
method: 'get_alerts_config'
});
var callGetWebUrl = rpc.declare({
object: 'luci.glances',
method: 'get_web_url'
});
var callServiceStart = rpc.declare({
object: 'luci.glances',
method: 'service_start'
});
var callServiceStop = rpc.declare({
object: 'luci.glances',
method: 'service_stop'
});
var callServiceRestart = rpc.declare({
object: 'luci.glances',
method: 'service_restart'
});
var callSetConfig = rpc.declare({
object: 'luci.glances',
method: 'set_config',
params: ['key', 'value']
});
return baseclass.extend({
getStatus: function() {
return callGetStatus().catch(function() {
return { running: false, enabled: false };
});
},
getConfig: function() {
return callGetConfig().catch(function() {
return {};
});
},
getMonitoringConfig: function() {
return callGetMonitoringConfig().catch(function() {
return {};
});
},
getAlertsConfig: function() {
return callGetAlertsConfig().catch(function() {
return {};
});
},
getWebUrl: function() {
return callGetWebUrl().catch(function() {
return { web_url: '' };
});
},
serviceStart: function() {
return callServiceStart();
},
serviceStop: function() {
return callServiceStop();
},
serviceRestart: function() {
return callServiceRestart();
},
setConfig: function(key, value) {
return callSetConfig(key, value);
},
getAllData: function() {
var self = this;
return Promise.all([
self.getStatus(),
self.getConfig(),
self.getMonitoringConfig(),
self.getAlertsConfig()
]).then(function(results) {
return {
status: results[0],
config: results[1],
monitoring: results[2],
alerts: results[3]
};
});
}
});