Manager tab: stats and status column

This commit is contained in:
jesmg 2016-07-28 12:45:20 +00:00
parent b4d2c53ead
commit d8037f0c28
2 changed files with 72 additions and 21 deletions

View File

@ -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;
});
});

View File

@ -26,12 +26,23 @@
<md-content flex layout="column" ng-if="!load" layout-align="space-around">
<md-content layout="row" layout-padding layout-sm="column" layout-xs="column">
<span ng-repeat="daemon in daemons" layout="row" flex layout-align="space-around center">{{daemon.daemon}} <div ng-class="getDaemonStatusClass(daemon.status)" class="round"></div><md-divider></md-divider></span>
</md-content>
<md-content layout-padding flex layout="row" layout-sm="column" layout-xs="column">
<div flex layout="column">
<md-card>
<md-card-content>
<h3>Manager status</h3>
<span layout="column" ng-repeat="daemon in daemons">
<span layout="row" layout-align="space-between center">
<p>{{daemon.daemon}}</p>
<p class="right-text"><div ng-class="getDaemonStatusClass(daemon.status)" class="round"></div></p>
</span>
<md-divider></md-divider>
</span>
</md-card-content>
</md-card>
</div>
<div flex layout="column">
<md-card>
<md-card-content>
@ -58,8 +69,8 @@
</md-list-item>
<md-divider></md-divider>
<md-list-item>
<p>Last agent connected</p>
<p class="right-text">vpc-agent-ubuntu</p>
<p>Top reporting agent (Today)</p>
<p class="right-text">{{stats['/top/agent']}}</p>
</md-list-item>
<md-divider></md-divider>
</md-list>
@ -70,21 +81,21 @@
<div flex layout="column">
<md-card>
<md-card-content>
<h3>Alerts overview</h3>
<h3>Alerts overview (Today stats)</h3>
<md-list>
<md-list-item>
<p>Today alerts</p>
<p class="right-text">127,345</p>
<p>Alerts</p>
<p class="right-text">{{stats['/overview/alerts'].alerts}}</p>
</md-list-item>
<md-divider></md-divider>
<md-list-item>
<p>Top source ip</p>
<p class="right-text">256.56.122.14</p>
<p class="right-text">{{stats['/overview/alerts'].ip}}</p>
</md-list-item>
<md-divider></md-divider>
<md-list-item>
<p>Top alert group</p>
<p class="right-text">ssh_intrusion</p>
<p class="right-text">{{stats['/overview/alerts'].group}}</p>
</md-list-item>
<md-divider></md-divider>
</md-list>
@ -95,21 +106,21 @@
<div flex layout="column">
<md-card>
<md-card-content>
<h3>FIM overview</h3>
<h3>FIM overview (Today stats)</h3>
<md-list>
<md-list-item>
<p>Today FIM alerts</p>
<p class="right-text">786</p>
</md-list-item>
<md-divider></md-divider>
<md-list-item>
<p>Last file change</p>
<p class="right-text">/etc/password</p>
<p>FIM alerts</p>
<p class="right-text">{{stats['/overview/fim'].alerts}}</p>
</md-list-item>
<md-divider></md-divider>
<md-list-item>
<p>Most agent FIM changes</p>
<p class="right-text">vpc-manager-newjersey</p>
<p class="right-text">{{stats['/overview/fim'].agent}}</p>
</md-list-item>
<md-divider></md-divider>
<md-list-item>
<p>Most file change</p>
<p class="right-text">{{stats['/overview/fim'].file}}</p>
</md-list-item>
<md-divider></md-divider>
</md-list>