Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking if cluster is enabled and it's running (monitoring tab) #741

Merged
merged 1 commit into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions public/controllers/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ app.controller('clusterController', function ($scope, $rootScope, $timeout, erro
$scope.search = term => {
$scope.$broadcast('wazuhSearch',{term})
}
const clusterEnabled = appState.getClusterInfo() && appState.getClusterInfo().status === 'enabled';

const clusterEnabled = appState.getClusterInfo() && appState.getClusterInfo().status === 'enabled';
$scope.isClusterEnabled = clusterEnabled;
$scope.isClusterRunning = true;
$location.search('tabView','cluster-monitoring');
$location.search('tab','monitoring')
$location.search('_a',null)
Expand Down Expand Up @@ -156,34 +158,38 @@ app.controller('clusterController', function ($scope, $rootScope, $timeout, erro
rawVisualizations.removeAll();
loadedVisualizations.removeAll();


const status = await apiReq.request('GET','/cluster/status',{});
$scope.status = status.data.data.running;
if($scope.status === 'no') {
$scope.isClusterRunning = false;
throw new Error('Cluster is not running');
}

const data = await Promise.all([
apiReq.request('GET','/cluster/status',{}),
apiReq.request('GET','/cluster/nodes',{}),
apiReq.request('GET','/cluster/config',{}),
apiReq.request('GET','/version',{}),
apiReq.request('GET','/agents',{limit:1}),
apiReq.request('GET','/cluster/healthcheck',{})
]);

const status = data[0]
$scope.status = status.data.data.running;

const nodesCount = data[1].data.data.totalItems
const nodesCount = data[0].data.data.totalItems;
$scope.nodesCount = nodesCount;

const configuration = data[2]
const configuration = data[1];
$scope.configuration = configuration.data.data;

const version = data[3]
const version = data[2];
$scope.version = version.data.data;

const agents = data[4]
const agents = data[3];
$scope.agentsCount = agents.data.data.totalItems - 1;

const health = data[5];
const health = data[4];
$scope.healthCheck = health.data.data;

const nodes = data[1].data.data;
const nodes = data[0].data.data;

nodes.name = $scope.configuration.name;
nodes.master_node = $scope.configuration.node_name;
Expand All @@ -198,7 +204,8 @@ app.controller('clusterController', function ($scope, $rootScope, $timeout, erro
if(!$scope.$$phase) $scope.$digest();
return;
} catch(error) {
errorHandler.handle(error,'Cluster')
$scope.loading = false;
errorHandler.handle(error,'Cluster');
}
}

Expand Down
20 changes: 18 additions & 2 deletions public/templates/manager/monitoring/disabled.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div flex layout="column" ng-controller="clusterController" ng-if="tab === 'monitoring'" ng-show="!isClusterEnabled">
<div flex layout="column" ng-controller="clusterController" ng-if="tab === 'monitoring'" ng-show="!isClusterEnabled || !isClusterRunning">

<!-- Cluster disabled breadcrumbs -->
<div layout="row" layout-align="start center">
Expand Down Expand Up @@ -33,7 +33,7 @@
<!-- End headline -->

<!-- Cluster disabled section -->
<div flex layout="row" layout-align="start start">
<div flex layout="row" layout-align="start start" ng-if="!isClusterEnabled">
<md-card flex class="wz-md-card" flex>
<md-card-content class="wz-text-center">
<i class="fa fa-fw fa-info-circle" aria-hidden="true"></i> <span class="wz-headline-title">Cluster disabled</span>
Expand All @@ -47,4 +47,20 @@
</div>
<!-- End cluster disabled section -->

<!-- Cluster not running section -->
<div flex layout="row" layout-align="start start" ng-if="!isClusterRunning">
<md-card flex class="wz-md-card" flex>
<md-card-content class="wz-text-center">
<i class="fa fa-fw fa-info-circle" aria-hidden="true"></i> <span class="wz-headline-title">Cluster not running</span>
<md-divider class="wz-margin-top-10"></md-divider>
<div layout="column" class="wz-padding-top-10">
<p>
The cluster is enabled but it's not running.
</p>
</div>
</md-card-content>
</md-card>
</div>
<!-- End cluster not running section -->

</div>
2 changes: 1 addition & 1 deletion public/templates/manager/monitoring/monitoring.head
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div flex layout="column" ng-controller="clusterController" ng-if="tab === 'monitoring'" ng-show="isClusterEnabled">
<div flex layout="column" ng-controller="clusterController" ng-if="tab === 'monitoring'" ng-show="isClusterEnabled && isClusterRunning">

<!-- Loading ring -->
<div class='uil-ring-css' ng-show="loading">
Expand Down