From 070145b72a7c647ceb00aab292ae012e9df4d7a2 Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Thu, 23 Sep 2021 17:40:30 -0300 Subject: [PATCH 1/8] feat(agents): Added agent status on agents view. --- .../js/controllers/agents/agents/agents.html | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html index e796f628d..498e7c0c9 100644 --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html @@ -3,7 +3,6 @@ layout-align="start space-around">
-
@@ -96,9 +95,49 @@
- + + + Agents status + + + + + +
+
+ + Agents status + +
+
+
+
+

Total

+

{{agentsCountTotal}}

+
+
+
+

Active

+

{{agentsCountActive}}

+
+
+

Disconnected

+

{{agentsCountDisconnected}}

+
+
+

Never connected

+

{{agentsCountNeverConnected}}

+
+
+

Agents coverage

+

{{(agentsCoverity | number:2)}}%

+
+
+
+
+
From 507154e9a840b19978ec1f101f4b9ac48f16f610 Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Tue, 28 Sep 2021 09:51:24 -0300 Subject: [PATCH 2/8] feat(agents): Added LinearChart of Agent status on Agents view. --- .../js/controllers/agents/agents/agents.html | 82 +++++++++---------- .../controllers/agents/agents/agentsCtrl.js | 82 +++++++++++++++++-- 2 files changed, 117 insertions(+), 47 deletions(-) mode change 100644 => 100755 SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html mode change 100644 => 100755 SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html old mode 100644 new mode 100755 index 498e7c0c9..76bf162af --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html @@ -97,51 +97,52 @@ - - - Agents status - - + + + Agents status + + + - - -
-
- - Agents status - -
-
-
-
-

Total

-

{{agentsCountTotal}}

-
-
-
-

Active

-

{{agentsCountActive}}

-
-
-

Disconnected

-

{{agentsCountDisconnected}}

-
-
-

Never connected

-

{{agentsCountNeverConnected}}

-
-
-

Agents coverage

-

{{(agentsCoverity | number:2)}}%

+ +
+ + + Agents status + +
+
+
+
+

Total

+

{{agentsCountTotal}}

+
+
+
+

Active

+

{{agentsCountActive}}

+
+
+

Disconnected

+

{{agentsCountDisconnected}}

+
+
+

Never connected

+

{{agentsCountNeverConnected}}

+
+
+

Agents coverage

+

{{(agentsCoverity | number:2)}}%

+
-
- - + + +
-
+
- + - Add new agent diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js old mode 100644 new mode 100755 index 6a46b43cb..85385f89e --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js @@ -1,6 +1,6 @@ /* * Wazuh app - Agents controller - * Copyright (C) 2015-2019 Wazuh, Inc. + * Copyright (C) 2015-2021 Wazuh, Inc. * * This program is free software you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,8 +13,9 @@ define([ '../../module', '../../../services/visualizations/search/search-handler', + '../../../services/visualizations/chart/linear-chart', 'FileSaver' -], function(app, SearchHandler) { +], function(app, SearchHandler, LinearChart) { 'use strict' class Agents { @@ -26,7 +27,13 @@ define([ * @param {Object} $state * @param {Object} $notificationService * @param {Object} $requestService + * @param $csvRequestService + * @param $tableFilterService * @param {Object} agentData + * @param clusterInfo + * @param $mdDialog + * @param $groupHandler + * @param $dateDiffService */ constructor( @@ -44,7 +51,7 @@ define([ $groupHandler, $dateDiffService ) { - this.scope = $scope + this.scope = $scope; this.submittedTokenModel = $urlTokenModel.getSubmittedTokenModel() this.submittedTokenModel.set('activeAgentToken', '-') this.currentDataService = $currentDataService @@ -140,8 +147,8 @@ define([ : [] } - if (this.clusterInfo && - this.clusterInfo.enabled === 'yes' && + if (this.clusterInfo && + this.clusterInfo.enabled === 'yes' && this.clusterInfo.running === 'yes' ) { this.scope.searchBarModel.node_name = nodes || [] @@ -160,7 +167,7 @@ define([ 'loadingSearch' ) - this.scope.$applyAsync() + this.scope.expandChartAgent = false; } /** @@ -179,6 +186,7 @@ define([ this.scope.versionModel = 'all' this.scope.downloadCsv = () => this.downloadCsv() this.scope.$on('$destroy', () => { + this.linearChartAgent.destroy(); this.topAgent.destroy() }) this.scope.reloadList = () => this.reloadList() @@ -196,6 +204,7 @@ define([ this.scope.loadCharts = id => { setTimeout(() => { + // eslint-disable-next-line no-undef const chart = new Chart(document.getElementById(id), { type: 'doughnut', data: { @@ -225,6 +234,67 @@ define([ chart.update() }, 250) } + + this.scope.getAgentStatus = () => { + this.scope.wzMonitoringEnabled = true; + + //Filters for agents Status + try { + this.clusOrMng = Object.keys( + this.currentDataService.getFilters()[0] + )[0] + + if (this.clusOrMng === 'manager.name') { + this.mngName = this.currentDataService.getFilters()[0][ + 'manager.name' + ] + this.agentsStatusFilter = `manager.name=${this.mngName} index=wazuh-monitoring*` + } else { + this.clusName = this.currentDataService.getFilters()[0][ + 'cluster.name' + ] + this.agentsStatusFilter = `cluster.name=${this.clusName} index=wazuh-monitoring*` + } + // eslint-disable-next-line no-empty + } catch (error) {} + + this.spanTime = '15m' + this.linearChartAgent = new LinearChart( + `agentStatusChartHistory`, + `${this.agentsStatusFilter} id!=000 status=* | timechart span=${this.spanTime} cont=FALSE count by status usenull=f`, + `agentStatusChart`, + this.scope, + {customAxisTitleX: "Time span"} + ); + } + + /** + * Expands the visualizations + * @param {Number} i + * @param {String} id + */ + this.scope.expand = id => { + this.scope.expandChartAgent = !this.scope.expandChartAgent; + let vis = $( + "#" + id + " .panel-body .splunk-view .shared-reportvisualizer" + ); + this.scope.expandChartAgent + ? vis.css("height", "calc(100vh - 200px)") + : vis.css("height", "250px"); + + let vis_header = $(".wz-headline-title"); + vis_header.dblclick(e => { + if (this.scope.expandChartAgent) { + this.scope.expandChartAgent = !this.scope.expandChartAgent; + this.scope.expandChartAgent + ? vis.css("height", "calc(100vh - 200px)") + : vis.css("height", "250px"); + this.scope.$applyAsync(); + } else { + e.preventDefault(); + } + }); + }; } /** From da93c90ed9f371754c68b4bd0af4f5c50b377082 Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Tue, 28 Sep 2021 10:37:10 -0300 Subject: [PATCH 3/8] feat(agents): Rollback $applyAsync(). --- .../appserver/static/js/controllers/agents/agents/agentsCtrl.js | 1 + 1 file changed, 1 insertion(+) diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js index 85385f89e..110905d22 100755 --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js @@ -168,6 +168,7 @@ define([ ) this.scope.expandChartAgent = false; + this.scope.$applyAsync(); } /** From f70dbb947cedadcb61e68ac56c32471eeae52e65 Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Tue, 28 Sep 2021 10:38:53 -0300 Subject: [PATCH 4/8] feat(agents): Prettier. --- .../controllers/agents/agents/agentsCtrl.js | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js index 110905d22..314471465 100755 --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js @@ -239,39 +239,37 @@ define([ this.scope.getAgentStatus = () => { this.scope.wzMonitoringEnabled = true; - //Filters for agents Status try { this.clusOrMng = Object.keys( - this.currentDataService.getFilters()[0] - )[0] + this.currentDataService.getFilters()[0] + )[0]; - if (this.clusOrMng === 'manager.name') { + if (this.clusOrMng === "manager.name") { this.mngName = this.currentDataService.getFilters()[0][ - 'manager.name' - ] - this.agentsStatusFilter = `manager.name=${this.mngName} index=wazuh-monitoring*` + "manager.name" + ]; + this.agentsStatusFilter = `manager.name=${this.mngName} index=wazuh-monitoring*`; } else { this.clusName = this.currentDataService.getFilters()[0][ - 'cluster.name' - ] - this.agentsStatusFilter = `cluster.name=${this.clusName} index=wazuh-monitoring*` + "cluster.name" + ]; + this.agentsStatusFilter = `cluster.name=${this.clusName} index=wazuh-monitoring*`; } // eslint-disable-next-line no-empty } catch (error) {} - this.spanTime = '15m' + this.spanTime = "15m"; this.linearChartAgent = new LinearChart( - `agentStatusChartHistory`, - `${this.agentsStatusFilter} id!=000 status=* | timechart span=${this.spanTime} cont=FALSE count by status usenull=f`, - `agentStatusChart`, - this.scope, - {customAxisTitleX: "Time span"} + `agentStatusChartHistory`, + `${this.agentsStatusFilter} id!=000 status=* | timechart span=${this.spanTime} cont=FALSE count by status usenull=f`, + `agentStatusChart`, + this.scope, + { customAxisTitleX: "Time span" } ); - } + }; /** * Expands the visualizations - * @param {Number} i * @param {String} id */ this.scope.expand = id => { From c0cce91c7dcfa7dde1d528a411fd8c8ad79c06bd Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Tue, 28 Sep 2021 11:30:35 -0300 Subject: [PATCH 5/8] feat(agents): Removed unnecessary md-card with count of status. --- .../js/controllers/agents/agents/agents.html | 32 +------------------ .../controllers/agents/agents/agentsCtrl.js | 2 -- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html index 76bf162af..f5d4d2d96 100755 --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agents.html @@ -98,7 +98,7 @@
- + Agents status @@ -107,36 +107,6 @@
- - Agents status - -
-
-
-
-

Total

-

{{agentsCountTotal}}

-
-
-
-

Active

-

{{agentsCountActive}}

-
-
-

Disconnected

-

{{agentsCountDisconnected}}

-
-
-

Never connected

-

{{agentsCountNeverConnected}}

-
-
-

Agents coverage

-

{{(agentsCoverity | number:2)}}%

-
-
-
-
diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js index 314471465..6ed9876ce 100755 --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js @@ -237,8 +237,6 @@ define([ } this.scope.getAgentStatus = () => { - this.scope.wzMonitoringEnabled = true; - try { this.clusOrMng = Object.keys( this.currentDataService.getFilters()[0] From 8b5ba8f8feef885fbb3f39450382f3433095cf9d Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Tue, 28 Sep 2021 13:53:56 -0300 Subject: [PATCH 6/8] doc(changelog): Updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba8262e6e..73dad87dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to the Wazuh app for Splunk project will be documented in th - Support for Splunk v8.1.4 - Added new source type selector to customize queries used by dashboards [#1104](https://github.com/wazuh/wazuh-splunk/pull/1104) - Added quick settings to improve the view and selection of API, index, and source type [#1107](https://github.com/wazuh/wazuh-splunk/pull/1107) +- Added Agent status visualization on Agents main view [#1140](https://github.com/wazuh/wazuh-splunk/pull/1140) ### Fixed From ddc2bca6e19d30fd61f75f943290afcd31586fc6 Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Wed, 29 Sep 2021 12:01:21 -0300 Subject: [PATCH 7/8] fix(modal-download): Changed zIndex for this modal, fixing overlap --- .../appserver/static/js/controllers/agents/agents/agentsCtrl.js | 2 ++ SplunkAppForWazuh/appserver/static/js/dashboardMain.js | 2 ++ 2 files changed, 4 insertions(+) mode change 100644 => 100755 SplunkAppForWazuh/appserver/static/js/dashboardMain.js diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js index 6ed9876ce..602b0a251 100755 --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js @@ -279,6 +279,8 @@ define([ ? vis.css("height", "calc(100vh - 200px)") : vis.css("height", "250px"); + document.querySelectorAll('[role="main"]')[0].style.zIndex = 1000; + let vis_header = $(".wz-headline-title"); vis_header.dblclick(e => { if (this.scope.expandChartAgent) { diff --git a/SplunkAppForWazuh/appserver/static/js/dashboardMain.js b/SplunkAppForWazuh/appserver/static/js/dashboardMain.js old mode 100644 new mode 100755 index 1bd3bf8c1..6ddaa11da --- a/SplunkAppForWazuh/appserver/static/js/dashboardMain.js +++ b/SplunkAppForWazuh/appserver/static/js/dashboardMain.js @@ -142,6 +142,8 @@ define([ ? vis.css('height', 'calc(100vh - 200px)') : vis.css('height', '250px') + document.querySelectorAll('[role="main"]')[0].style.zIndex = 1000; + let vis_header = $('.wz-headline-title') vis_header.dblclick(e => { if (this.scope.expandArray[i]) { From d520a7ef34e79276f039fcd83c24a37d1015f305 Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Wed, 29 Sep 2021 17:25:48 -0300 Subject: [PATCH 8/8] fix(modal-download): Fixed zindex modal. --- .../appserver/static/js/controllers/agents/agents/agentsCtrl.js | 2 +- SplunkAppForWazuh/appserver/static/js/dashboardMain.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js index 602b0a251..3a88194ee 100755 --- a/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js +++ b/SplunkAppForWazuh/appserver/static/js/controllers/agents/agents/agentsCtrl.js @@ -279,7 +279,7 @@ define([ ? vis.css("height", "calc(100vh - 200px)") : vis.css("height", "250px"); - document.querySelectorAll('[role="main"]')[0].style.zIndex = 1000; + document.querySelectorAll('[role="main"]')[0].style.zIndex = this.scope.expandChartAgent ? 900 : ''; let vis_header = $(".wz-headline-title"); vis_header.dblclick(e => { diff --git a/SplunkAppForWazuh/appserver/static/js/dashboardMain.js b/SplunkAppForWazuh/appserver/static/js/dashboardMain.js index 6ddaa11da..268132e54 100755 --- a/SplunkAppForWazuh/appserver/static/js/dashboardMain.js +++ b/SplunkAppForWazuh/appserver/static/js/dashboardMain.js @@ -142,7 +142,7 @@ define([ ? vis.css('height', 'calc(100vh - 200px)') : vis.css('height', '250px') - document.querySelectorAll('[role="main"]')[0].style.zIndex = 1000; + document.querySelectorAll('[role="main"]')[0].style.zIndex = this.scope.expandArray[i] ? 900 : ''; let vis_header = $('.wz-headline-title') vis_header.dblclick(e => {