From d8037f0c285204bd2e3da8f56ef14a0c16235f5a Mon Sep 17 00:00:00 2001 From: jesmg Date: Thu, 28 Jul 2016 12:45:20 +0000 Subject: [PATCH] Manager tab: stats and status column --- public/controllers/manager.js | 42 ++++++++++++++++++++++++++++- public/templates/manager.html | 51 +++++++++++++++++++++-------------- 2 files changed, 72 insertions(+), 21 deletions(-) diff --git a/public/controllers/manager.js b/public/controllers/manager.js index ac2c28bd9..d851212e8 100644 --- a/public/controllers/manager.js +++ b/public/controllers/manager.js @@ -3,12 +3,17 @@ var kuf = require('plugins/wazuh/utils/kibanaUrlFormatter.js'); // Require config var app = require('ui/modules').get('app/wazuh', []); -app.controller('managerController', function ($scope, $route, $q, alertify, sharedProperties, $location, $sce, DataFactory, tabProvider, $filter) { +app.controller('managerController', function ($scope, $route, $q, alertify, sharedProperties, $location, $sce, DataFactory, tabProvider, $filter, $http) { //Initialisation $scope.load = true; $scope.menuNavItem = 'manager'; $scope.submenuNavItem = 'general'; + $scope.stats = []; + $scope.stats['/top/agent'] = '-'; + $scope.stats['/overview/alerts'] = {"alerts":0,"ip":"-","group":"-"}; + $scope.stats['/overview/fim'] = {"alerts":0,"agent":"-","file":"-"}; + $scope.pageId = (Math.random().toString(36).substring(3)); tabProvider.register($scope.pageId); @@ -117,6 +122,39 @@ app.controller('managerController', function ($scope, $route, $q, alertify, shar return output; }; + var loadStats = function () { + $http.get('/api/wazuh-stats/top/agent') + .success(function (data) { + $scope.stats['/top/agent'] = data.data; + }) + .error(function (data) { + var error = []; + error['html'] = "Error getting top agent stats: Could not connect with Elasticsearch."; + error.message = "Error getting top agent stats: Could not connect with Elasticsearch."; + printError(error); + }); + $http.get('/api/wazuh-stats/overview/alerts') + .success(function (data) { + $scope.stats['/overview/alerts'] = data.data; + }) + .error(function (data) { + var error = []; + error['html'] = "Error getting alerts overview stats: Could not connect with Elasticsearch."; + error.message = "Error getting alerts overview stats: Could not connect with Elasticsearch."; + printError(error); + }); + $http.get('/api/wazuh-stats/overview/syscheck') + .success(function (data) { + $scope.stats['/overview/fim'] = data.data; + }) + .error(function (data) { + var error = []; + error['html'] = "Error getting FIM overview stats: Could not connect with Elasticsearch."; + error.message = "Error getting FIM overview stats: Could not connect with Elasticsearch."; + printError(error); + }); + }; + var load = function () { DataFactory.getAndClean('get', '/manager/status', {}) .then(function (data) { @@ -127,6 +165,7 @@ app.controller('managerController', function ($scope, $route, $q, alertify, shar $scope.agentsCountDisconnected = data.data.disconnected; $scope.agentsCountNeverConnected = data.data.neverConnected; $scope.agentsCountTotal = data.data.total; + loadStats(); $scope.load = false; }, printError); }, printError); @@ -139,6 +178,7 @@ app.controller('managerController', function ($scope, $route, $q, alertify, shar $scope.$on("$destroy", function () { //angular.forEach(objectsArray, DataFactory.clean(value)); tabProvider.clean($scope.pageId); + $scope.stats.length = 0; }); }); diff --git a/public/templates/manager.html b/public/templates/manager.html index a9e34272f..f0f58069d 100644 --- a/public/templates/manager.html +++ b/public/templates/manager.html @@ -26,12 +26,23 @@ - - {{daemon.daemon}}
-
- +
+ + +

Manager status

+ + +

{{daemon.daemon}}

+

+
+ +
+
+
+
+
@@ -58,8 +69,8 @@ -

Last agent connected

-

vpc-agent-ubuntu

+

Top reporting agent (Today)

+

{{stats['/top/agent']}}

@@ -70,21 +81,21 @@
-

Alerts overview

+

Alerts overview (Today stats)

-

Today alerts

-

127,345

+

Alerts

+

{{stats['/overview/alerts'].alerts}}

Top source ip

-

256.56.122.14

+

{{stats['/overview/alerts'].ip}}

Top alert group

-

ssh_intrusion

+

{{stats['/overview/alerts'].group}}

@@ -95,21 +106,21 @@
-

FIM overview

+

FIM overview (Today stats)

-

Today FIM alerts

-

786

-
- - -

Last file change

-

/etc/password

+

FIM alerts

+

{{stats['/overview/fim'].alerts}}

Most agent FIM changes

-

vpc-manager-newjersey

+

{{stats['/overview/fim'].agent}}

+
+ + +

Most file change

+

{{stats['/overview/fim'].file}}