From 39fb79bbb42b9402fac5f22111bf0f4158ea0b78 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Tue, 11 Jul 2017 18:22:25 +0200 Subject: [PATCH] Fix automatic combined graph macros in name and labels - #1088 --- .../include/functions_reporting.php | 69 +++++++++++++++---- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index fc9341d2ec..ffde723fe7 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -128,6 +128,26 @@ function reporting_make_reporting_data($report = null, $id_report, $content['period'] = $period; } + if(defined('METACONSOLE')){ + if (is_array($content['id_agent'])) { + $new_array = array(); + foreach ($content['id_agent'] as $key => $value) { + $meta_id = explode("|",$value); + array_push($new_array,$meta_id[1]); + } + $content['id_agent'] = $new_array; + } + else { + $meta_id = explode("|",$content['id_agent']); + if ($meta_id[1] != null) { + $content['id_agent'] = array(); + $content['id_agent'] = $meta_id[1]; + } + } + + + } + $content['style'] = json_decode(io_safe_output($content['style']), true); if(isset($content['style']['name_label'])){ //Add macros name @@ -147,7 +167,18 @@ function reporting_make_reporting_data($report = null, $id_report, } } - $content['name'] = reporting_label_macro($items_label, $content['style']['name_label']); + + + if(sizeof($content['id_agent']) != 1){ + $content['style']['name_label'] = str_replace("_agent_",sizeof($content['id_agent']).__(' agents'),$content['style']['name_label']); + } + + if(sizeof($content['id_agent_module']) != 1){ + $content['style']['name_label'] = str_replace("_module_",sizeof($content['id_agent_module']).__(' modules'),$content['style']['name_label']); + } + + $content['name'] = reporting_label_macro($items_label, $content['style']['name_label']); + if ($metaconsole_on) { //Restore db connection @@ -5780,17 +5811,12 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', require_once ($config["homedir"] . '/include/functions_graph.php'); - if ($type_report == 'automatic_graph') { - // Do none - } - else { - if ($config['metaconsole']) { - $id_meta = metaconsole_get_id_server($content["server_name"]); - - - $server = metaconsole_get_connection_by_id ($id_meta); - metaconsole_connect($server); - } + if ($config['metaconsole']) { + $id_meta = metaconsole_get_id_server($content["server_name"]); + + + $server = metaconsole_get_connection_by_id ($id_meta); + metaconsole_connect($server); } $graph = db_get_row ("tgraph", "id_graph", $content['id_gs']); @@ -5833,9 +5859,17 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', array_push ($weights, $graph_item["weight"]); if (in_array('label',$content['style'])) { + if (defined('METACONSOLE')) { + $item = array('type' => 'custom_graph', + 'id_agent' =>$content['id_agent'], + 'id_agent_module'=>$graph_item['id_agent_module']); + } + else { $item = array('type' => 'custom_graph', 'id_agent' =>modules_get_agentmodule_agent($graph_item['id_agent_module']), 'id_agent_module'=>$graph_item['id_agent_module']); + } + $label = reporting_label_macro($item, $content['style']['label']); $labels[$graph_item['id_agent_module']] = $label; } @@ -5855,6 +5889,13 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', $height = 50; } } + if (defined('METACONSOLE')) { + $modules_new = array(); + foreach ($modules as $mod) { + $modules_new[] = $mod['module']; + } + $modules = $modules_new; + } switch ($type) { case 'dinamic': @@ -10251,7 +10292,6 @@ function reporting_get_agentmodule_sla_working_timestamp ($period, $date_end, $w } function reporting_label_macro ($item, $label) { - switch ($item['type']) { case 'event_report_agent': case 'alert_report_agent': @@ -10277,6 +10317,7 @@ function reporting_label_macro ($item, $label) { $label = str_replace("_address_", $agent_name, $label); } break; + case 'automatic_graph': case 'simple_graph': case 'module_histogram_graph': case 'custom_graph': @@ -10330,4 +10371,4 @@ function reporting_label_macro ($item, $label) { return $label; } -?> +?> \ No newline at end of file