fixed autocombined report metaconsole

Former-commit-id: f277a1302c0b84ca0417693673ca3da0a4956f6c
This commit is contained in:
daniel 2018-12-12 16:13:31 +01:00
parent ca414d30b6
commit 358532c4a8
3 changed files with 62 additions and 44 deletions

View File

@ -1082,13 +1082,15 @@ You can of course remove the warnings, that's why we include the source and do n
WHERE tagente.id_agente = tagent_module_log.id_agent AND tagente.disabled = 0'; WHERE tagente.id_agente = tagent_module_log.id_agent AND tagente.disabled = 0';
} }
$all_agent_log = db_get_all_rows_sql($sql_log_report); $all_agent_log = db_get_all_rows_sql($sql_log_report);
foreach ($all_agent_log as $key => $value) { if(isset($all_agent_log) && is_array($all_agent_log)){
$agents2[$value['id_agente']] = $value['alias']; foreach ($all_agent_log as $key => $value) {
$agents2[$value['id_agente']] = $value['alias'];
}
} }
if ((empty($agents2)) || $agents2 == -1) $agents = array(); if ((empty($agents2)) || $agents2 == -1) $agents = array();
$agents_select = array(); $agents_select = array();
if (is_array($id_agents) || is_object($id_agents)){ if (is_array($id_agents) || is_object($id_agents)){
foreach ($id_agents as $id) { foreach ($id_agents as $id) {

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,8 +1211,8 @@ 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 = ' .
@ -1340,12 +1352,12 @@ function graphic_combined_module (
$data_module_graph['id_module_type'] = $module_data['id_tipo_modulo']; $data_module_graph['id_module_type'] = $module_data['id_tipo_modulo'];
$data_module_graph['module_type'] = modules_get_moduletype_name($data_module_graph['id_module_type']); $data_module_graph['module_type'] = modules_get_moduletype_name($data_module_graph['id_module_type']);
$data_module_graph['uncompressed'] = is_module_uncompressed($data_module_graph['module_type']); $data_module_graph['uncompressed'] = is_module_uncompressed($data_module_graph['module_type']);
$data_module_graph['w_min'] = $module_data['min_warning']; $data_module_graph['w_min'] = $module_data['min_warning'];
$data_module_graph['w_max'] = $module_data['max_warning']; $data_module_graph['w_max'] = $module_data['max_warning'];
$data_module_graph['w_inv'] = $module_data['warning_inverse']; $data_module_graph['w_inv'] = $module_data['warning_inverse'];
$data_module_graph['c_min'] = $module_data['min_critical']; $data_module_graph['c_min'] = $module_data['min_critical'];
$data_module_graph['c_max'] = $module_data['max_critical']; $data_module_graph['c_max'] = $module_data['max_critical'];
$data_module_graph['c_inv'] = $module_data['critical_inverse']; $data_module_graph['c_inv'] = $module_data['critical_inverse'];
$data_module_graph['module_id'] = $agent_module_id; $data_module_graph['module_id'] = $agent_module_id;
//stract data //stract data
@ -1357,7 +1369,7 @@ function graphic_combined_module (
$i $i
); );
$series_suffix = $i; $series_suffix = $i;
//convert to array graph and weight //convert to array graph and weight
foreach ($array_data_module as $key => $value) { foreach ($array_data_module as $key => $value) {
@ -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

@ -6343,13 +6343,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") {
$id_meta = metaconsole_get_id_server($content["server_name"]); if (is_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);
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';
@ -6373,30 +6378,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 {
@ -6436,7 +6436,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(
@ -6445,13 +6446,13 @@ 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") {
metaconsole_restore_db(); if (is_metaconsole()) {
metaconsole_restore_db();
}
} }
return reporting_check_structure_content($return); return reporting_check_structure_content($return);