diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 32de285b11..66063ed5ab 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -123,12 +123,17 @@ if ($get_module_detail) { $time_from = (string) get_parameter ('time_from', date ('h:iA')); $date_to = (string) get_parameter ('date_to', date ('Y-m-j')); $time_to = (string) get_parameter ('time_to', date ('h:iA')); + $freesearch = (string) get_parameter ('freesearch', ''); + $free_checkbox = (bool) get_parameter ('free_checkbox', false); $formtable->width = '98%'; $formtable->class = "databox"; $formtable->data = array (); $formtable->size = array (); + $moduletype_name = modules_get_moduletype_name( + modules_get_agentmodule_type($module_id)); + $periods = array(SECONDS_5MINUTES =>__('5 minutes'), SECONDS_30MINUTES =>__('30 minutes'), SECONDS_1HOUR =>__('1 hour'), @@ -175,10 +180,19 @@ if ($get_module_detail) { $formtable->data[1][2] .= html_print_input_text('time_to', $time_to, '', 9, 7, true); - html_print_table($formtable); + $freesearch_object = ''; + if (preg_match("/_string/", $moduletype_name)) { + $formtable->data[2][0] = __('Free search') . ' '; + $formtable->data[2][1] = html_print_input_text ('freesearch', $freesearch, '', 20, null, true); + $formtable->data[2][2] = html_print_checkbox('free_checkbox', 1, $free_checkbox, true); + $formtable->data[2][2] .= ' ' . __('Exact phrase'); + $freesearch_object = json_encode( array( + 'value' => io_safe_output($freesearch), + 'exact' => (bool)$free_checkbox + )); + } - $moduletype_name = modules_get_moduletype_name( - modules_get_agentmodule_type($module_id)); + html_print_table($formtable); $offset = (int) get_parameter("offset"); $block_size = (int) $config["block_size"]; @@ -222,10 +236,10 @@ if ($get_module_detail) { } $count = modules_get_agentmodule_data ($module_id, $period, - $date, true, $conexion); + $date, true, $conexion, 'ASC', $freesearch_object); $module_data = modules_get_agentmodule_data ($module_id, $period, - $date, false, $conexion, 'DESC'); + $date, false, $conexion, 'DESC', $freesearch_object); if (empty($module_data)) { $result = array(); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index bcdeb6819c..6d09e2d9a9 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1716,11 +1716,19 @@ function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) * @param int Agent module id * @param int Period of time to check (in seconds) * @param int Top date to check the values. Default current time. + * @param + * @param + * @param string 'ASC' od 'DESC' + * @param string with a json with parameters to filter data + * string object: + * value: Text to search + * exact: Boolean. True if search exact phrase or false to content * * @return array The module value and the timestamp */ function modules_get_agentmodule_data ($id_agent_module, $period, - $date = 0, $trash=false, $conexion = false, $order = 'ASC') { + $date = 0, $trash=false, $conexion = false, $order = 'ASC', + $freesearch = '') { global $config; $module = db_get_row('tagente_modulo', 'id_agente_modulo', @@ -1742,12 +1750,28 @@ function modules_get_agentmodule_data ($id_agent_module, $period, case 17: //async_string case 23: - $sql = sprintf ("SELECT datos AS data, utimestamp - FROM tagente_datos_string - WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d - ORDER BY utimestamp %s", - $id_agent_module, $datelimit, $date, $order); + // Free search is a json with value and exact modifier + $freesearch = json_decode($freesearch, true); + $freesearch_sql = ''; + if (isset($freesearch['value']) && !empty($freesearch['value'])) { + $freesearch_sql = " AND datos "; + if ($freesearch['exact']){ + $freesearch_sql .= "='" . $freesearch['value'] . "' "; + } else { + $freesearch_sql .= " LIKE '%" . $freesearch['value'] . "%' "; + } + } + $sql = sprintf ( + "SELECT datos AS data, utimestamp FROM tagente_datos_string + WHERE id_agente_modulo = %d + %s + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp %s", + $id_agent_module, + $freesearch_sql, + $datelimit, $date, + $order + ); break; //log4x case 24: diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index f5c870dc83..3fceedda4e 100755 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -364,6 +364,19 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri extra_parameters = '&selection_mode=' + selection_mode + '&date_from=' + date_from + '&date_to=' + date_to + '&time_from=' + time_from + '&time_to=' + time_to; } + + // Get the free text in both options + var freesearch = $('#text-freesearch').val(); + if (freesearch != null && freesearch !== '') { + var free_checkbox = $('input[name=free_checkbox]:checked').val(); + extra_parameters += '&freesearch=' + freesearch; + if (free_checkbox == 1) { + extra_parameters += '&free_checkbox=1'; + } else { + extra_parameters += '&free_checkbox=0'; + } + } + title = ; $.ajax({ type: "POST",