Updated agent webui page to display allocated and available resources. Review: https://reviews.apache.org/r/58549/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/00569bfc Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/00569bfc Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/00569bfc Branch: refs/heads/master Commit: 00569bfcff4ed14fa083862f604e018512a6e282 Parents: 65ecc0a Author: Benjamin Mahler <[email protected]> Authored: Tue Apr 25 02:12:54 2017 +0800 Committer: Haosdent Huang <[email protected]> Committed: Tue Apr 25 02:12:54 2017 +0800 ---------------------------------------------------------------------- src/webui/master/static/agent.html | 50 ++++++++++++++++++++++---- src/webui/master/static/js/controllers.js | 15 ++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/00569bfc/src/webui/master/static/agent.html ---------------------------------------------------------------------- diff --git a/src/webui/master/static/agent.html b/src/webui/master/static/agent.html index cd55973..71e5e70 100644 --- a/src/webui/master/static/agent.html +++ b/src/webui/master/static/agent.html @@ -88,30 +88,68 @@ <tr> <td></td> <td class="text-right">Used</td> + <td class="text-right">Allocated</td> + <td class="text-right">Available</td> <td class="text-right">Total</td> </tr> </thead> <tbody> <tr> <td>CPUs</td> - <td class="text-right">{{monitor.statistics.cpus_total_usage | number}}</td> - <td class="text-right">{{state.resources.cpus | number}}</td> + <td class="text-right"> + {{monitor.statistics.cpus_total_usage | number}} + </td> + <td class="text-right"> + {{state.allocated_resources.cpus | number}} + </td> + <td class="text-right"> + {{state.resources.cpus - state.allocated_resources.cpus | number}} + </td> + <td class="text-right"> + {{state.resources.cpus | number}} + </td> </tr> <tr> <td>GPUs</td> - <td class="text-right">N/A</td> - <td class="text-right">{{state.resources.gpus | number}}</td> + <td class="text-right"> + N/A + </td> + <td class="text-right"> + {{state.allocated_resources.gpus | number}} + </td> + <td class="text-right"> + {{state.resources.gpus - state.allocated_resources.gpus | number}} + </td> + <td class="text-right"> + {{state.resources.gpus | number}} + </td> </tr> <tr> <td>Memory</td> - <td class="text-right">{{monitor.statistics.mem_rss_bytes | dataSize}}</td> + <td class="text-right"> + {{monitor.statistics.mem_rss_bytes | dataSize}} + </td> + <td class="text-right"> + {{state.allocated_resources.mem * (1024 * 1024) | dataSize}} + </td> + <td class="text-right"> + {{(state.resources.mem - state.allocated_resources.mem) * (1024 * 1024) | dataSize}} + </td> <td class="text-right"> {{state.resources.mem * (1024 * 1024) | dataSize}} </td> </tr> <tr> <td>Disk</td> - <td class="text-right">{{monitor.statistics.disk_used_bytes | dataSize}}</td> + <td class="text-right"> + {{monitor.statistics.disk_used_bytes | dataSize}} + </td> + <td class="text-right"> + {{state.allocated_resources.disk * (1024 * 1024) | dataSize}} + </td> + <td class="text-right"> + {{(state.resources.disk - state.allocated_resources.disk) * (1024 * 1024) | dataSize}} + </td> <td class="text-right"> {{state.resources.disk * (1024 * 1024) | dataSize}} </td> http://git-wip-us.apache.org/repos/asf/mesos/blob/00569bfc/src/webui/master/static/js/controllers.js ---------------------------------------------------------------------- diff --git a/src/webui/master/static/js/controllers.js b/src/webui/master/static/js/controllers.js index fa4742a..a021962 100644 --- a/src/webui/master/static/js/controllers.js +++ b/src/webui/master/static/js/controllers.js @@ -645,6 +645,21 @@ } }); + $scope.state.allocated_resources = {}; + $scope.state.allocated_resources.cpus = 0; + $scope.state.allocated_resources.gpus = 0; + $scope.state.allocated_resources.mem = 0; + $scope.state.allocated_resources.disk = 0; + + // Currently the agent does not expose the total allocated + // resources across all frameworks, so we sum manually. + _.each($scope.state.frameworks, function(framework) { + $scope.state.allocated_resources.cpus += framework.cpus; + $scope.state.allocated_resources.gpus += framework.gpus; + $scope.state.allocated_resources.mem += framework.mem; + $scope.state.allocated_resources.disk += framework.disk; + }); + $('#agent').show(); }) .error(function(reason) {
