diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 7be51aa924..6745d9a931 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -184,12 +184,14 @@ if ($moduleFilter != 0) { $where .= ' AND id_agent_module = ' . $moduleFilter; } +/* // Filter report items created from metaconsole in normal console list and the opposite if (defined('METACONSOLE') and $config['metaconsole'] == 1) { $where .= ' AND ((server_name IS NOT NULL AND length(server_name) != 0) OR type IN (\'general\',\'SLA\',\'exception\',\'top_n\'))'; } else $where .= ' AND ((server_name IS NULL OR length(server_name) = 0) OR type IN (\'general\',\'SLA\',\'exception\',\'top_n\'))'; +*/ switch ($config["dbtype"]) { case "mysql": diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index adbe187e9f..05ad96fdba 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -473,24 +473,14 @@ function human_time_description_raw ($seconds, $exactly = false, $units = 'large if ($mins != 0) { $seconds = $seconds - ($mins * 60); - if ($hours == 0) { - $returnTime .= "$mins $minutesString "; - } - else { - $returnTime = sprintf("%02d", $hours) . ':' . - sprintf("%02d", $mins); - } + $returnTime .= "$mins $minutesString "; + } + $seconds = (int) $seconds; + if ($seconds != 0) { - if ($hours == 0) { - $returnTime .= "$seconds $secondsString "; - } - else { - $returnTime = sprintf("%02d",$hours) . ':' . - sprintf("%02d",$mins) . ':' . - sprintf("%02d",$seconds); - } + $returnTime .= "$seconds $secondsString "; } $return = ' '; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index dade8717c3..ead279ceab 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1398,14 +1398,8 @@ function modules_get_count_datas($id_agent_module, $date_init, $date_end) { return ($diff / $interval); } -function modules_get_data_with_value($id_agent_module, $date_init, - $date_end, $value, $split_interval = false) { - - global $config; - - // TODO REMOVE THE TIME IN PLANNED DOWNTIME - - // TODO FOR OTHER KIND OF DATA +function modules_get_count_data_with_value($id_agent_module, $date_init, + $date_end, $value) { if (!is_numeric($date_init)) { $date_init = strtotime($date_init); @@ -1415,56 +1409,47 @@ function modules_get_data_with_value($id_agent_module, $date_init, $date_end = strtotime($date_end); } - $sql = " - SELECT * + $sql = "SELECT * FROM tagente_datos WHERE - datos = " . (int)$value . " - AND id_agente_modulo = " . (int)$id_agent_module . " + id_agente_modulo = " . (int)$id_agent_module . " AND (utimestamp >= " . $date_init . " AND utimestamp <= " . $date_end . ")"; - $data = db_get_all_rows_sql($sql, - $config['history_db_enabled']); + $data = db_get_all_rows_sql($sql, $config['history_db_enabled']); if (empty($data)) { $data = array(); } - if ($split_interval) { - $temp = array(); - $previous_utimestamp = false; - foreach ($data as $row) { - if ($previous_utimestamp === false) { - $previous_utimestamp = $row['utimestamp']; - - $temp[] = $row; + $interval = modules_get_interval($id_agent_module); + + $total_time_with_value = 0; + $on_value_detected = false; + $timestamp_with_value = null; + + foreach ($data as $row) { + if ($row['datos'] == $value) { + if (!$on_value_detected) { + $timestamp_with_value = $row['utimestamp']; + $on_value_detected = true; } - else { - $diff = $row['utimestamp'] - $previous_utimestamp; + } + else { + if ($on_value_detected) { + $total_time_with_value + += $row['utimestamp'] - $timestamp_with_value; - $interval = modules_get_interval($id_agent_module); - - if ($diff > $interval) { - $fake_count = (int)($diff / $interval); - - $fake = $row; - for ($iterator = 1; $iterator <= $fake_count; $iterator++) { - $fake['utimestamp'] = $previous_utimestamp + ($iterator * $interval); - $temp[] = $fake; - } - } - else { - $temp[] = $row; - } - - $previous_utimestamp = $row['utimestamp']; - - $data = $temp; + $on_value_detected = false; } } } - return $data; + if ($on_value_detected && !empty($data)) { + $total_time_with_value + += $date_end - $timestamp_with_value; + } + + return $total_time_with_value / $interval; } /** diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 93b428c05b..003609a6e5 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -5700,12 +5700,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $item['id_agent_module'], $report["datetime"] - $content['period'], $report["datetime"]); - $count_fails = count( - modules_get_data_with_value( - $item['id_agent_module'], + $count_fails = modules_get_count_data_with_value( + $item['id_agent_module'], $report["datetime"] - $content['period'], $report["datetime"], - 0, true)); + 0); + $percent_ok = (($count_checks - $count_fails) * 100) / $count_checks; $percent_fail = 100 - $percent_ok;