diff --git a/pandora_console/include/ajax/general_tactical_view.ajax.php b/pandora_console/include/ajax/general_tactical_view.ajax.php
index 3b4865421e..99c9b09a57 100644
--- a/pandora_console/include/ajax/general_tactical_view.ajax.php
+++ b/pandora_console/include/ajax/general_tactical_view.ajax.php
@@ -66,7 +66,7 @@ if (is_ajax()) {
if (class_exists($class) === true) {
$instance = new $class();
if ($instance->ajaxMethod($method) === true) {
- $instance->{$method}();
+ echo $instance->{$method}();
} else {
$instance->error('Unavailable method.');
}
diff --git a/pandora_console/include/javascript/general_tactical_view.js b/pandora_console/include/javascript/general_tactical_view.js
new file mode 100644
index 0000000000..ee9aae65f2
--- /dev/null
+++ b/pandora_console/include/javascript/general_tactical_view.js
@@ -0,0 +1,72 @@
+/* global $ */
+$(document).ready(function() {
+ $.ajax({
+ url: "ajax.php",
+ data: {
+ page: "include/ajax/general_tactical_view.ajax",
+ method: "getEventsGraph",
+ class: "Events"
+ },
+ type: "POST",
+ success: function(data) {
+ $("#events-last-24").html(data);
+ }
+ });
+
+ $.ajax({
+ url: "ajax.php",
+ data: {
+ page: "include/ajax/general_tactical_view.ajax",
+ method: "getEventsCriticalityGraph",
+ class: "Events"
+ },
+ type: "POST",
+ success: function(data) {
+ $("#events-criticality").html(data);
+ }
+ });
+
+ $.ajax({
+ url: "ajax.php",
+ data: {
+ page: "include/ajax/general_tactical_view.ajax",
+ method: "getEventsStatusValidateGraph",
+ class: "Events"
+ },
+ type: "POST",
+ success: function(data) {
+ $("#events-status-validate").html(data);
+ }
+ });
+
+ $.ajax({
+ url: "ajax.php",
+ data: {
+ page: "include/ajax/general_tactical_view.ajax",
+ method: "getEventsStatusValidateGraph",
+ class: "Events"
+ },
+ type: "POST",
+ success: function(data) {
+ $("#events-status-pending-validate").html(data);
+ }
+ });
+});
+
+function autoRefresh(interval, id, method, php_class) {
+ setInterval(() => {
+ $.ajax({
+ url: "ajax.php",
+ data: {
+ page: "include/ajax/general_tactical_view.ajax",
+ method: method,
+ class: php_class
+ },
+ type: "POST",
+ success: function(data) {
+ var content = $(data).html();
+ $("#" + id).html(content);
+ }
+ });
+ }, interval);
+}
diff --git a/pandora_console/include/lib/TacticalView/Element.php b/pandora_console/include/lib/TacticalView/Element.php
index ed0c7c78d6..b7c756fb39 100644
--- a/pandora_console/include/lib/TacticalView/Element.php
+++ b/pandora_console/include/lib/TacticalView/Element.php
@@ -54,7 +54,21 @@ class Element
*
* @var integer
*/
- protected $interval;
+ public $interval;
+
+ /**
+ * Agent of automonitoritation
+ *
+ * @var array
+ */
+ protected $monitoringAgent;
+
+ /**
+ * Refresh config for async method.
+ *
+ * @var array
+ */
+ public $refreshConfig = [];
/**
@@ -68,6 +82,11 @@ class Element
$this->interval = 0;
$this->title = __('Default element');
$this->ajaxController = $ajax_controller;
+ $agent = agents_get_agents(['nombre' => 'pandora.internals']);
+ if (is_array($agent) === true && count($agent) > 0) {
+ $this->monitoringAgent = $agent[0];
+ }
+
}
@@ -116,4 +135,65 @@ class Element
}
+ /**
+ * Return a valur from Module of monitoring.
+ *
+ * @param string $moduleName Name of module value.
+ * @param integer $dateInit Date init for filter.
+ * @param integer $dateEnd Date end for filter.
+ *
+ * @return array Array of module data.
+ */
+ protected function valueMonitoring(string $moduleName, int $dateInit=0, int $dateEnd=0):array
+ {
+ if (empty($this->monitoringAgent) === false) {
+ $module = modules_get_agentmodule_id(io_safe_input($moduleName), $this->monitoringAgent['id_agente']);
+ if (is_array($module) === true && key_exists('id_agente_modulo', $module) === true) {
+ if ($dateInit === 0 && $dateEnd === 0) {
+ $value = modules_get_last_value($module['id_agente_modulo']);
+ $rawData = [['datos' => $value]];
+ } else {
+ $rawData = modules_get_raw_data($module['id_agente_modulo'], $dateInit, $dateEnd);
+ }
+
+ return $rawData;
+ } else {
+ return [['datos' => 0]];
+ }
+
+ return [['datos' => 0]];
+ } else {
+ return [['datos' => 0]];
+ }
+ }
+
+
+ /**
+ * Simple image loading for async functions.
+ *
+ * @return string
+ */
+ public static function loading():string
+ {
+ return html_print_div(
+ [
+ 'content' => '',
+ 'class' => 'spinner-fixed inherit',
+ ],
+ true
+ );
+ }
+
+
+ /**
+ * Return the name of class
+ *
+ * @return string
+ */
+ public static function nameClass():string
+ {
+ return static::class;
+ }
+
+
}
diff --git a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php
index 42f351f56d..3bc2e45246 100644
--- a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php
+++ b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php
@@ -45,6 +45,7 @@ class GeneralTacticalView
public function __construct()
{
ui_require_css_file('general_tactical_view');
+ ui_require_javascript_file('general_tactical_view');
$this->elements = $this->instanceElements();
}
@@ -106,13 +107,37 @@ class GeneralTacticalView
*/
public function render():void
{
+ $data = [];
+ $data['javascript'] = $this->javascript();
+ $data = array_merge($data, $this->elements);
View::render(
'tacticalView/view',
- $this->elements
+ $data
);
}
+ /**
+ * Function for print js embedded in html.
+ *
+ * @return string
+ */
+ public function javascript():string
+ {
+ $js = '';
+ return $js;
+ }
+
+
/**
* Return the welcome message.
*
diff --git a/pandora_console/include/lib/TacticalView/elements/Agents.php b/pandora_console/include/lib/TacticalView/elements/Agents.php
index eef1264334..d3061599f6 100644
--- a/pandora_console/include/lib/TacticalView/elements/Agents.php
+++ b/pandora_console/include/lib/TacticalView/elements/Agents.php
@@ -47,10 +47,11 @@ class Agents extends Element
*/
public function getTotalAgents():string
{
- // TODO connect to automonitorization.
+ $value = $this->valueMonitoring('total_agents');
+ $total = round($value[0]['datos']);
return html_print_div(
[
- 'content' => '9.999.999',
+ 'content' => $total,
'class' => 'text-l',
'style' => 'margin: 0px 10px 10px 10px;',
],
@@ -66,10 +67,11 @@ class Agents extends Element
*/
public function getAlerts():string
{
- // TODO connect to automonitorization.
+ $value = $this->valueMonitoring('triggered_alerts_24h');
+ $total = round($value[0]['datos']);
return html_print_div(
[
- 'content' => '9.999.999',
+ 'content' => $total,
'class' => 'text-l',
'style' => 'margin: 0px 10px 10px 10px;',
],
@@ -105,7 +107,10 @@ class Agents extends Element
'columns' => $columns,
'column_names' => $columnNames,
'ajax_url' => $this->ajaxController,
- 'no-filtered' => [-1],
+ 'no_sortable_columns' => [
+ 0,
+ 1,
+ ],
'ajax_data' => [
'method' => 'getGroups',
'class' => static::class,
@@ -125,9 +130,9 @@ class Agents extends Element
/**
* Return top 20 groups with more agents for ajax datatable.
*
- * @return void
+ * @return string
*/
- public function getGroups():void
+ public function getGroups():string
{
global $config;
@@ -195,26 +200,25 @@ class Agents extends Element
$total = db_get_num_rows($sql_count);
- echo json_encode(
+ // Capture output.
+ $response = ob_get_clean();
+
+ return json_encode(
[
'data' => $rows,
'recordsTotal' => $total,
'recordsFiltered' => $total,
]
);
-
- // Capture output.
- $response = ob_get_clean();
} catch (Exception $e) {
- echo json_encode(['error' => $e->getMessage()]);
- exit;
+ return json_encode(['error' => $e->getMessage()]);
}
json_decode($response);
if (json_last_error() === JSON_ERROR_NONE) {
- echo $response;
+ return $response;
} else {
- echo json_encode(
+ return json_encode(
[
'success' => false,
'error' => $response,
@@ -279,16 +283,71 @@ class Agents extends Element
*/
public function getStatusGraph():string
{
- // TODO Find the method for calculate status in agents.
- $labels = [];
- $data = [];
- foreach ([] as $key => $row) {
- if (empty($row['alias']) === true) {
- continue;
+ $agents = agents_get_agents(
+ false,
+ [
+ 'id_agente',
+ 'id_grupo',
+ 'nombre',
+ 'alias',
+ 'id_os',
+ 'ultimo_contacto',
+ 'intervalo',
+ 'comentarios description',
+ 'quiet',
+ 'normal_count',
+ 'warning_count',
+ 'critical_count',
+ 'unknown_count',
+ 'notinit_count',
+ 'total_count',
+ 'fired_count',
+ 'ultimo_contacto_remoto',
+ 'remote',
+ 'agent_version',
+ ]
+ );
+ $labels = [
+ __('No Monitors'),
+ __('CRITICAL'),
+ __('WARNING'),
+ __('UKNOWN'),
+ __('NORMAL'),
+ ];
+ $totals = [
+ 'no_monitors' => 0,
+ 'critical' => 0,
+ 'warning' => 0,
+ 'unknown' => 0,
+ 'ok' => 0,
+ ];
+
+ $colors = [
+ COL_NOTINIT,
+ COL_CRITICAL,
+ COL_WARNING,
+ COL_UNKNOWN,
+ COL_NORMAL,
+ ];
+
+ foreach ($agents as $key => $agent) {
+ if ($agent['total_count'] == 0 || $agent['total_count'] == $agent['notinit_count']) {
+ $totals['no_monitors']++;
}
- $labels[] = $this->controlSizeText($row['alias']);
- $data[] = $row['status'];
+ if ($agent['critical_count'] > 0) {
+ $totals['critical']++;
+ } else if ($agent['warning_count'] > 0) {
+ $totals['warning']++;
+ } else if ($agent['unknown_count'] > 0) {
+ $totals['unknown']++;
+ } else {
+ $totals['ok']++;
+ }
+ }
+
+ foreach ($totals as $key => $total) {
+ $data[] = $total;
}
$options = [
@@ -300,6 +359,7 @@ class Agents extends Element
],
'cutout' => 80,
'nodata_image' => ['width' => '80%'],
+ 'colors' => $colors,
];
$pie = ring_graph($data, $options);
$output = html_print_div(
diff --git a/pandora_console/include/lib/TacticalView/elements/Alerts.php b/pandora_console/include/lib/TacticalView/elements/Alerts.php
index 0c970346a6..fc4c3a5297 100644
--- a/pandora_console/include/lib/TacticalView/elements/Alerts.php
+++ b/pandora_console/include/lib/TacticalView/elements/Alerts.php
@@ -37,6 +37,22 @@ class Alerts extends Element
parent::__construct();
$this->title = __('Alerts');
$this->ajaxMethods = ['getUsers'];
+ $this->ajaxMethods = [
+ 'getUsers',
+ 'getCurrentlyTriggered',
+ 'getActiveCorrelation',
+ ];
+ $this->interval = 300000;
+ $this->refreshConfig = [
+ 'triggered' => [
+ 'id' => 'currently-triggered',
+ 'method' => 'getCurrentlyTriggered',
+ ],
+ 'active-correlation' => [
+ 'id' => 'active-correlation',
+ 'method' => 'getActiveCorrelation',
+ ],
+ ];
}
@@ -47,11 +63,13 @@ class Alerts extends Element
*/
public function getCurrentlyTriggered():string
{
- // TODO connect to automonitorization.
+ $value = $this->valueMonitoring('triggered_alerts');
+ $total = round($value[0]['datos']);
return html_print_div(
[
- 'content' => '9.999.999',
+ 'content' => $total,
'class' => 'text-l',
+ 'id' => 'currently-triggered',
'style' => 'margin: 0px 10px 10px 10px;',
],
true
@@ -66,11 +84,13 @@ class Alerts extends Element
*/
public function getActiveCorrelation():string
{
- // TODO connect to automonitorization.
+ $value = $this->valueMonitoring('triggered_correlative_alerts');
+ $total = round($value[0]['datos']);
return html_print_div(
[
- 'content' => '9.999.999',
+ 'content' => $total,
'class' => 'text-l',
+ 'id' => 'active-correlation',
'style' => 'margin: 0px 10px 10px 10px;',
],
true
@@ -126,9 +146,9 @@ class Alerts extends Element
/**
* Return all users for ajax.
*
- * @return void
+ * @return string
*/
- public function getUsers():void
+ public function getUsers():string
{
global $config;
@@ -188,26 +208,25 @@ class Alerts extends Element
$total = db_process_sql($sql_count);
- echo json_encode(
+ // Capture output.
+ $response = ob_get_clean();
+
+ return json_encode(
[
'data' => $rows,
'recordsTotal' => $total[0]['total'],
'recordsFiltered' => $total[0]['total'],
]
);
-
- // Capture output.
- $response = ob_get_clean();
} catch (Exception $e) {
- echo json_encode(['error' => $e->getMessage()]);
- exit;
+ return json_encode(['error' => $e->getMessage()]);
}
json_decode($response);
if (json_last_error() === JSON_ERROR_NONE) {
- echo $response;
+ return $response;
} else {
- echo json_encode(
+ return json_encode(
[
'success' => false,
'error' => $response,
diff --git a/pandora_console/include/lib/TacticalView/elements/Configurations.php b/pandora_console/include/lib/TacticalView/elements/Configurations.php
index a6e171f8b5..51b9dcd6b5 100644
--- a/pandora_console/include/lib/TacticalView/elements/Configurations.php
+++ b/pandora_console/include/lib/TacticalView/elements/Configurations.php
@@ -46,12 +46,13 @@ class Configurations extends Element
*/
public function getTotalGroups():string
{
- // TODO connect to automonitorization.
+ $value = $this->valueMonitoring('total_groups');
+ $total = round($value[0]['datos']);
$image = html_print_image('images/Tactical_Groups.svg', true);
$text = ''.__('Groups').'';
$number = html_print_div(
[
- 'content' => '999.999',
+ 'content' => $total,
'class' => 'text-l text_center',
'style' => '',
],
@@ -69,12 +70,13 @@ class Configurations extends Element
*/
public function getTotalModules():string
{
- // TODO connect to automonitorization.
+ $value = $this->valueMonitoring('total_modules');
+ $total = round($value[0]['datos']);
$image = html_print_image('images/Tactical_Modules.svg', true);
$text = ''.__('Modules').'';
$number = html_print_div(
[
- 'content' => '999.999',
+ 'content' => $total,
'class' => 'text-l text_center',
'style' => '',
],
@@ -182,12 +184,13 @@ class Configurations extends Element
*/
public function getNotInitModules():string
{
- // TODO connect to automonitorization.
+ $value = $this->valueMonitoring('total_notinit');
+ $total = round($value[0]['datos']);
$image = html_print_image('images/Tactical_Not_init_module.svg', true);
$text = ''.__('Not-init modules').'';
$number = html_print_div(
[
- 'content' => '999.999',
+ 'content' => $total,
'class' => 'text-l text_center',
'style' => '',
],
@@ -205,12 +208,13 @@ class Configurations extends Element
*/
public function getTotalUnknowAgents():string
{
- // TODO connect to automonitorization.
+ $value = $this->valueMonitoring('total_notinit');
+ $total = round($value[0]['total_unknown']);
$image = html_print_image('images/Tactical_Unknown_agent.svg', true);
$text = ''.__('Unknown agents').'';
$number = html_print_div(
[
- 'content' => '999.999',
+ 'content' => $total,
'class' => 'text-l text_center',
'style' => '',
],
diff --git a/pandora_console/include/lib/TacticalView/elements/Database.php b/pandora_console/include/lib/TacticalView/elements/Database.php
index c1c0138e28..ffd38c8156 100644
--- a/pandora_console/include/lib/TacticalView/elements/Database.php
+++ b/pandora_console/include/lib/TacticalView/elements/Database.php
@@ -36,6 +36,42 @@ class Database extends Element
{
parent::__construct();
$this->title = __('Database');
+ $this->ajaxMethods = [
+ 'getStatus',
+ 'getDataRecords',
+ 'getEvents',
+ 'getStringRecords',
+ 'getReadsGraph',
+ 'getWritesGraph',
+ ];
+ $this->interval = 300000;
+ $this->refreshConfig = [
+ 'status' => [
+ 'id' => 'status-database',
+ 'method' => 'getStatus',
+ ],
+ 'records' => [
+ 'id' => 'data-records',
+ 'method' => 'getDataRecords',
+ ],
+ 'events' => [
+ 'id' => 'total-events',
+ 'method' => 'getEvents',
+ ],
+ 'totalRecords' => [
+ 'id' => 'total-records',
+ 'method' => 'getStringRecords',
+
+ ],
+ 'reads' => [
+ 'id' => 'database-reads',
+ 'method' => 'getReadsGraph',
+ ],
+ 'writes' => [
+ 'id' => 'database-writes',
+ 'method' => 'getWritesGraph',
+ ],
+ ];
}
@@ -75,6 +111,7 @@ class Database extends Element
[
'content' => $output,
'class' => 'flex_center margin-top-5',
+ 'id' => 'status-database',
'style' => 'margin: 0px 10px 10px 10px;',
],
true
@@ -89,11 +126,13 @@ class Database extends Element
*/
public function getDataRecords():string
{
- // TODO connect to automonitorization.
+ $data = $this->valueMonitoring('mysql_size_of_data');
+ $value = round($data[0]['datos'], 2).' MB';
return html_print_div(
[
- 'content' => '9.999.999',
+ 'content' => $value,
'class' => 'text-l',
+ 'id' => 'data-records',
'style' => 'margin: 0px 10px 10px 10px;',
],
true
@@ -113,6 +152,7 @@ class Database extends Element
[
'content' => '9.999.999',
'class' => 'text-l',
+ 'id' => 'total-events',
'style' => 'margin: 0px 10px 10px 10px;',
],
true
@@ -127,11 +167,13 @@ class Database extends Element
*/
public function getStringRecords():string
{
- // TODO connect to automonitorization.
+ $data = $this->valueMonitoring('total_string_data');
+ $value = round($data[0]['datos']);
return html_print_div(
[
- 'content' => '9.999.999',
+ 'content' => $value,
'class' => 'text-l',
+ 'id' => 'total-records',
'style' => 'margin: 0px 10px 10px 10px;',
],
true
@@ -146,33 +188,17 @@ class Database extends Element
*/
public function getReadsGraph():string
{
- // TODO connect to automonitorization.
- $dates = [
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- ];
- $string_reads = [
- 1,
- 0.5,
- 2,
- 1.5,
- 3,
- 2.5,
- 4,
- 3.5,
- 5,
- 4.5,
- 6,
- ];
- $total = '9.999.999';
+ $dateInit = (time() - 86400);
+ $reads = $this->valueMonitoring('mysql_questions_reads', $dateInit, time());
+ $dates = [];
+ $string_reads = [];
+ $total = 0;
+ foreach ($reads as $key => $read) {
+ $dates[] = date('d-m-Y H:i:s', $read['utimestamp']);
+ $string_reads[] = $read['datos'];
+ $total += $read['datos'];
+ }
+
$options = [
'labels' => $dates,
'legend' => [ 'display' => false ],
@@ -217,7 +243,13 @@ class Database extends Element
true
);
- $output = $total.$graph_area;
+ $output = html_print_div(
+ [
+ 'content' => $total.$graph_area,
+ 'id' => 'database-reads',
+ ],
+ true
+ );
return $output;
}
@@ -230,33 +262,17 @@ class Database extends Element
*/
public function getWritesGraph():string
{
- // TODO connect to automonitorization.
- $dates = [
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- ];
- $string_writes = [
- 1,
- 0.5,
- 2,
- 1.5,
- 3,
- 2.5,
- 4,
- 3.5,
- 5,
- 4.5,
- 6,
- ];
- $total = '9.999.999';
+ $dateInit = (time() - 86400);
+ $writes = $this->valueMonitoring('mysql_questions_writes', $dateInit, time());
+ $dates = [];
+ $string_writes = [];
+ $total = 0;
+ foreach ($writes as $key => $write) {
+ $dates[] = date('d-m-Y H:i:s', $write['utimestamp']);
+ $string_writes[] = $write['datos'];
+ $total += $write['datos'];
+ }
+
$options = [
'labels' => $dates,
'legend' => [ 'display' => false ],
@@ -301,7 +317,13 @@ class Database extends Element
true
);
- $output = $total.$graph_area;
+ $output = html_print_div(
+ [
+ 'content' => $total.$graph_area,
+ 'id' => 'database-writes',
+ ],
+ true
+ );
return $output;
}
diff --git a/pandora_console/include/lib/TacticalView/elements/Events.php b/pandora_console/include/lib/TacticalView/elements/Events.php
index 6889b11b6d..dd25efa3e2 100644
--- a/pandora_console/include/lib/TacticalView/elements/Events.php
+++ b/pandora_console/include/lib/TacticalView/elements/Events.php
@@ -36,6 +36,11 @@ class Events extends Element
{
parent::__construct();
$this->title = __('Events');
+ $this->ajaxMethods = [
+ 'getEventsGraph',
+ 'getEventsCriticalityGraph',
+ 'getEventsStatusValidateGraph',
+ ];
}
@@ -84,7 +89,6 @@ class Events extends Element
}
$danger = $max_value;
- $warning = ($max_value / 2);
$ok = ($max_value / 3);
foreach ($graph_values as $key => $value) {
@@ -92,7 +96,7 @@ class Events extends Element
$colors[] = '#EC7176';
}
- if ($value['y'] >= $warning && $value['y'] < $danger) {
+ if ($value['y'] >= $ok && $value['y'] < $danger) {
$colors[] = '#FCAB10';
}
@@ -120,7 +124,7 @@ class Events extends Element
$bar = vbar_graph($graph_values, $options);
- return html_print_div(
+ $output = html_print_div(
[
'content' => $bar,
'class' => 'margin-top-5 w100p relative',
@@ -128,6 +132,8 @@ class Events extends Element
],
true
);
+
+ return $output;
}
diff --git a/pandora_console/include/lib/TacticalView/elements/Groups.php b/pandora_console/include/lib/TacticalView/elements/Groups.php
index b3aa1f9b6e..ee7ccf0ab6 100644
--- a/pandora_console/include/lib/TacticalView/elements/Groups.php
+++ b/pandora_console/include/lib/TacticalView/elements/Groups.php
@@ -41,7 +41,11 @@ class Groups extends Element
*/
public function __construct()
{
+ global $config;
parent::__construct();
+ include_once $config['homedir'].'/include/functions_users.php';
+ include_once 'include/functions_groupview.php';
+ ui_require_css_file('heatmap');
$this->title = __('Groups');
$this->total = $this->calculateTotalGroups();
}
@@ -54,7 +58,7 @@ class Groups extends Element
*/
public function calculateTotalGroups():int
{
- $total = db_get_num_rows('SELECT * FROM tgrupo;');
+ $total = db_get_value_sql('SELECT count(*) FROM tgrupo');
return $total;
}
@@ -66,19 +70,22 @@ class Groups extends Element
*/
public function getStatusHeatMap():string
{
- ui_require_css_file('heatmap');
+ global $config;
+
+ // ACL Check.
+ $agent_a = check_acl($config['id_user'], 0, 'AR');
+ $agent_w = check_acl($config['id_user'], 0, 'AW');
$width = 350;
$height = 275;
- $sql = 'SELECT * FROM tagente a
- LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente';
- $all_agents = db_get_all_rows_sql($sql);
- if (empty($all_agents)) {
- return null;
- }
-
- $total_agents = count($all_agents);
+ $groups_list = groupview_get_groups_list(
+ $config['id_user'],
+ ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'),
+ true
+ );
+ $total_groups = $groups_list['counter'];
+ $groups = $groups_list['groups'];
// Best square.
$high = (float) max($width, $height);
$low = 0.0;
@@ -86,7 +93,7 @@ class Groups extends Element
while (abs($high - $low) > 0.000001) {
$mid = (($high + $low) / 2.0);
$midval = (floor($width / $mid) * floor($height / $mid));
- if ($midval >= $total_agents) {
+ if ($midval >= $total_groups) {
$low = $mid;
} else {
$high = $mid;
@@ -107,38 +114,21 @@ class Groups extends Element
$x = 0;
$y = 0;
$cont = 1;
+ foreach ($groups as $key => $value) {
+ if ($value['_name_'] === 'All') {
+ continue;
+ }
- foreach ($all_agents as $key => $value) {
- // Colour by status.
- $status = agents_get_status_from_counts($value);
-
- switch ($status) {
- case 5:
- // Not init status.
- $status = 'notinit';
- break;
-
- case 1:
- // Critical status.
- $status = 'critical';
- break;
-
- case 2:
- // Warning status.
- $status = 'warning';
- break;
-
- case 0:
- // Normal status.
- $status = 'normal';
- break;
-
- case 3:
- case -1:
- default:
- // Unknown status.
- $status = 'unknown';
- break;
+ if ($value['_monitors_critical_'] > 0) {
+ $status = 'critical';
+ } else if ($value['_monitors_warning_'] > 0) {
+ $status = 'warning';
+ } else if (($value['_monitors_unknown_'] > 0) || ($value['_agents_unknown_'] > 0)) {
+ $status = 'unknown';
+ } else if ($value['_monitors_ok_'] > 0) {
+ $status = 'normal';
+ } else {
+ $status = 'unknown';
}
$heatmap .= sprintf(
@@ -175,14 +165,13 @@ class Groups extends Element
$heatmap .= '