diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 953b9639c8..85f37c198e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2013-04-12 Sancho Lerena + + * include/functions.php: Added a new function to detect + when a string data is a snapshot or now (by counting + \n > 2). + + * operation/agentes/datos_agente.php: Removed duped + column with datetime information on string data. + + * operation/agentes/estado_monitores.php: Using snapshot + detect function. + 2013-04-12 Sergio Martin * include/functions_graph.php: Optimize the event graphs diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 679dabb2e9..d9b13027bd 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1718,4 +1718,26 @@ function copy_dir($src, $dst) { } closedir($dir); } + +/** +* Returns 1 if this is Snapshot data, 0 otherwise +* Looks for two or more carriage returns. +*/ + +function is_snapshot_data ($data){ + + // TODO IDEA: In the future, we can set a variable in setup + // to define how many \n must have a snapshot to define it's + // a snapshot. I think two or three is a good value anyway. + + $temp = array(); + $count = preg_match_all ("/\n/", $data, $temp); + + if ($count > 2) + return 1; + else + return 0; +} + + ?> diff --git a/pandora_console/operation/agentes/datos_agente.php b/pandora_console/operation/agentes/datos_agente.php index ca208446fe..872575c852 100755 --- a/pandora_console/operation/agentes/datos_agente.php +++ b/pandora_console/operation/agentes/datos_agente.php @@ -112,8 +112,7 @@ else if (preg_match ("/string/", $moduletype_name)) { $columns = array( "Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "left"), - "Data" => array("datos", "modules_format_data", "align" => "left"), - "Time" => array("utimestamp", "modules_format_time", "align" => "center") + "Data" => array("datos", "modules_format_data", "align" => "left") ); } else { diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index e29447ae85..0fd9e73b18 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -470,10 +470,10 @@ foreach ($modules as $module) { $module_value = io_safe_output($module["datos"]); } - // There are carriage returns here ? // If carriage returns present... then is a "Snapshot" data (full command output) - if (($config['command_snapshot']) && (preg_match ("/[\n]+/i", io_safe_output($module["datos"])))) { - + $is_snapshot = is_snapshot_data ( $module_value ); + + if (($config['command_snapshot']) && ($is_snapshot)){ $handle = "snapshot"."_".$module["id_agente_modulo"]; $url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; $win_handle = dechex(crc32($handle)); @@ -635,4 +635,4 @@ function print_form_filter_monitors($status_filter_monitor = -1, ui_toggle($form_text, __('Form filter'), __('Form filter')); } -?> \ No newline at end of file +?>