From ff0731ba9658ac3880d4fb1b3422710684cee34c Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 12 Feb 2013 14:57:01 +0000 Subject: [PATCH] 2013-02-12 Sergio Martin * include/functions_modules.php operation/agentes/estado_ultimopaquete.php operation/agentes/estado_monitores.php: Protect the data of the string modules from the numeric format in the visualization for bug 3600790 Added snapshot feature to the data view of the modules git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7631 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 ++++ pandora_console/include/functions_modules.php | 13 ++++++ .../operation/agentes/estado_monitores.php | 2 +- .../agentes/estado_ultimopaquete.php | 46 +++++++++++++++++-- 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0b31af68f5..9b6f588651 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2013-02-12 Sergio Martin + + * include/functions_modules.php + operation/agentes/estado_ultimopaquete.php + operation/agentes/estado_monitores.php: Protect the data + of the string modules from the numeric format + in the visualization for bug 3600790 + Added snapshot feature to the data view of the modules + 2013-02-12 Sergio Martin * godmode/agentes/configurar_agente.php: Changed the call of diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 3578627588..5b730e6b7f 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -699,6 +699,19 @@ function modules_get_type_name ($id_type) { return (string) db_get_value ('nombre', 'ttipo_modulo', 'id_tipo', (int) $id_type); } +/** + * Know if a module type is a string or not + * + * @param int $id_type Type id + * + * @return bool true if string. false if not + */ +function modules_is_string_type ($id_type) { + $type_name = modules_get_type_name($id_type); + + return (bool)preg_match('/_string$/', $type_name); +} + /** * Get the icon of a module type * diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 536dba51d4..2b60fdb811 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -430,7 +430,7 @@ foreach ($modules as $module) { $salida = "$salida"; } else { - if (is_numeric($module["datos"])){ + if (is_numeric($module["datos"]) && !modules_is_string_type($module['id_tipo_modulo'])){ $salida = format_numeric($module["datos"]); // Show units ONLY in numeric data types diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index a6dc1b8a0c..d1b9504362 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -459,9 +459,9 @@ foreach ($modules as $module) { else { $graph_type = return_graphtype ($module["id_tipo_modulo"]); - if ((is_numeric($module["datos"])) && ($module["id_tipo_modulo"] != 23)) { + if ((is_numeric($module["datos"])) && !modules_is_string_type($module['id_tipo_modulo'])) { echo ""; - echo format_for_graph($module["datos"] ); + echo format_for_graph($module["datos"]); } else { @@ -469,7 +469,36 @@ foreach ($modules as $module) { else $colspan= 1; echo ""; - io_safe_output(io_safe_output($module["datos"]), 45, false); + + $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"])))) { + + $handle = "snapshot"."_".$module["id_agente_modulo"]; + $url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; + $win_handle=dechex(crc32($handle)); + + $link ="winopeng_var('operation/agentes/snapshot_view.php?id=".$module["id_agente_modulo"]."&refr=".$module["current_interval"]."&label=".$module["nombre"]."','".$win_handle."', 700,480)"; + + $out = '' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '   '; + } + else { + $sub_string = substr(io_safe_output($module["datos"]),0, 12); + + if ($module_value == $sub_string) { + $out = $module_value; + } + else { + $out = "" . + '' . $sub_string . ' ' . + "" . html_print_image("images/rosette.png", true) . "" . ""; + } + } + + echo $out; } echo ""; @@ -522,4 +551,15 @@ foreach ($modules as $module) { echo ""; } echo ''; +?> + + ?> \ No newline at end of file