From ca5b9bd62f8d9f644528c746708232188e76d8b9 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Tue, 26 May 2015 12:37:14 +0200 Subject: [PATCH] Add new option, when is active data of modules type is proc, show ok or fail. Tiquet: #1996 --- .../godmode/setup/setup_visuals.php | 10 ++++++++ pandora_console/include/functions_config.php | 9 +++++-- pandora_console/include/functions_modules.php | 24 +++++++++++++++++++ .../operation/agentes/estado_monitores.php | 21 +++++++++++++++- .../operation/agentes/status_monitor.php | 21 +++++++++++++++- 5 files changed, 81 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 2aba54efe7..b8dbf0d76e 100644 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -492,6 +492,16 @@ $table->data[$row][1] = html_print_input_text ('custom_graph_widht', $row++; +$table->data[$row][0] = __('Render data of module type is proc.'); +$table->data[$row][1] = __('Yes') . ' ' . + html_print_radio_button ('render_proc', 1, '', + $config["render_proc"], true) . + '  '; +$table->data[$row][1] .= __('No') . ' ' . + html_print_radio_button ('render_proc', 0, '', + $config["render_proc"], true); + +$row++; echo '
'; html_print_input_hidden ('update_config', 1); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index ddaa7cfd96..ed07d8a270 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -453,7 +453,9 @@ function config_update_config () { $error_update[] = __('Show the group name instead the group icon.'); if (!config_update_value ('custom_graph_widht', get_parameter('custom_graph_widht'))) $error_update[] = __('Default line thickness for the Custom Graph.'); - + if (!config_update_value ('render_proc', (int) get_parameter('render_proc', 0))) + $error_update[] = __('Render data of module type is proc.'); + $interval_values = get_parameter ('interval_values'); // Add new interval value if is provided @@ -1201,7 +1203,10 @@ function config_process_config () { if (!isset($config['custom_graph_widht'])) { config_update_value ('custom_graph_widht', 1); } - + if (!isset($config['render_proc'])) { + config_update_value ('render_proc', 0); + } + if (!isset($config['command_snapshot'])) { config_update_value ('command_snapshot', 1); } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index dade8717c3..18488de58a 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1683,6 +1683,8 @@ function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) */ function modules_get_agentmodule_data ($id_agent_module, $period, $date = 0, $trash=false, $conexion = false, $order = 'ASC') { + global $config; + $module = db_get_row('tagente_modulo', 'id_agente_modulo', $id_agent_module); @@ -1719,6 +1721,28 @@ function modules_get_agentmodule_data ($id_agent_module, $period, ORDER BY utimestamp %s", $id_agent_module, $datelimit, $date, $order); break; + case 2: + case 6: + case 9: + case 18: + case 21: + case 31: + if ( $config["render_proc"] ) { + $sql = sprintf ("SELECT IF(datos >= 1, 'OK', 'FAIL') as data, utimestamp + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp %s", + $id_agent_module, $datelimit, $date, $order); + }else{ + $sql = sprintf ("SELECT datos AS data, utimestamp + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp %s", + $id_agent_module, $datelimit, $date, $order); + } + break; default: $sql = sprintf ("SELECT datos AS data, utimestamp FROM tagente_datos diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 2fef575c64..777d55c714 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -598,7 +598,26 @@ foreach ($modules as $module) { } else { if (is_numeric($module["datos"]) && !modules_is_string_type($module['id_tipo_modulo'])){ - $salida = format_numeric($module["datos"]); + if ( $config["render_proc"] ){ + switch($module["id_tipo_modulo"]) { + case 2: + case 6: + case 9: + case 18: + case 21: + case 31: + if ($module["datos"]>=1) + $salida ='OK'; + else + $salida = 'FAIL'; + break; + default: + $salida = format_numeric($module["datos"]); + break; + } + }else{ + $salida = format_numeric($module["datos"]); + } // Show units ONLY in numeric data types if (isset($module["unit"])){ diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 1d0e9bf78f..d780b8dd39 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1204,7 +1204,26 @@ foreach ($result as $row) { $row['min_critical'], $row['str_critical']); if (is_numeric($row["datos"])) { - $salida = format_numeric($row["datos"]); + if ( $config["render_proc"] ){ + switch($row["module_type"]) { + case 2: + case 6: + case 9: + case 18: + case 21: + case 31: + if ( $row["datos"] >= 1 ) + $salida ='OK'; + else + $salida = 'FAIL'; + break; + default: + $salida = format_numeric($row["datos"]); + break; + } + }else{ + $salida = format_numeric($row["datos"]); + } // Show units ONLY in numeric data types if (isset($row["unit"])) {