From 5d6876eb813ff83b499bd2910c8626cb5a229119 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 9 Sep 2016 14:46:33 -0400 Subject: [PATCH] Remove old metrics dashboard It only applies to a single instance, making it fairly useless --- endpoints/realtime.py | 51 +-------------- static/directives/ps-usage-graph.html | 75 ----------------------- static/js/directives/ui/ps-usage-graph.js | 50 --------------- static/js/pages/superuser.js | 5 -- static/partials/super-user.html | 9 --- 5 files changed, 1 insertion(+), 189 deletions(-) delete mode 100644 static/directives/ps-usage-graph.html delete mode 100644 static/js/directives/ui/ps-usage-graph.js diff --git a/endpoints/realtime.py b/endpoints/realtime.py index 23d41ee28..b1e5151b2 100644 --- a/endpoints/realtime.py +++ b/endpoints/realtime.py @@ -4,63 +4,14 @@ import json from flask import request, Blueprint, abort, Response from flask.ext.login import current_user from auth.auth import require_session_login -from endpoints.common import route_show_if -from app import app, userevents -from auth.permissions import SuperUserPermission +from app import userevents from data.userevent import CannotReadUserEventsException -import features -import psutil -import time - logger = logging.getLogger(__name__) realtime = Blueprint('realtime', __name__) -@realtime.route("/ps") -@route_show_if(features.SUPER_USERS) -@require_session_login -def ps(): - if not SuperUserPermission().can(): - abort(403) - - def generator(): - while True: - build_status = {} - try: - builder_data = app.config['HTTPCLIENT'].get('http://localhost:8686/status', timeout=1) - if builder_data.status_code == 200: - build_status = json.loads(builder_data.text) - except: - pass - - try: - data = { - 'count': { - 'cpu': psutil.cpu_percent(interval=1, percpu=True), - 'virtual_mem': psutil.virtual_memory(), - 'swap_mem': psutil.swap_memory(), - 'connections': len(psutil.net_connections()), - 'processes': len(psutil.pids()), - 'network': psutil.net_io_counters() - }, - 'build': build_status - } - except psutil.AccessDenied: - data = {} - - json_string = json.dumps(data) - yield 'data: %s\n\n' % json_string - time.sleep(1) - - try: - return Response(generator(), mimetype="text/event-stream") - except: - pass - - - @realtime.route("/user/") @require_session_login def index(): diff --git a/static/directives/ps-usage-graph.html b/static/directives/ps-usage-graph.html deleted file mode 100644 index a02eaa83c..000000000 --- a/static/directives/ps-usage-graph.html +++ /dev/null @@ -1,75 +0,0 @@ -
- -
-
- Cannot load build system status. Please restart your container. -
-
-
-

Build Queue

-
- Running Jobs: {{ data.build.running_total }} | Total Jobs: {{ data.build.job_total }} -
-
-
- -
-

Local Build Workers

-
- Local Workers: {{ data.build.workers }} | Working: {{ data.build.running_local }} -
-
-
-
-
- - -
-

CPU Usage %

-
-
- -
-

Process Count

-
-
- -
-

Virtual Memory %

-
-
- -
-

Swap Memory

-
-
- -
-

Network Connections

-
-
- -
-

Network Usage (Bytes)

-
-
-
diff --git a/static/js/directives/ui/ps-usage-graph.js b/static/js/directives/ui/ps-usage-graph.js deleted file mode 100644 index 7e1629b34..000000000 --- a/static/js/directives/ui/ps-usage-graph.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * An element which displays charts and graphs representing the current installation of the - * application. This control requires superuser access and *must be disabled when not visible*. - */ -angular.module('quay').directive('psUsageGraph', function () { - var directiveDefinitionObject = { - priority: 0, - templateUrl: '/static/directives/ps-usage-graph.html', - replace: false, - transclude: false, - restrict: 'C', - scope: { - 'isEnabled': '=isEnabled' - }, - controller: function($scope, $element) { - $scope.counter = -1; - $scope.data = null; - - var source = null; - - var connect = function() { - if (source) { return; } - source = new EventSource('/realtime/ps'); - source.onmessage = function(e) { - $scope.$apply(function() { - $scope.counter++; - $scope.data = JSON.parse(e.data); - }); - }; - }; - - var disconnect = function() { - if (!source) { return; } - source.close(); - source = null; - }; - - $scope.$watch('isEnabled', function(value) { - if (value) { - connect(); - } else { - disconnect(); - } - }); - - $scope.$on("$destroy", disconnect); - } - }; - return directiveDefinitionObject; -}); \ No newline at end of file diff --git a/static/js/pages/superuser.js b/static/js/pages/superuser.js index 1132f27a7..f5b6d19a2 100644 --- a/static/js/pages/superuser.js +++ b/static/js/pages/superuser.js @@ -29,15 +29,10 @@ $scope.pollChannel = null; $scope.logsScrolled = false; $scope.csrf_token = encodeURIComponent(window.__token); - $scope.dashboardActive = false; $scope.currentConfig = null; $scope.serviceKeysActive = false; $scope.takeOwnershipInfo = null; - $scope.setDashboardActive = function(active) { - $scope.dashboardActive = active; - }; - $scope.configurationSaved = function(config) { $scope.currentConfig = config; $scope.requiresRestart = true; diff --git a/static/partials/super-user.html b/static/partials/super-user.html index 56d83adeb..ab640736b 100644 --- a/static/partials/super-user.html +++ b/static/partials/super-user.html @@ -28,10 +28,6 @@ tab-target="#servicekeys" tab-init="loadServiceKeys()"> - - - @@ -59,11 +55,6 @@
- -
-
-
-