From 0f379a28888d8c2289e4d4b486ef3454ef8a9f7b Mon Sep 17 00:00:00 2001
From: Daniel Maya
Date: Tue, 20 Oct 2020 12:38:42 +0200
Subject: [PATCH 01/42] Fixed pagination counter
---
pandora_console/extensions/module_groups.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php
index 76225c0751..50a0de4d78 100644
--- a/pandora_console/extensions/module_groups.php
+++ b/pandora_console/extensions/module_groups.php
@@ -86,7 +86,6 @@ function mainModuleGroups()
);
$info = $tree_group->getArray();
$info = groupview_plain_groups($info);
- $counter = count($info);
$offset = get_parameter('offset', 0);
$agent_group_search = get_parameter('agent_group_search', '');
$module_group_search = get_parameter('module_group_search', '');
@@ -134,6 +133,8 @@ function mainModuleGroups()
$ids_group = -1;
}
+ $counter = count($info);
+
$condition_critical = modules_get_state_condition(AGENT_MODULE_STATUS_CRITICAL_ALERT);
$condition_warning = modules_get_state_condition(AGENT_MODULE_STATUS_WARNING_ALERT);
$condition_unknown = modules_get_state_condition(AGENT_MODULE_STATUS_UNKNOWN);
From 6c16587b4099df4f0d1f972d111368a1adcad310 Mon Sep 17 00:00:00 2001
From: Daniel Barbero Martin
Date: Tue, 20 Oct 2020 12:58:25 +0200
Subject: [PATCH 02/42] fixed legend avg network interfaces
---
pandora_console/include/functions.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 0147168ebf..a033f33115 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -3753,7 +3753,16 @@ function series_type_graph_array($data, $show_elements_graph)
$name_legend .= __('Unit ').' ';
$name_legend .= $show_elements_graph['unit'].': ';
} else {
- $name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': ';
+ if (isset($show_elements_graph['from_interface']) === true
+ && (bool) $show_elements_graph['from_interface'] === true
+ ) {
+ $label_interfaces = array_flip($show_elements_graph['modules_series']);
+ $name_legend = $show_elements_graph['labels'][$value['agent_module_id']][$label_interfaces[$value['agent_module_id']]].': ';
+ } else if (is_array($show_elements_graph['labels'][$value['agent_module_id']]) === true) {
+ $name_legend = 'Avg: ';
+ } else {
+ $name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': ';
+ }
}
} else {
if (strpos($key, 'baseline') !== false) {
From 685acc6c204f21d16bb23ea75171f72657117fa0 Mon Sep 17 00:00:00 2001
From: Daniel Barbero Martin
Date: Tue, 20 Oct 2020 16:00:19 +0200
Subject: [PATCH 03/42] fixed report avg-min-max
---
.../include/functions_reporting.php | 141 +++++++++++++++---
.../include/functions_reporting_html.php | 79 ++++++++--
pandora_console/include/styles/pandora.css | 1 +
3 files changed, 189 insertions(+), 32 deletions(-)
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index 0bfe96e864..674da95b09 100755
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -4979,6 +4979,16 @@ function reporting_agent_configuration($report, $content)
}
+/**
+ * Report Min, Max and Avg.
+ *
+ * @param array $report Info report.
+ * @param array $content Content report.
+ * @param string $type Type report.
+ * @param boolean $pdf Is pdf.
+ *
+ * @return array Data draw report.
+ */
function reporting_value($report, $content, $type, $pdf=false)
{
global $config;
@@ -4993,16 +5003,17 @@ function reporting_value($report, $content, $type, $pdf=false)
$return['type'] = 'min_value';
break;
- case 'avg':
- $return['type'] = 'avg_value';
- break;
-
case 'sum':
$return['type'] = 'sumatory';
break;
+
+ case 'avg':
+ default:
+ $return['type'] = 'avg_value';
+ break;
}
- if (empty($content['name'])) {
+ if (empty($content['name']) === true) {
switch ($type) {
case 'max':
$content['name'] = __('Max. Value');
@@ -5012,17 +5023,18 @@ function reporting_value($report, $content, $type, $pdf=false)
$content['name'] = __('Min. Value');
break;
- case 'avg':
- $content['name'] = __('AVG. Value');
- break;
-
case 'sum':
$content['name'] = __('Summatory');
break;
+
+ case 'avg':
+ default:
+ $content['name'] = __('AVG. Value');
+ break;
}
}
- if ($config['metaconsole']) {
+ if (is_metaconsole() === true) {
$id_meta = metaconsole_get_id_server($content['server_name']);
$server = metaconsole_get_connection_by_id($id_meta);
@@ -5060,14 +5072,15 @@ function reporting_value($report, $content, $type, $pdf=false)
$return['agent_name'] = $agent_name;
$return['module_name'] = $module_name;
+ $only_image = false;
if ($pdf) {
- $only_image = 1;
+ $only_image = true;
}
$params = [
'agent_module_id' => $content['id_agent_module'],
'period' => $content['period'],
- 'width' => '600px',
+ 'width' => '90%',
'pure' => false,
'date' => $report['datetime'],
'only_image' => $only_image,
@@ -5086,6 +5099,7 @@ function reporting_value($report, $content, $type, $pdf=false)
case 'max':
case 'min':
case 'avg':
+ default:
$divisor = get_data_multiplier($unit);
if ($content['lapse_calc'] == 0) {
@@ -5107,6 +5121,7 @@ function reporting_value($report, $content, $type, $pdf=false)
break;
case 'avg':
+ default:
$value = reporting_get_agentmodule_data_average(
$content['id_agent_module'],
$content['period'],
@@ -5118,7 +5133,14 @@ function reporting_value($report, $content, $type, $pdf=false)
if (!$config['simple_module_value']) {
$formated_value = $value;
} else {
- $formated_value = format_for_graph($value, $config['graph_precision'], '.', ',', $divisor, $unit);
+ $formated_value = format_for_graph(
+ $value,
+ $config['graph_precision'],
+ '.',
+ ',',
+ $divisor,
+ $unit
+ );
}
} else {
$return['visual_format'] = $content['visual_format'];
@@ -5126,17 +5148,51 @@ function reporting_value($report, $content, $type, $pdf=false)
switch ($type) {
case 'max':
$params['force_interval'] = 'max_only';
- $value = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit);
+ $value = format_for_graph(
+ reporting_get_agentmodule_data_max(
+ $content['id_agent_module'],
+ $content['period'],
+ $report['datetime']
+ ),
+ $config['graph_precision'],
+ '.',
+ ',',
+ $divisor,
+ $unit
+ );
break;
case 'min':
$params['force_interval'] = 'min_only';
- $value = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit);
+ $value = format_for_graph(
+ reporting_get_agentmodule_data_min(
+ $content['id_agent_module'],
+ $content['period'],
+ $report['datetime']
+ ),
+ $config['graph_precision'],
+ '.',
+ ',',
+ $divisor,
+ $unit
+ );
break;
case 'avg':
+ default:
$params['force_interval'] = 'avg_only';
- $value = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit);
+ $value = format_for_graph(
+ reporting_get_agentmodule_data_average(
+ $content['id_agent_module'],
+ $content['period'],
+ $report['datetime']
+ ),
+ $config['graph_precision'],
+ '.',
+ ',',
+ $divisor,
+ $unit
+ );
break;
}
@@ -5166,15 +5222,49 @@ function reporting_value($report, $content, $type, $pdf=false)
if ($i > $time_begin['utimestamp']) {
switch ($type) {
case 'max':
- $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit);
+ $row[__('Maximun')] = format_for_graph(
+ reporting_get_agentmodule_data_max(
+ $content['id_agent_module'],
+ $content['lapse'],
+ ($i + $content['lapse'])
+ ),
+ $config['graph_precision'],
+ '.',
+ ',',
+ $divisor,
+ $unit
+ );
break;
case 'min':
- $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit);
+ $row[__('Maximun')] = format_for_graph(
+ reporting_get_agentmodule_data_min(
+ $content['id_agent_module'],
+ $content['lapse'],
+ ($i + $content['lapse'])
+ ),
+ $config['graph_precision'],
+ '.',
+ ',',
+ $divisor,
+ $unit
+ );
break;
case 'avg':
- $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit);
+ default:
+ $row[__('Maximun')] = format_for_graph(
+ reporting_get_agentmodule_data_average(
+ $content['id_agent_module'],
+ $content['lapse'],
+ ($i + $content['lapse'])
+ ),
+ $config['graph_precision'],
+ '.',
+ ',',
+ $divisor,
+ $unit
+ );
break;
}
} else {
@@ -5185,7 +5275,7 @@ function reporting_value($report, $content, $type, $pdf=false)
}
}
- if ($config['metaconsole']) {
+ if (is_metaconsole() === true) {
metaconsole_restore_db();
}
@@ -5205,7 +5295,14 @@ function reporting_value($report, $content, $type, $pdf=false)
} else {
$divisor = get_data_multiplier($unit);
- $formated_value = format_for_graph($value, $config['graph_precision'], '.', ',', $divisor, $unit);
+ $formated_value = format_for_graph(
+ $value,
+ $config['graph_precision'],
+ '.',
+ ',',
+ $divisor,
+ $unit
+ );
}
break;
}
@@ -5215,7 +5312,7 @@ function reporting_value($report, $content, $type, $pdf=false)
'formated_value' => $formated_value,
];
- if ($config['metaconsole']) {
+ if (is_metaconsole() === true) {
metaconsole_restore_db();
}
diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php
index 0de6b542bd..a9f7acadb9 100644
--- a/pandora_console/include/functions_reporting_html.php
+++ b/pandora_console/include/functions_reporting_html.php
@@ -2965,8 +2965,26 @@ function reporting_html_min_value(&$table, $item, $mini)
}
-function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_empty=false)
-{
+/**
+ * Htlm report AVg, min, Max, Only.
+ *
+ * @param array $table Table.
+ * @param array $item Data.
+ * @param boolean $mini Is mini.
+ * @param boolean $only_value Only value.
+ * @param boolean $check_empty Empty.
+ * @param integer $pdf PDF Mode.
+ *
+ * @return string Html output.
+ */
+function reporting_html_value(
+ $table,
+ $item,
+ $mini,
+ $only_value=false,
+ $check_empty=false,
+ $pdf=0
+) {
global $config;
if ($mini) {
@@ -2975,8 +2993,12 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
$font_size = $config['font_size_item_report'].'em';
}
- if (isset($item['visual_format']) && $item['visual_format'] != 0
- && ($item['type'] == 'max_value' || $item['type'] == 'min_value' || $item['type'] == 'avg_value')
+ $return_pdf = '';
+
+ if (isset($item['visual_format']) === true && $item['visual_format'] != 0
+ && ($item['type'] == 'max_value'
+ || $item['type'] == 'min_value'
+ || $item['type'] == 'avg_value')
) {
$table2 = new stdClass();
$table2->width = '100%';
@@ -2998,6 +3020,7 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
break;
case 'avg_value':
+ default:
$table2->head = [
__('Agent'),
__('Module'),
@@ -3025,15 +3048,28 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
$table->colspan[2][0] = 3;
$table->colspan[3][0] = 3;
- array_push($table->data, html_print_table($table2, true));
+ if ($pdf === 0) {
+ array_push($table->data, html_print_table($table2, true));
+ } else {
+ $return_pdf .= html_print_table($table2, true);
+ }
+
unset($item['data'][0]);
if ($item['visual_format'] != 1) {
$value = $item['data'][1]['value'];
- array_push($table->data, $value);
- unset($item['data'][1]);
+ if ($pdf === 0) {
+ array_push($table->data, $value);
+ } else {
+ $style_div_pdf = 'text-align:center;margin-bottom:20px;';
+ $return_pdf .= '';
+ $return_pdf .= $value;
+ $return_pdf .= '
';
+ }
}
+ unset($item['data'][1]);
+
if ($item['visual_format'] != 2) {
$table1 = new stdClass();
$table1->width = '100%';
@@ -3053,6 +3089,7 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
break;
case 'avg_value':
+ default:
$table1->head = [
__('Lapse'),
__('Average'),
@@ -3061,8 +3098,9 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
}
$table1->data = [];
+ $row = [];
foreach ($item['data'] as $data) {
- if (!is_numeric($data[__('Maximun')])) {
+ if (is_numeric($data[__('Maximun')]) === false) {
$row = [
$data[__('Lapse')],
$data[__('Maximun')],
@@ -3070,7 +3108,12 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
} else {
$row = [
$data[__('Lapse')],
- remove_right_zeros(number_format($data[__('Maximun')], $config['graph_precision'])),
+ remove_right_zeros(
+ number_format(
+ $data[__('Maximun')],
+ $config['graph_precision']
+ )
+ ),
];
}
@@ -3080,10 +3123,22 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
$table1->title = $item['title'];
$table1->titleclass = 'title_table_pdf';
$table1->titlestyle = 'text-align:left;';
+ if ($pdf === 0) {
+ array_push($table->data, html_print_table($table1, true));
+ } else {
+ $return_pdf .= html_print_table($table1, true);
+ }
+ }
- array_push($table->data, html_print_table($table1, true));
+ if ($pdf !== 0) {
+ return $return_pdf;
}
} else {
+ if ($pdf !== 0) {
+ $table = new stdClass();
+ $table->width = '100%';
+ }
+
$table->colspan['data']['cell'] = 3;
$table->cellstyle['data']['cell'] = 'text-align: left;';
@@ -3098,6 +3153,10 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
}
$table->data['data']['cell'] .= '
';
+
+ if ($pdf !== 0) {
+ return html_print_table($table, true);
+ }
}
}
diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css
index 6b48ab13ae..5f0f9024c7 100644
--- a/pandora_console/include/styles/pandora.css
+++ b/pandora_console/include/styles/pandora.css
@@ -1480,6 +1480,7 @@ table.databox {
padding: 9px 7px;
font-weight: normal;
color: #fff;
+ text-align: justify;
}
.databox > th * {
From 3c95d1748225d76ee880b45774e79b0b35ccf712 Mon Sep 17 00:00:00 2001
From: Daniel Maya
Date: Tue, 20 Oct 2020 16:15:42 +0200
Subject: [PATCH 04/42] Fixed new_agent
---
.../godmode/agentes/agent_manager.php | 17 ++++++++++-------
.../godmode/agentes/modificar_agente.php | 1 -
.../operation/agentes/estado_agente.php | 2 --
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php
index f4014de907..d1c7ae5224 100644
--- a/pandora_console/godmode/agentes/agent_manager.php
+++ b/pandora_console/godmode/agentes/agent_manager.php
@@ -149,7 +149,7 @@ if (is_ajax()) {
ui_require_javascript_file('openlayers.pandora');
-$new_agent = (bool) get_parameter('new_agent');
+$new_agent = (empty($id_agente)) ? true : false;
if (! isset($id_agente) && ! $new_agent) {
db_pandora_audit('ACL Violation', 'Trying to access agent manager witout an agent');
@@ -1222,6 +1222,7 @@ ui_require_jquery_file('bgiframe');
$(document).ready (function() {
+ var $id_agent = '';
var previous_primary_group_select;
$("#grupo").on('focus', function () {
previous_primary_group_select = this.value;
@@ -1276,12 +1277,14 @@ ui_require_jquery_file('bgiframe');
}
});
- paint_qrcode(
- "",
- "#qr_code_agent_view",
- 128,
- 128
- );
+ if (typeof $id_agent !== 'undefined' && $id_agent !== '0') {
+ paint_qrcode(
+ "",
+ "#qr_code_agent_view",
+ 128,
+ 128
+ );
+ }
$("#text-agente").prop('readonly', true);
});
diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php
index d4036bd68c..2a3620a504 100644
--- a/pandora_console/godmode/agentes/modificar_agente.php
+++ b/pandora_console/godmode/agentes/modificar_agente.php
@@ -754,7 +754,6 @@ if (check_acl($config['id_user'], 0, 'AW')) {
// Create agent button.
echo '