From ca4161d1ee352e3b609f53d94ddb82d8686886ce Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Tue, 8 Nov 2016 12:39:28 +0100 Subject: [PATCH] Add feature of timesticks. Ticket: #2494 (cherry picked from commit b369d8b5b4e9a9e73b072d7d3ed80405787de97d) --- pandora_console/include/ajax/module.php | 41 +++++++++++++- .../include/functions_treeview.php | 55 ++++++++++++++++--- .../operation/agentes/status_monitor.php | 27 ++++++++- 3 files changed, 108 insertions(+), 15 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 640ef1acd5..ae4eaed9ce 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -286,8 +286,20 @@ if ($get_module_detail) { } else if (is_numeric($row[$attr[0]]) && !modules_is_string_type($row['module_type']) ) { - $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); + //~ $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); //~ $data[] = (double) $row[$attr[0]]; + switch($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $data[] = human_milliseconds_to_string($row['data']); + else + $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); + break; + default: + $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); + break; + } } else { if ($row[$attr[0]] == '') { @@ -924,12 +936,35 @@ if ($list_modules) { $salida = $config["render_proc_fail"]; break; default: - $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); + switch($module['id_tipo_modulo']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $salida = human_milliseconds_to_string($module['datos']); + else + $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); + break; + default: + $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); + break; + } break; } } else { - $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); + switch($module['id_tipo_modulo']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $salida = human_milliseconds_to_string($module['datos']); + else + $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); + break; + default: + $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); + break; + } + //~ $salida = (number_format($module["datos"], $config['graph_precision'])); } // Show units ONLY in numeric data types if (isset($module["unit"])) { diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index b7d5aaf564..00a7c90ff9 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -184,21 +184,58 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = break; default: //~ if (is_numeric($last_data["datos"])) - //~ $data = "" . format_numeric($last_data["datos"]) . ""; + //~ $data = "" . remove_right_zeros(number_format($last_data["datos"], $config['graph_precision'])) . ""; //~ else //~ $data = "" . substr(io_safe_output($last_data['datos']),0,12) . ""; - if (is_numeric($last_data["datos"])) - $data = "" . remove_right_zeros(number_format($last_data["datos"], $config['graph_precision'])) . ""; - else - $data = "" . substr(io_safe_output($last_data['datos']),0,12) . ""; + switch($module['id_tipo_modulo']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $data = "" . human_milliseconds_to_string($last_data['datos']) . ""; + else + if (is_numeric($last_data["datos"])) + $data = "" . + remove_right_zeros(number_format($last_data["datos"], $config['graph_precision'])) . ""; + else + $data = "" . + substr(io_safe_output($last_data['datos']),0,12) . ""; + break; + default: + if (is_numeric($last_data["datos"])) + $data = "" . + remove_right_zeros(number_format($last_data["datos"], $config['graph_precision'])) . ""; + else + $data = "" . + substr(io_safe_output($last_data['datos']),0,12) . ""; + break; + } break; } } else { - if (is_numeric($last_data["datos"])) - $data = "" . remove_right_zeros(number_format($last_data["datos"], $config['graph_precision'])) . ""; - else - $data = "" . substr(io_safe_output($last_data['datos']),0,12) . ""; + switch($module['id_tipo_modulo']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $data = "" . human_milliseconds_to_string($last_data['datos']) . ""; + else + if (is_numeric($last_data["datos"])) + $data = "" . + remove_right_zeros(number_format($last_data["datos"], $config['graph_precision'])) . ""; + else + $data = "" . + substr(io_safe_output($last_data['datos']),0,12) . ""; + break; + default: + if (is_numeric($last_data["datos"])) + $data = "" . + remove_right_zeros(number_format($last_data["datos"], $config['graph_precision'])) . ""; + else + $data = "" . + substr(io_safe_output($last_data['datos']),0,12) . ""; + break; } if (!empty($last_data['utimestamp'])) { $last_data_str = $data; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index e693fefcfc..e97edc7436 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1278,19 +1278,40 @@ if (!empty($result)) { case 18: case 21: case 31: - if ( $row['datos'] >= 1 ) $salida = $config['render_proc_ok']; else $salida = $config['render_proc_fail']; break; default: - $salida = format_numeric($row['datos']); + switch($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $salida = human_milliseconds_to_string($row['datos']); + else + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + default: + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + } break; } } else { - $salida = format_numeric($row['datos']); + switch($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $salida = human_milliseconds_to_string($row['datos']); + else + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + default: + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + } } // Show units ONLY in numeric data types