mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-08 02:38:51 +00:00
Fetching agents summary
This commit is contained in:
parent
0a3fc30d61
commit
becb1fe682
@ -154,6 +154,25 @@ function ($scope, $location, $rootScope, appState,
|
||||
}
|
||||
};
|
||||
|
||||
const getSummary = async () => {
|
||||
try {
|
||||
const data = await apiReq.request('GET', '/agents/summary', { });
|
||||
|
||||
if(data && data.data && data.data.data){
|
||||
$scope.agentsCountActive = data.data.data.Active;
|
||||
$scope.agentsCountDisconnected = data.data.data.Disconnected;
|
||||
$scope.agentsCountNeverConnected = data.data.data['Never connected'];
|
||||
$scope.agentsCountTotal = data.data.data.Total;
|
||||
$scope.agentsCoverity = (data.data.data.Active / data.data.data.Total) * 100;
|
||||
} else {
|
||||
throw new Error('Error fetching /agents/summary from Wazuh API');
|
||||
}
|
||||
return;
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
const loadConfiguration = async () => {
|
||||
try {
|
||||
const configuration = wazuhConfig.getConfig();
|
||||
@ -161,17 +180,7 @@ function ($scope, $location, $rootScope, appState,
|
||||
$scope.wzMonitoringEnabled = !!configuration['wazuh.monitoring.enabled'];
|
||||
|
||||
if(!$scope.wzMonitoringEnabled){
|
||||
const data = await apiReq.request('GET', '/agents/summary', { });
|
||||
|
||||
if(data && data.data && data.data.data){
|
||||
$scope.agentsCountActive = data.data.data.Active;
|
||||
$scope.agentsCountDisconnected = data.data.data.Disconnected;
|
||||
$scope.agentsCountNeverConnected = data.data.data['Never connected'];
|
||||
$scope.agentsCountTotal = data.data.data.Total;
|
||||
$scope.agentsCoverity = (data.data.data.Active / data.data.data.Total) * 100;
|
||||
} else {
|
||||
throw new Error('Error fetching /agents/summary from Wazuh API');
|
||||
}
|
||||
await getSummary();
|
||||
}
|
||||
|
||||
return;
|
||||
@ -184,6 +193,7 @@ function ($scope, $location, $rootScope, appState,
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
|
||||
await Promise.all([
|
||||
loadPciAndGDPR(),
|
||||
loadConfiguration()
|
||||
@ -191,13 +201,19 @@ function ($scope, $location, $rootScope, appState,
|
||||
|
||||
$scope.switchTab($scope.tab,true);
|
||||
|
||||
if($scope.tab && $scope.tab === 'welcome'){
|
||||
await getSummary();
|
||||
}
|
||||
|
||||
if(!$scope.$$phase) $scope.$digest()
|
||||
|
||||
return;
|
||||
|
||||
} catch (error) {
|
||||
errorHandler.handle(error, 'Overview (init)')
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user