Merge branch '3253-Error_en_automatic_combined_graph_en_meta_con_varios_nodos' into 'develop'

fixed autocombined report metaconsole

See merge request artica/pandorafms!2077

Former-commit-id: 130262742f8bac0441b4b8285dc62bb0d3aa998a
This commit is contained in:
vgilc 2018-12-21 10:22:21 +01:00
commit 2a407bb494
3 changed files with 62 additions and 44 deletions

View File

@ -1083,9 +1083,11 @@ You can of course remove the warnings, that's why we include the source and do n
} }
$all_agent_log = db_get_all_rows_sql($sql_log_report); $all_agent_log = db_get_all_rows_sql($sql_log_report);
if(isset($all_agent_log) && is_array($all_agent_log)){
foreach ($all_agent_log as $key => $value) { foreach ($all_agent_log as $key => $value) {
$agents2[$value['id_agente']] = $value['alias']; $agents2[$value['id_agente']] = $value['alias'];
} }
}
if ((empty($agents2)) || $agents2 == -1) $agents = array(); if ((empty($agents2)) || $agents2 == -1) $agents = array();

View File

@ -1049,6 +1049,10 @@ function graphic_combined_module (
$params_combined['id_graph'] = 0; $params_combined['id_graph'] = 0;
} }
if(!isset($params_combined['type_report'])){
$params_combined['type_report'] = '';
}
if(!isset($params['percentil'])){ if(!isset($params['percentil'])){
$params_combined['percentil'] = null; $params_combined['percentil'] = null;
} }
@ -1207,7 +1211,7 @@ function graphic_combined_module (
); );
$series = db_get_all_rows_sql( $series = db_get_all_rows_sql(
'SELECT summatory_series,average_series,modules_series 'SELECT summatory_series,average_series, modules_series
FROM tgraph FROM tgraph
WHERE id_graph = '. WHERE id_graph = '.
$params_combined['id_graph'] $params_combined['id_graph']
@ -1301,7 +1305,6 @@ function graphic_combined_module (
); );
} }
//XXX arreglar estas
$long_index = ''; $long_index = '';
switch ($params_combined['stacked']) { switch ($params_combined['stacked']) {
default: default:
@ -1324,7 +1327,16 @@ function graphic_combined_module (
$i=0; $i=0;
$array_data = array(); $array_data = array();
foreach ($module_list as $key => $agent_module_id) { foreach ($module_list as $key => $agent_module_id) {
if(is_metaconsole() && $params_combined['type_report'] == 'automatic_graph'){
$server = metaconsole_get_connection_by_id ($agent_module_id['server']);
if (metaconsole_connect ($server) != NOERR){
continue;
}
$agent_module_id = $agent_module_id['module'];
}
$module_data = db_get_row_sql ( $module_data = db_get_row_sql (
'SELECT * FROM tagente_modulo 'SELECT * FROM tagente_modulo
WHERE id_agente_modulo = ' . WHERE id_agente_modulo = ' .
@ -1386,6 +1398,10 @@ function graphic_combined_module (
//$array_events_alerts[$series_suffix] = $events; //$array_events_alerts[$series_suffix] = $events;
$i++; $i++;
if(is_metaconsole() && $params_combined['type_report'] == 'automatic_graph'){
metaconsole_restore_db();
}
} }
if($params_combined['projection']){ if($params_combined['projection']){
@ -1544,7 +1560,6 @@ function graphic_combined_module (
$water_mark, $water_mark,
$array_events_alerts $array_events_alerts
); );
break; break;
case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD: case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD:
case CUSTOM_GRAPH_BULLET_CHART: case CUSTOM_GRAPH_BULLET_CHART:

View File

@ -6344,13 +6344,18 @@ 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 ($config['metaconsole']) { if ($type_report == "custom_graph") {
if (is_metaconsole()) {
$id_meta = metaconsole_get_id_server($content["server_name"]); $id_meta = metaconsole_get_id_server($content["server_name"]);
$server = metaconsole_get_connection_by_id ($id_meta); $server = metaconsole_get_connection_by_id ($id_meta);
metaconsole_connect($server); if (metaconsole_connect ($server) != NOERR){
return false;
}
}
} }
$graph = db_get_row ("tgraph", "id_graph", $content['id_gs']); $graph = db_get_row ("tgraph", "id_graph", $content['id_gs']);
$return = array(); $return = array();
$return['type'] = 'custom_graph'; $return['type'] = 'custom_graph';
@ -6374,30 +6379,25 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
$graphs[0]["average_series"] = ''; $graphs[0]["average_series"] = '';
$graphs[0]["modules_series"] = ''; $graphs[0]["modules_series"] = '';
$graphs[0]["fullscale"] = $content['style']['fullscale']; $graphs[0]["fullscale"] = $content['style']['fullscale'];
$modules = $content['id_agent_module'];
if(is_array($content['id_agent_module'])){ if(!$modules){
foreach ($content['id_agent_module'] as $key => $value) { $module_source = db_get_all_rows_sql(
if($content['each_agent']){ "SELECT id_agent_module, id_server
$modules[] = $value; FROM tgraph_source
} WHERE id_graph = " .
else{ $content['id_gs']
$modules[] = $value['module']; );
}
} if(isset($module_source) && is_array($module_source)){
} $modules = array();
else{
if ($content['id_agent_module']) {
$modules[] = $content['id_agent_module'];
} else {
// restore to metaconsole database
metaconsole_restore_db();
$module_source = db_get_all_rows_sql("SELECT id_agent_module FROM tgraph_source WHERE id_graph = " . $content['id_gs']);
foreach ($module_source as $key => $value) { foreach ($module_source as $key => $value) {
$modules[$key] = $value['id_agent_module']; $modules[$key]['module'] = $value['id_agent_module'];
} $modules[$key]['server'] = $value['id_server'];
metaconsole_connect($server);
} }
} }
}
$id_graph = 0; $id_graph = 0;
} }
else { else {
@ -6437,7 +6437,8 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
'summatory' => $graphs[0]["summatory_series"], 'summatory' => $graphs[0]["summatory_series"],
'average' => $graphs[0]["average_series"], 'average' => $graphs[0]["average_series"],
'modules_series' => $graphs[0]["modules_series"], 'modules_series' => $graphs[0]["modules_series"],
'id_graph' => $id_graph 'id_graph' => $id_graph,
'type_report' => $type_report
); );
$return['chart'] = graphic_combined_module( $return['chart'] = graphic_combined_module(
@ -6446,14 +6447,14 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
$params_combined $params_combined
); );
break;
case 'data':
break; break;
} }
if ($config['metaconsole']) { if ($type_report == "custom_graph") {
if (is_metaconsole()) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
}
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
} }