diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f59dc273d0..6645113104 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,18 @@ +2008-06-27 Esteban Sanchez + + * include/functions_db.php: Renamed variable from spanish. + + * include/functions_reporting.php: Splitted + agents_detailed_reporting() into agent_detailed_reporting() so now + it's possible to get the report of a single agent. Also the table + width of this report was reduced a bit to fit well in the console. + + * include/styles/pandora.css: Added style to agent reportings, + basically a border. + + * operation/reporting/reporting_viewer.php: Separate each report into + its own table. Flush the result to improve speed. Style correction. + 2008-06-26 Esteban Sanchez * images/console/background/africa.jpg, diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 398596f418..d01748f85e 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -384,12 +384,12 @@ function gime_idgroup_from_idevent ($id_event) { /** * Get name of an agent. * - * @param id_agente Agent id. + * @param id_agent Agent id. * * @return Name of the given agent. */ -function dame_nombre_agente ($id_agente) { - return (string) get_db_value ('nombre', 'tagente', 'id_agente', (int) $id_agente); +function dame_nombre_agente ($id_agent) { + return (string) get_db_value ('nombre', 'tagente', 'id_agente', (int) $id_agent); } /** diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 6b1c992b4d..f0c5e2e7a8 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -428,9 +428,98 @@ function general_group_reporting ($id_group, $return = false) { } /** - * Get a detailed report of agents in a group. + * Get a detailed report of an agent * - * It + * @param $id_agent Agent to get the report. + * @param $period Period of time of the desired report. + * @param $date Beggining date of the report (current date by default). + * @param $return Flag to return or echo the report (by default). + */ +function agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $return = false) { + $output = ''; + $n_a_string = lang_string ('N/A').'(*)'; + $monitors = array (); + $table_modules->data = array (); + $table_modules->head = array (); + $table_alerts->data = array (); + + /* Show modules in agent */ + $modules = get_modules_in_agent ($id_agent); + $output .= '
'; + $output .= '

'.lang_string ('agent').' - '.dame_nombre_agente ($id_agent).'

'; + $output .= '

'.lang_string ('modules').'

'; + $data = array (); + foreach ($modules as $module) { + if ($module['descripcion'] != $n_a_string && $module['descripcion'] != '') + $data[0] = $module['descripcion']; + else + $data[0] = $module['nombre']; + $module_name = giveme_module_type ($module['id_tipo_modulo']); + if (is_module_proc ($module_name)) { + array_push ($monitors, $module); + } + array_push ($table_modules->data, $data); + } + $output .= print_table ($table_modules, true); + + /* Show alerts in agent */ + $alerts = get_alerts_in_agent ($id_agent); + foreach ($alerts as $alert) { + $fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date); + if (! $fires) { + continue; + } + $alert_type = get_db_row ('talerta', 'id_alerta', $alert['id_alerta']); + $data = array (); + $data[0] = $alert_type['nombre']; + $data[1] = $alert['descripcion']; + $data[2] = $alert['dis_min']; + $data[3] = $alert['dis_max']; + $data[4] = $alert['time_threshold']; + $data[5] = get_alert_last_fire_timestamp_in_period ($alert['id_agente_modulo'], $period, $date); + $data[6] = $fires; + + array_push ($table_alerts->data, $data); + } + if (sizeof ($table_alerts->data)) { + $output .= '

'.lang_string ('alerts').'

'; + $output .= print_table ($table_alerts, true); + } + + /* Show monitor status in agent (if any) */ + if (sizeof ($monitors) == 0) { + $output .= '
'; + if (! $return) + echo $output; + return $output; + } + $table_monitors->data = array (); + foreach ($monitors as $monitor) { + $downs = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date); + if (! $downs) { + continue; + } + $data = array (); + if ($monitor['descripcion'] != $n_a_string && $monitor['descripcion'] != '') + $data[0] = $monitor['descripcion']; + else + $data[0] = $monitor['nombre']; + $data[1] = get_monitor_last_down_timestamp_in_period ($monitor['id_agente_modulo'], $period, $date); + array_push ($table_monitors->data, $data); + } + if (sizeof ($table_monitors->data)) { + $output .= '

'.lang_string ('monitors').'

'; + $output .= print_table ($table_monitors, true); + } + $output .= ''; + + if (! $return) + echo $output; + return $output; +} + +/** + * Get a detailed report of agents in a group. * * @param $id_group Group to get the report * @param $return Flag to return or echo the report (by default). @@ -439,9 +528,9 @@ function agents_detailed_reporting ($id_group, $period = 0, $date = 0, $return = $output = ''; $agents = get_agents_in_group ($id_group); - $table_modules->width = '750px'; - $table_alerts->width = '750px'; - $table_monitors->width = '750px'; + $table_modules->width = '700px'; + $table_alerts->width = '700px'; + $table_monitors->width = '700px'; $table_monitors->align = array (); $table_monitors->align[1] = 'right'; $table_monitors->head = array (); @@ -457,77 +546,12 @@ function agents_detailed_reporting ($id_group, $period = 0, $date = 0, $return = $table_alerts->head[6] = lang_string ('times_fired'); $agents = get_agents_in_group ($id_group); - $n_a_string = lang_string ('N/A').'(*)'; foreach ($agents as $agent) { - $monitors = array (); - $table_modules->data = array (); - $table_modules->head = array (); - $table_alerts->data = array (); - - $modules = get_modules_in_agent ($agent['id_agente']); - - /* Show modules in agent */ - $output .= '

'.lang_string ('agent').' - '.$agent['nombre'].'

'; - $output .= '

'.lang_string ('modules').'

'; - $data = array (); - foreach ($modules as $module) { - if ($module['descripcion'] != $n_a_string && $module['descripcion'] != '') - $data[0] = $module['descripcion']; - else - $data[0] = $module['nombre']; - $module_name = giveme_module_type ($module['id_tipo_modulo']); - if (is_module_proc ($module_name)) { - array_push ($monitors, $module); - } - array_push ($table_modules->data, $data); - } - $output .= print_table ($table_modules, true); - - /* Show alerts in agent */ - $alerts = get_alerts_in_agent ($agent['id_agente']); - foreach ($alerts as $alert) { - $fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date); - if (! $fires) { - continue; - } - $alert_type = get_db_row ('talerta', 'id_alerta', $alert['id_alerta']); - $data = array (); - $data[0] = $alert_type['nombre']; - $data[1] = $alert['descripcion']; - $data[2] = $alert['dis_min']; - $data[3] = $alert['dis_max']; - $data[4] = $alert['time_threshold']; - $data[5] = get_alert_last_fire_timestamp_in_period ($alert['id_agente_modulo'], $period, $date); - $data[6] = $fires; - - array_push ($table_alerts->data, $data); - } - if (sizeof ($table_alerts->data)) { - $output .= '

'.lang_string ('alerts').'

'; - $output .= print_table ($table_alerts, true); - } - - /* Show monitor status in agent (if any) */ - if (sizeof ($monitors) == 0) { - continue; - } - $table_monitors->data = array (); - foreach ($monitors as $monitor) { - $downs = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date); - if (! $downs) { - continue; - } - $data = array (); - if ($monitor['descripcion'] != $n_a_string && $monitor['descripcion'] != '') - $data[0] = $monitor['descripcion']; - else - $data[0] = $monitor['nombre']; - $data[1] = get_monitor_last_down_timestamp_in_period ($monitor['id_agente_modulo'], $period, $date); - array_push ($table_monitors->data, $data); - } - if (sizeof ($table_monitors->data)) { - $output .= '

'.lang_string ('monitors').'

'; - $output .= print_table ($table_monitors, true); + $output .= agent_detailed_reporting ($agent['id_agente'], $period, $date, true); + if (!$return) { + echo $output; + $output = ''; + flush (); } } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index c4d497b45a..272ddbf948 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -717,3 +717,12 @@ div#main_pure { float: left; width: 300px; } + +.agent_reporting { + margin: 5px; + padding: 5px; +} + +.report_table, .agent_reporting { + border: #CCC outset 3px; +} diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 4711a7857e..01a9e0e786 100644 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -113,19 +113,18 @@ if ($datetime > time ()) { return; } -$table->data = array (); $table->size = array (); $table->style = array (); $table->width = '750px'; -$table->class = 'databox'; +$table->class = 'databox report_table'; $table->rowclasses = array (); $group_name = dame_grupo ($report['id_group']); $sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $id_report); $contents = get_db_all_rows_sqlfree ($sql); foreach ($contents as $content) { - unset ($modules); - unset ($weights); + $table->data = array (); + $module_name = get_db_value ('nombre', 'tagente_modulo', 'id_agente_modulo', $content['id_agent_module']); $agent_name = dame_nombre_agente_agentemodulo ($content['id_agent_module']); @@ -155,7 +154,7 @@ foreach ($contents as $content) { while ($content2 = mysql_fetch_array($res2)) { $weight = $content2["weight"]; $content['id_agent_module'] = $content2["id_agent_module"]; - if (!isset($modules)){ + if (!isset ($modules)) { $modules = $content['id_agent_module']; $weights = $weight; } else { @@ -163,6 +162,8 @@ foreach ($contents as $content) { $weights = $weights.",".$weight; } } + unset ($modules); + unset ($weights); $data = array (); $data[0] = '

'.lang_string ('custom_graph').'

'; $data[1] = "

".$graph["name"]."

"; @@ -381,8 +382,8 @@ foreach ($contents as $content) { break; } + print_table ($table); + flush (); } -print_table ($table); - ?>