Merge branch '1088-Macros-en-automatic-combined-graph-plantillas-de-informes' into 'develop'

Fix automatic combined graph macros in name and labels - #1088

See merge request !657
This commit is contained in:
vgilc 2017-07-12 10:12:45 +02:00
commit f907f3cdb7
1 changed files with 55 additions and 14 deletions

View File

@ -128,6 +128,26 @@ function reporting_make_reporting_data($report = null, $id_report,
$content['period'] = $period; $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); $content['style'] = json_decode(io_safe_output($content['style']), true);
if(isset($content['style']['name_label'])){ if(isset($content['style']['name_label'])){
//Add macros name //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) { if ($metaconsole_on) {
//Restore db connection //Restore db connection
@ -5780,17 +5811,12 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
require_once ($config["homedir"] . '/include/functions_graph.php'); require_once ($config["homedir"] . '/include/functions_graph.php');
if ($type_report == 'automatic_graph') { if ($config['metaconsole']) {
// Do none $id_meta = metaconsole_get_id_server($content["server_name"]);
}
else {
if ($config['metaconsole']) { $server = metaconsole_get_connection_by_id ($id_meta);
$id_meta = metaconsole_get_id_server($content["server_name"]); metaconsole_connect($server);
$server = metaconsole_get_connection_by_id ($id_meta);
metaconsole_connect($server);
}
} }
$graph = db_get_row ("tgraph", "id_graph", $content['id_gs']); $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"]); array_push ($weights, $graph_item["weight"]);
if (in_array('label',$content['style'])) { 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', $item = array('type' => 'custom_graph',
'id_agent' =>modules_get_agentmodule_agent($graph_item['id_agent_module']), 'id_agent' =>modules_get_agentmodule_agent($graph_item['id_agent_module']),
'id_agent_module'=>$graph_item['id_agent_module']); 'id_agent_module'=>$graph_item['id_agent_module']);
}
$label = reporting_label_macro($item, $content['style']['label']); $label = reporting_label_macro($item, $content['style']['label']);
$labels[$graph_item['id_agent_module']] = $label; $labels[$graph_item['id_agent_module']] = $label;
} }
@ -5855,6 +5889,13 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
$height = 50; $height = 50;
} }
} }
if (defined('METACONSOLE')) {
$modules_new = array();
foreach ($modules as $mod) {
$modules_new[] = $mod['module'];
}
$modules = $modules_new;
}
switch ($type) { switch ($type) {
case 'dinamic': case 'dinamic':
@ -10251,7 +10292,6 @@ function reporting_get_agentmodule_sla_working_timestamp ($period, $date_end, $w
} }
function reporting_label_macro ($item, $label) { function reporting_label_macro ($item, $label) {
switch ($item['type']) { switch ($item['type']) {
case 'event_report_agent': case 'event_report_agent':
case 'alert_report_agent': case 'alert_report_agent':
@ -10277,6 +10317,7 @@ function reporting_label_macro ($item, $label) {
$label = str_replace("_address_", $agent_name, $label); $label = str_replace("_address_", $agent_name, $label);
} }
break; break;
case 'automatic_graph':
case 'simple_graph': case 'simple_graph':
case 'module_histogram_graph': case 'module_histogram_graph':
case 'custom_graph': case 'custom_graph':
@ -10330,4 +10371,4 @@ function reporting_label_macro ($item, $label) {
return $label; return $label;
} }
?> ?>