Merge pull request #1502 from notFloran/webui-per-cpu

Better display of per-cpu plugin with a lot of cpus
This commit is contained in:
Nicolas Hennion 2019-07-06 18:43:35 +02:00 committed by GitHub
commit e8a8b4666f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17406 additions and 17398 deletions

View File

@ -1,7 +1,8 @@
import _ from "lodash";
export default function GlancesPluginPercpuController($scope, GlancesStats, GlancesPluginHelper) { export default function GlancesPluginPercpuController($scope, GlancesStats, GlancesPluginHelper) {
var vm = this; var vm = this;
vm.cpus = []; vm.cpusChunks = [];
vm.$onInit = function () { vm.$onInit = function () {
loadData(GlancesStats.getData()); loadData(GlancesStats.getData());
@ -14,12 +15,12 @@ export default function GlancesPluginPercpuController($scope, GlancesStats, Glan
var loadData = function (data) { var loadData = function (data) {
var percpuStats = data.stats['percpu']; var percpuStats = data.stats['percpu'];
vm.cpus = []; var cpus = [];
for (var i = 0; i < percpuStats.length; i++) { for (var i = 0; i < percpuStats.length; i++) {
var cpuData = percpuStats[i]; var cpuData = percpuStats[i];
vm.cpus.push({ cpus.push({
'number': cpuData.cpu_number, 'number': cpuData.cpu_number,
'total': cpuData.total, 'total': cpuData.total,
'user': cpuData.user, 'user': cpuData.user,
@ -29,7 +30,9 @@ export default function GlancesPluginPercpuController($scope, GlancesStats, Glan
'steal': cpuData.steal 'steal': cpuData.steal
}); });
} }
}
vm.cpusChunks = _.chunk(cpus, 4);
};
vm.getUserAlert = function (cpu) { vm.getUserAlert = function (cpu) {
return GlancesPluginHelper.getAlert('percpu', 'percpu_user_', cpu.user) return GlancesPluginHelper.getAlert('percpu', 'percpu_user_', cpu.user)

View File

@ -1,37 +1,37 @@
<section id="percpu" class="plugin"> <section id="percpu" class="plugin">
<div class="table"> <div class="table" ng-repeat="cpus in vm.cpusChunks">
<div class="table-row"> <div class="table-row">
<div class="table-cell text-left title">PER CPU</div> <div class="table-cell text-left title"><span ng-if="$first">PER CPU</span></div>
<div class="table-cell" ng-repeat="percpu in vm.cpus track by percpu.number">{{ percpu.total }}%</div> <div class="table-cell" ng-repeat="percpu in cpus track by percpu.number">{{ percpu.total }}%</div>
</div> </div>
<div class="table-row"> <div class="table-row">
<div class="table-cell text-left">user:</div> <div class="table-cell text-left">user:</div>
<div class="table-cell" ng-repeat="percpu in vm.cpus track by percpu.number" <div class="table-cell" ng-repeat="percpu in cpus track by percpu.number"
ng-class="vm.getUserAlert(percpu)"> ng-class="vm.getUserAlert(percpu)">
{{ percpu.user }}% {{ percpu.user }}%
</div> </div>
</div> </div>
<div class="table-row"> <div class="table-row">
<div class="table-cell text-left">system:</div> <div class="table-cell text-left">system:</div>
<div class="table-cell" ng-repeat="percpu in vm.cpus track by percpu.number" <div class="table-cell" ng-repeat="percpu in cpus track by percpu.number"
ng-class="vm.getSystemAlert(percpu)"> ng-class="vm.getSystemAlert(percpu)">
{{ percpu.system }}% {{ percpu.system }}%
</div> </div>
</div> </div>
<div class="table-row"> <div class="table-row">
<div class="table-cell text-left">idle:</div> <div class="table-cell text-left">idle:</div>
<div class="table-cell" ng-repeat="percpu in vm.cpus track by percpu.number">{{ percpu.idle }}%</div> <div class="table-cell" ng-repeat="percpu in cpus track by percpu.number">{{ percpu.idle }}%</div>
</div> </div>
<div class="table-row" ng-if="vm.cpus[0].iowait"> <div class="table-row" ng-if="vm.cpus[0].iowait">
<div class="table-cell text-left">iowait:</div> <div class="table-cell text-left">iowait:</div>
<div class="table-cell" ng-repeat="percpu in vm.cpus track by percpu.number" <div class="table-cell" ng-repeat="percpu in cpus track by percpu.number"
ng-class="vm.getSystemAlert(percpu)"> ng-class="vm.getSystemAlert(percpu)">
{{ percpu.iowait }}% {{ percpu.iowait }}%
</div> </div>
</div> </div>
<div class="table-row" ng-if="vm.cpus[0].steal"> <div class="table-row" ng-if="vm.cpus[0].steal">
<div class="table-cell text-left">steal:</div> <div class="table-cell text-left">steal:</div>
<div class="table-cell" ng-repeat="percpu in vm.cpus track by percpu.number" <div class="table-cell" ng-repeat="percpu in cpus track by percpu.number"
ng-class="vm.getSystemAlert(percpu)"> ng-class="vm.getSystemAlert(percpu)">
{{ percpu.steal }}% {{ percpu.steal }}%
</div> </div>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long