diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a2329ab160..73f4627eb7 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2012-09-21 Miguel de Dios + + * operation/agentes/estado_monitores.php: added the small form to + filter the modules/monitors in the agent general view and of course + pagination. + + * include/functions_html.php, operation/events/events.php, + operation/events/export_csv.php, operation/events/sound_events.php, + operation/events/events_list.php, + operation/netflow/nf_live_view.php, operation/tree.php, + operation/agentes/ver_agente.php, operation/agentes/stat_win.php: + cleaned source code style. + 2012-09-21 Junichi Satoh * include/help/ja/help_macros.php: Added a new help file. diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index dba7f40f0b..c8a6e28908 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -509,7 +509,7 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle if ($maxlength == 0) $maxlength = 255; - + if ($size == 0) $size = 10; diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 7caafcc749..0759495c0e 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -155,16 +155,77 @@ switch ($config["dbtype"]) { // TODO: Clean extra_sql $extra_sql = ''; +$status_filter_monitor = (int)get_parameter('status_filter_monitor', -1); +$status_text_monitor = get_parameter('status_text_monitor', ''); +$filter_monitors = (bool)get_parameter('filter_monitors', false); + +$status_filter_sql = '1 = 1'; +if ($status_filter_monitor != -1) { + $status_filter_sql = 'tagente_estado.estado = ' . $status_filter_monitor; +} +$status_text_monitor_sql = '%'; +if (!empty($status_text_monitor)) { + $status_text_monitor_sql = $status_text_monitor . '%'; +} + + +//Count monitors/modules +switch ($config["dbtype"]) { + case "mysql": + case "postgresql": + $sql = sprintf(" + SELECT COUNT(*) + FROM tagente_estado, + (SELECT * + FROM tagente_modulo + WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0 + AND disabled = 0) tagente_modulo + LEFT JOIN tmodule_group + ON tagente_modulo.id_module_group = tmodule_group.id_mg + WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND %s AND %s tagente_estado.utimestamp != 0 + ORDER BY tagente_modulo.id_module_group , %s %s", + $id_agente, $status_text_monitor_sql, $status_filter_sql, $extra_sql, $order['field'], $order['order']); + break; + case "oracle": + $sql = sprintf (" + SELECT COUNT(*)" . + " FROM tagente_estado, tagente_modulo + LEFT JOIN tmodule_group + ON tmodule_group.id_mg = tagente_modulo.id_module_group + WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.id_agente = %d + AND tagente_modulo.nombre LIKE '%s' + AND %s + AND tagente_modulo.delete_pending = 0 + AND tagente_modulo.disabled = 0 + AND tagente_estado.utimestamp != 0 + ORDER BY tagente_modulo.id_module_group , %s %s + ", $id_agente, $status_text_monitor_sql, $status_filter_sql, $order['field'], $order['order']); + break; +} +$count_modules = db_get_all_rows_sql ($sql); +$count_modules = reset($count_modules[0]); + + +//Get monitors/modules // Get all module from agent switch ($config["dbtype"]) { case "mysql": case "postgresql": $sql = sprintf(" - SELECT * FROM tagente_estado, (SELECT * FROM tagente_modulo WHERE id_agente = %d AND delete_pending = 0 AND disabled = 0) tagente_modulo - LEFT JOIN tmodule_group ON tagente_modulo.id_module_group = tmodule_group.id_mg + SELECT * + FROM tagente_estado, + (SELECT * + FROM tagente_modulo + WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0 + AND disabled = 0) tagente_modulo + LEFT JOIN tmodule_group + ON tagente_modulo.id_module_group = tmodule_group.id_mg WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND %s tagente_estado.utimestamp != 0 - ORDER BY tagente_modulo.id_module_group , %s %s", $id_agente, $extra_sql, $order['field'], $order['order']); + AND %s AND %s tagente_estado.utimestamp != 0 + ORDER BY tagente_modulo.id_module_group , %s %s", + $id_agente, $status_text_monitor_sql, $status_filter_sql, $extra_sql, $order['field'], $order['order']); break; // If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table() case "oracle": @@ -178,15 +239,20 @@ switch ($config["dbtype"]) { LEFT JOIN tmodule_group ON tmodule_group.id_mg = tagente_modulo.id_module_group WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.id_agente = %d + AND tagente_modulo.id_agente = %d + AND tagente_modulo.nombre LIKE '%s' + AND %s AND tagente_modulo.delete_pending = 0 AND tagente_modulo.disabled = 0 AND tagente_estado.utimestamp != 0 ORDER BY tagente_modulo.id_module_group , %s %s - ", $id_agente, $order['field'], $order['order']); + ", $id_agente, $status_text_monitor_sql, $status_filter_sql, $order['field'], $order['order']); break; } -$modules = db_get_all_rows_sql ($sql); + +$limit = " LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0); + +$modules = db_get_all_rows_sql ($sql . $limit); if (empty ($modules)) { $modules = array (); } @@ -331,14 +397,34 @@ foreach ($modules as $module) { $data[5] = ui_print_status_image($status, $title, true); - if ($module["id_tipo_modulo"] == 24) { // log4x + + if ($module["id_tipo_modulo"] == 24) { + // log4x switch($module["datos"]) { - case 10: $salida = "TRACE"; $style="font-weight:bold; color:darkgreen;"; break; - case 20: $salida = "DEBUG"; $style="font-weight:bold; color:darkgreen;"; break; - case 30: $salida = "INFO"; $style="font-weight:bold; color:darkgreen;"; break; - case 40: $salida = "WARN"; $style="font-weight:bold; color:darkorange;"; break; - case 50: $salida = "ERROR"; $style="font-weight:bold; color:red;"; break; - case 60: $salida = "FATAL"; $style="font-weight:bold; color:red;"; break; + case 10: + $salida = "TRACE"; + $style="font-weight:bold; color:darkgreen;"; + break; + case 20: + $salida = "DEBUG"; + $style="font-weight:bold; color:darkgreen;"; + break; + case 30: + $salida = "INFO"; + $style="font-weight:bold; color:darkgreen;"; + break; + case 40: + $salida = "WARN"; + $style="font-weight:bold; color:darkorange;"; + break; + case 50: + $salida = "ERROR"; + $style="font-weight:bold; color:red;"; + break; + case 60: + $salida = "FATAL"; + $style="font-weight:bold; color:red;"; + break; } $salida = "$salida"; } @@ -381,8 +467,7 @@ foreach ($modules as $module) { $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module["id_agente_modulo"]."&label=".base64_encode($module["nombre"])."&refresh=600','day_".$win_handle."')"; - // if ($nombre_tipo_modulo != "log4x") - $data[8] .= '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '   '; + $data[8] .= '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '   '; $data[8] .= "" . html_print_image('images/binary.png', true, array("border" => '0', "alt" => "")) . ""; } @@ -411,12 +496,21 @@ function toggle_full_value(id) { ".__('Full list of monitors').""; + +print_form_filter_monitors($status_filter_monitor, $status_text_monitor); if (empty ($table->data)) { - echo '
'.__('This agent doesn\'t have any active monitors').'
'; + if ($filter_monitors) { + echo '
' . __('Any monitors aren\'t with this filter.') . '
'; + } + else { + echo '
' . __('This agent doesn\'t have any active monitors.') . '
'; + } } else { - echo "

".__('Full list of monitors')."

"; + ui_pagination ($count_modules); html_print_table ($table); + ui_pagination ($count_modules); } unset ($table); @@ -429,12 +523,45 @@ ui_require_jquery_file ('cluetip'); \ No newline at end of file + +'; + + $table->data[0][0] = html_print_input_hidden('filter_monitors', 1, true); + $table->data[0][0] .= __('Status:'); + $status_list = array( + -1 => __('All'), + AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'), + AGENT_MODULE_STATUS_CRITICAL_ALERT => __('Alert'), + AGENT_MODULE_STATUS_NORMAL => __('Normal'), + AGENT_MODULE_STATUS_WARNING => __('Warning'), + AGENT_MODULE_STATUS_UNKNOW => __('Unknow')); + $table->data[0][1] = html_print_select ($status_list, + 'status_filter_monitor', $status_filter_monitor, '', '', 0, + true); + $table->data[0][2] = __('Free text for search (*):'); + $table->data[0][3] = html_print_input_text('status_text_monitor', $status_text_monitor, '', 30, 100, true); + $table->data[0][4] = html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"', true); + $table->data[0][4] .= ''; + $table->data[0][5] = '
'; + $table->data[0][5] .= html_print_submit_button(__('Reset'), 'reset', false, 'class="sub upd"', true); + $table->data[0][5] .= '
'; + html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"', true); + $form_text .= html_print_table($table, true); + + $form_text .= ''; + + ui_toggle($form_text, __('Form filter'), __('Form filter')); +} +?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 118412f211..c444f2444a 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -38,7 +38,7 @@ if (! isset ($config['id_user']) && get_parameter("loginhash", 0)) { $_SESSION['id_usuario'] = $loginhash_user; $config["id_user"] = $loginhash_user; - $hash_connection_data = true; + $hash_connection_data = true; } } @@ -108,7 +108,7 @@ $label = base64_decode(get_parameter('label', '')); $("#graph_menu_arrow").click(function(){ if ($("#graph_menu_arrow").attr("src").indexOf("hide") == -1){ - $("#graph_menu_arrow").attr("src", + "/images/graphmenu_arrow_hide.png"); + $("#graph_menu_arrow").attr("src", + "/images/graphmenu_arrow_hide.png"); } else { $("#graph_menu_arrow").attr("src", + "/images/graphmenu_arrow.png"); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index dc27fcbe5a..4083a17e86 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -188,7 +188,7 @@ if (is_ajax ()) { $first_elements = array(); foreach ($idAgents as $idA) { - + $row = explode ('|', $idA); $server_name = $row[0]; $id_agent = $row [1]; @@ -217,20 +217,20 @@ if (is_ajax ()) { // Add agent and server foreach ($temp as $element_key => $element_value) { - + //$temp_element[$element_key . '|' . $id_agent . '|' . $server_name] = $element_value; if (!isset($temp_element[$element_value]) && $first) $temp_element[$element_value] = $element_key . '|' . $id_agent . '|' . $server_name; else if (isset($temp_element[$element_value])) $temp_element[$element_value] .= ';' . $element_key . '|' . $id_agent . '|' . $server_name; - + } } // If the result array is empty then there aren't common modules else if (!$first) unset($temp_element); - + // First iteration flag if (empty($nameModules) && $first == true) @@ -269,7 +269,7 @@ if (is_ajax ()) { io_safe_output($custom_condition) . ' AND delete_pending = 0 AND id_agente IN (' . implode(',', $idAgents) . ')'; - + if($selection_mode == 'common') { $sql .= ' AND ( SELECT count(nombre) @@ -307,8 +307,8 @@ if (is_ajax ()) { $force_local_modules = (int) get_parameter ('force_local_modules', 0); if ($agentName != null) { - $search = array(); - $search['name'] = io_safe_output($agentName); + $search = array(); + $search['name'] = io_safe_output($agentName); } else $search = false; @@ -367,7 +367,8 @@ if (is_ajax ()) { echo ''.__('Last contact').': '.human_time_comparation($agent['ultimo_contacto']).'
'; echo ''.__('Last remote contact').': '.human_time_comparation($agent['ultimo_contacto_remoto']).'
'; - $sql = sprintf ('SELECT tagente_modulo.descripcion, tagente_modulo.nombre + $sql = sprintf ('SELECT tagente_modulo.descripcion, + tagente_modulo.nombre FROM tagente_estado, tagente_modulo WHERE tagente_modulo.id_agente = %d AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo @@ -445,7 +446,7 @@ if (is_ajax ()) { echo html_print_image("images/" . modules_get_type_icon ($agentmoduletype), true) . '
'; echo ''.__('Module group').': '; $modulegroup = modules_get_modulegroup_name (modules_get_agentmodule_modulegroup ($module['id_agente_modulo'])); - if($modulegroup === false){ + if ($modulegroup === false) { echo __('None').'
'; } else{ @@ -454,7 +455,7 @@ if (is_ajax ()) { echo ''.__('Agent').': '; echo ui_print_truncate_text(modules_get_agentmodule_agent_name($module['id_agente_modulo']), 'agent_small', false, true, false).'
'; - if($module['id_tipo_modulo'] == 18) { + if ($module['id_tipo_modulo'] == 18) { echo ''.__('Address').': '; // Get the IP/IPs from the module description @@ -484,14 +485,14 @@ if (is_ajax ()) { echo ui_print_truncate_text($group['nombre'], GENERIC_SIZE_TEXT, false, true, false) . ''; echo ''.__('Parent').': '; if ($group['parent'] == 0) { - echo __('None').'
'; + echo __('None') . '
'; } else { $group_parent = db_get_row ('tgrupo', 'id_grupo', $group['parent']); echo html_print_image("images/groups_small/" . groups_get_icon ($group['parent']) . ".png", true); - echo $group_parent['nombre'].'
'; + echo $group_parent['nombre'] . '
'; } - echo ''.__('Sons').': '; + echo '' . __('Sons') . ': '; $groups_sons = db_get_all_fields_in_table ('tgrupo', 'parent', $group['id_grupo']); if ($groups_sons === false) { echo __('None').'
'; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 41c61be976..5115c92dc6 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -240,14 +240,14 @@ if ($config["pure"] == 0) { // Sound events $sound_event['active'] = false; - $sound_event['text'] = '' . html_print_image('images/music_note.png', true, array('title' => __('Sound events'))) . ''; + $sound_event['text'] = '' . html_print_image('images/music_note.png', true, array('title' => __('Sound events'))) . ''; // If the user has administrator permission display manage tab if (check_acl ($config["id_user"], 0, "IW")) { // Manage events $manage_events['active'] = false; $manage_events['text'] = '' . - html_print_image("images/setup.png", true, array ("title" => __('Manage events'))) . ''; + html_print_image("images/setup.png", true, array ("title" => __('Manage events'))) . ''; $onheader = array('manage_events' => $manage_events, 'separator' => '', @@ -554,7 +554,7 @@ $(document).ready( function() { // Change state image $("#status_img_"+id).attr ("src", "images/hourglass.png"); $("#status_img_"+id).attr ("title", ); - $("#status_img_"+id).attr ("alt", ); + $("#status_img_"+id).attr ("alt", ); // Remove row due to new state if (($("#status").val() == 0) || ($("#status").val() == 1)){ diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 7bfc72914a..5dd2b9d5c3 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -65,7 +65,7 @@ if (is_ajax()) { $values['search'] = get_parameter('search'); $values['text_agent'] = get_parameter('text_agent'); $values['pagination'] = get_parameter('pagination'); - $values['event_view_hr'] = get_parameter('event_view_hr'); + $values['event_view_hr'] = get_parameter('event_view_hr'); $values['id_user_ack'] = get_parameter('id_user_ack'); $values['group_rep'] = get_parameter('group_rep'); $values['tag'] = get_parameter('tag'); @@ -82,7 +82,7 @@ if (is_ajax()) { } } - if ($update_event_filter){ + if ($update_event_filter) { $values = array(); $id = get_parameter('id'); $values['id_name'] = get_parameter('id_name'); @@ -100,9 +100,10 @@ if (is_ajax()) { $values['filter_only_alert'] = get_parameter('filter_only_alert'); $values['id_group_filter'] = get_parameter('id_group_filter'); - $result = db_process_sql_update('tevent_filter', $values, array('id_filter' => $id)); + $result = db_process_sql_update('tevent_filter', + $values, array('id_filter' => $id)); - if ($result === false){ + if ($result === false) { echo 'error'; } else { @@ -115,7 +116,7 @@ if (is_ajax()) { echo json_encode($event_filter); } - + return; } @@ -509,7 +510,7 @@ $result = db_get_all_rows_sql ($sql); // Delete rnum field generated by oracle_recode_query() function if (($config['dbtype'] == 'oracle') && ($result !== false)) { for ($i=0; $i < count($result); $i++) { - unset($result[$i]['rnum']); + unset($result[$i]['rnum']); } } @@ -863,7 +864,7 @@ foreach ($result as $event) { $data[$i] .= ''; $data[$i] .= html_print_image ("images/eye.png", true, - array ("title" => __('Show more'))); + array ("title" => __('Show more'))); $data[$i] .= ' '; // Create incident from this event @@ -911,7 +912,7 @@ foreach ($result as $event) { if($event["id_alert_am"] != 0) { $string .= ''; } - $string .= ''; + $string .= ''; $data = array($string); diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php index 919ad0f9fa..aa253eb841 100644 --- a/pandora_console/operation/events/export_csv.php +++ b/pandora_console/operation/events/export_csv.php @@ -66,13 +66,13 @@ switch ($status) { if ($search != "") $filter[] = 'evento LIKE "%'.io_safe_input($search).'%"'; if (($event_type != "all") OR ($event_type != 0)) - $filter['event_type'] = $event_type; + $filter['event_type'] = $event_type; if ($severity != -1) $filter[] = 'criticity >= '.$severity; if ($id_agent == -2) { $text_agent = (string) get_parameter("text_agent", __("All")); - + switch ($text_agent) { case __('All'): @@ -106,9 +106,9 @@ if ($id_agent != -1) $filter['id_agente'] = $id_agent; if ($id_event != -1) - $filter['id_evento'] = $id_event; + $filter['id_evento'] = $id_event; -$timestamp_filter = ''; +$timestamp_filter = ''; if ($event_view_hr > 0) { $unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds $timestamp_filter = " AND (utimestamp > $unixtime OR estado = 2)"; @@ -125,7 +125,7 @@ if ($tag != "") { //$filter['order'] = 'timestamp DESC'; $now = date ("Y-m-d"); -// Show contentype header +// Show contentype header Header ("Content-type: text/txt"); header ('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.txt"'); diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index 77f798ef3b..b85cc5f9f7 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -158,7 +158,7 @@ function forgetPreviousEvents() { running = true; }, "json" - ); + ); } function check_event() { diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 57ef87d7d9..419ebeb3b2 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -356,7 +356,7 @@ if ($draw != '') { $("#radiobtn0001").attr("checked", ""); $("#radiobtn0002").attr("checked", "checked"); } - }); + }); // Shows update filter button $("#submit-update_button").css("visibility", ""); diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 9f292fe66a..b574bc46f0 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -536,20 +536,20 @@ if (is_ajax ()) switch ($lessBranchs) { case 0: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); + html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); + html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); break; case 1: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); + html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); + html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); break; case 2: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); + html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); + html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); break; case 3: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); + html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); + html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); break; } @@ -742,7 +742,7 @@ treeview_printTree($activeTab); function loadSubTree(type, div_id, less_branchs, id_father) { hiddenDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv'); loadDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv'); - pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree')); + pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree')); //If has yet ajax request running if (loadDiv == 2)