From 783b5d98e6f5619ed6057a174aadbdfec9a5ce06 Mon Sep 17 00:00:00 2001 From: Floran Brutel Date: Tue, 8 Sep 2015 07:53:10 +0200 Subject: [PATCH] WebUI : adds raid plugin --- glances/outputs/static/html/index.html | 1 + glances/outputs/static/html/plugins/raid.html | 19 ++++++++ glances/outputs/static/html/stats.html | 1 + .../static/js/services/core/glances_stats.js | 1 + .../js/services/plugins/glances_raid.js | 44 +++++++++++++++++++ glances/outputs/static/js/stats_controller.js | 1 + 6 files changed, 67 insertions(+) create mode 100644 glances/outputs/static/html/plugins/raid.html create mode 100644 glances/outputs/static/js/services/plugins/glances_raid.js diff --git a/glances/outputs/static/html/index.html b/glances/outputs/static/html/index.html index 610ca12c..46493c8c 100644 --- a/glances/outputs/static/html/index.html +++ b/glances/outputs/static/html/index.html @@ -35,6 +35,7 @@ + diff --git a/glances/outputs/static/html/plugins/raid.html b/glances/outputs/static/html/plugins/raid.html new file mode 100644 index 00000000..a6e0ab30 --- /dev/null +++ b/glances/outputs/static/html/plugins/raid.html @@ -0,0 +1,19 @@ +
+
RAID disks
+
Used
+
Total
+
+
+
+ {{ disk.type | uppercase }} {{ disk.name }} +
└─ Degraded mode
+
   └─ {{ disk.config }}
+ +
└─ Status {{ disk.status }}
+
+    {{ $last ? '└─' : '├─' }} disk {{ component.number }}: {{ component.name }} +
+
+
{{ disk.used }}
+
{{ disk.available }}
+
\ No newline at end of file diff --git a/glances/outputs/static/html/stats.html b/glances/outputs/static/html/stats.html index 03c413ea..d8ceed44 100644 --- a/glances/outputs/static/html/stats.html +++ b/glances/outputs/static/html/stats.html @@ -51,6 +51,7 @@
+
diff --git a/glances/outputs/static/js/services/core/glances_stats.js b/glances/outputs/static/js/services/core/glances_stats.js index b628c3ce..5b618320 100644 --- a/glances/outputs/static/js/services/core/glances_stats.js +++ b/glances/outputs/static/js/services/core/glances_stats.js @@ -17,6 +17,7 @@ glancesApp.service('GlancesStats', function($http, $injector, $q, GlancesPlugin) 'processcount': 'GlancesPluginProcessCount', 'processlist': 'GlancesPluginProcessList', 'quicklook': 'GlancesPluginQuicklook', + 'raid': 'GlancesPluginRaid', 'sensors': 'GlancesPluginSensors', 'system': 'GlancesPluginSystem', 'uptime': 'GlancesPluginUptime' diff --git a/glances/outputs/static/js/services/plugins/glances_raid.js b/glances/outputs/static/js/services/plugins/glances_raid.js new file mode 100644 index 00000000..f2100017 --- /dev/null +++ b/glances/outputs/static/js/services/plugins/glances_raid.js @@ -0,0 +1,44 @@ +glancesApp.service('GlancesPluginRaid', function () { + var _pluginName = "raid"; + this.disks = []; + + this.setData = function (data, views) { + this.disks = []; + data = data[_pluginName]; + + _.forIn(data, function(diskData, diskKey) { + var disk = { + 'name': diskKey, + 'type': diskData.type == null ? 'UNKNOWN' : diskData.type, + 'used': diskData.used, + 'available': diskData.available, + 'status': diskData.status, + 'degraded': diskData.used < diskData.available, + 'config': diskData.config == null ? '' : diskData.config.replace('_', 'A'), + 'inactive': diskData.status == 'inactive', + 'components': [] + }; + + _.forEach(diskData.components, function(number, name) { + disk.components.push({ + 'number': number, + 'name': name + }); + }); + + this.disks.push(disk); + }, this); + }; + + this.getAlert = function(disk) { + if (disk.inactive) { + return 'critical'; + } + + if (disk.degraded) { + return 'warning'; + } + + return 'ok' + } +}); diff --git a/glances/outputs/static/js/stats_controller.js b/glances/outputs/static/js/stats_controller.js index 71ccdf20..42cfbaff 100644 --- a/glances/outputs/static/js/stats_controller.js +++ b/glances/outputs/static/js/stats_controller.js @@ -73,6 +73,7 @@ glancesApp.controller('statsController', function ($scope, $interval, $routePara $scope.statsProcessCount = GlancesStats.getPlugin('processcount'); $scope.statsProcessList = GlancesStats.getPlugin('processlist'); $scope.statsQuicklook = GlancesStats.getPlugin('quicklook'); + $scope.statsRaid = GlancesStats.getPlugin('raid'); $scope.statsSensors = GlancesStats.getPlugin('sensors'); $scope.statsSystem = GlancesStats.getPlugin('system'); $scope.statsUptime = GlancesStats.getPlugin('uptime');