diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 63eebe46ad..f24aec295c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2009-02-26 Esteban Sanchez + + * include/functions_events.php: Added get_events() function. Replaced + "..." with html entity and reuse previously calculated value. + + * include/functions_reporting.php: Fixed get_agent_module_sla() to + allow no max value to be checked. That was causing some errors on + monitor reports. + + * operation/agentes/sla_view.php, + operation/reporting/reporting_xml.php, + operation/reporting/reporting_viewer.php: Do not use max value on + monitor SLA. + + * operation/events/events.php: Replaced exit for return. + + * include/functions_db.php: Added support for arrays in + format_array_to_update_sql() that will be transformed to a "IN ()" + statement. + 2009-02-26 Esteban Sanchez * include/config_process.php, index.php: Added generated timer count as diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 5448c84522..bf7fc0148b 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1889,6 +1889,8 @@ function format_array_to_update_sql ($values) { $sql = sprintf ("`%s` = %d", $field, $value); } else if (is_float ($value) || is_double ($value)) { $sql = sprintf ("`%s` = %f", $field, $value); + } else if (is_array ($value)) { + $sql = sprintf ('`%s` IN ("%s")', $field, implode ('", "', $value)); } else { $sql = sprintf ("`%s` = '%s'", $field, $value); } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 3fda2982c7..cdd18bb9da 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -17,6 +17,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +function get_events ($filter = false, $fields = false) { + return get_db_all_rows_filter ('tevento', $filter, $fields); +} + /** * Delete events in a transaction * @@ -231,8 +235,8 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = $wrap = floor ($width / 10); $data[2] = ''.safe_input (chunk_split (mb_substr ($event["evento"],0, $wrap),8, "­")); - if (mb_strlen ($event["evento"]) > floor ($width / 10)) { - $data[2] .= "..."; + if (mb_strlen ($event["evento"]) > $wrap) { + $data[2] .= "…"; } $data[2] .= ''; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 008bcbf42f..4ceb525460 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -27,12 +27,13 @@ require_once ($config["homedir"]."/include/functions_agents.php"); * @param int Agent module to calculate SLA * @param int Period to check the SLA compliance. * @param int Minimum data value the module in the right interval - * @param int Maximum data value the module in the right interval + * @param int Maximum data value the module in the right interval. False will + * ignore max value * @param int Beginning date of the report in UNIX time (current date by default). * * @return int SLA percentage of the requested module. */ -function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value, $date = 0) { +function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value = false, $date = 0) { if (empty ($date)) $date = get_system_time (); @@ -83,7 +84,7 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value } foreach ($datas as $data) { - if ($data["datos"] > $max_value || $data["datos"] < $min_value) { + if ($data["datos"] < $min_value || ($max_value !== false && $data["datos"] > $max_value)) { if ($interval_begin == 0) { $interval_begin = $data["utimestamp"]; } diff --git a/pandora_console/operation/agentes/sla_view.php b/pandora_console/operation/agentes/sla_view.php index a40af9fa59..8e9b02e4a2 100644 --- a/pandora_console/operation/agentes/sla_view.php +++ b/pandora_console/operation/agentes/sla_view.php @@ -94,7 +94,7 @@ if (mysql_num_rows ($result_t)) { echo "".$est_modulo.""; echo ""; - $temp = get_agent_module_sla ($module_data["id_agente_modulo"], $config["sla_period"], 1, 2147483647); + $temp = get_agent_module_sla ($module_data["id_agente_modulo"], $config["sla_period"], 1); if ($temp === false) echo __('N/A'); else { diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index f9f1892cc1..a4ec3f598f 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -26,7 +26,7 @@ if (! give_acl ($config["id_user"], 0, "IR")) { audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", "Trying to access event viewer"); require ("general/noaccess.php"); - exit; + return; } $delete = (bool) get_parameter ("delete"); diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 77c1848f15..d20afa94ec 100644 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -27,7 +27,7 @@ if (! $id_report) { audit_db ($config['id_user'], $REMOTE_ADDR, "HACK Attempt", "Trying to access graph viewer withoud ID"); include ("general/noaccess.php"); - exit; + return; } $report = get_db_row ('treport', 'id_report', $id_report); @@ -325,7 +325,7 @@ foreach ($contents as $content) { } $data = array (); - $monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, 1, $datetime)); + $monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime)); $data[0] = '

'; $data[0] .= $monitor_value.' %

'; $monitor_value = format_numeric (100 - $monitor_value, 2) ; diff --git a/pandora_console/operation/reporting/reporting_xml.php b/pandora_console/operation/reporting/reporting_xml.php index e9a7044563..56b1c15c6d 100644 --- a/pandora_console/operation/reporting/reporting_xml.php +++ b/pandora_console/operation/reporting/reporting_xml.php @@ -234,7 +234,7 @@ foreach ($contents as $content) { case 6: case 'monitor_report': $data["title"] = __('Monitor report'); - $monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, 1, $datetime)); + $monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime)); $data["objdata"]["good"] = $monitor_value; $data["objdata"]["bad"] = format_numeric (100 - $monitor_value, 2); break;