From c7d84b29c2ae150e2670d92b53a109d70b06bf80 Mon Sep 17 00:00:00 2001 From: Esteban Sanchez Date: Thu, 26 Feb 2009 09:08:48 +0000 Subject: [PATCH] 2009-02-26 Esteban Sanchez * include/functions_db.php: Added support for queries elapsed time in print_database_debug(). * operation/events/events.php: Style correction. * reporting/fgraph.php: Allow boolean graphics to get a starting date. * general/footer.php: Use config['debug'] instead of developer_bypass. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1487 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 +++++++++++ pandora_console/general/footer.php | 2 +- pandora_console/include/functions_db.php | 11 +++++++++-- pandora_console/operation/events/events.php | 12 ++++++------ pandora_console/reporting/fgraph.php | 10 +++++++--- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 320e5be706..5a8d8a8d66 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2009-02-26 Esteban Sanchez + + * include/functions_db.php: Added support for queries elapsed time in + print_database_debug(). + + * operation/events/events.php: Style correction. + + * reporting/fgraph.php: Allow boolean graphics to get a starting date. + + * general/footer.php: Use config['debug'] instead of developer_bypass. + 2009-02-25 Esteban Sanchez * include/functions_ui.php: Fixed typo that makes incorrect argument diff --git a/pandora_console/general/footer.php b/pandora_console/general/footer.php index 21f9cd8035..fa5475042b 100644 --- a/pandora_console/general/footer.php +++ b/pandora_console/general/footer.php @@ -26,7 +26,7 @@ if (isset($_SERVER['REQUEST_TIME'])) { echo 'Pandora FMS '.$pandora_version.' - Build '.$build_version.'
'; echo ''. __('Page generated at') . ' '. print_timestamp ($time, true, array ("prominent" => "timestamp")); //Always use timestamp here -if ((isset($develop_bypass)) AND ($develop_bypass == 1)) { +if (isset ($config['debug'])) { echo ' - Saved '.format_numeric ($sql_cache["saved"]).' Queries'; } echo '
'; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 115fcbc56a..5448c84522 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1753,7 +1753,9 @@ function process_sql ($sql, $rettype = "affected_rows") { $sql_cache['saved']++; add_database_debug_trace ($sql); } else { + $start = microtime (true); $result = mysql_query ($sql); + $time = microtime (true) - $start; if ($result === false) { $backtrace = debug_backtrace (); $error = sprintf ('%s (\'%s\') in %s on line %d', @@ -1772,10 +1774,12 @@ function process_sql ($sql, $rettype = "affected_rows") { $result = mysql_affected_rows (); } - add_database_debug_trace ($sql, $result, mysql_affected_rows ()); + add_database_debug_trace ($sql, $result, mysql_affected_rows (), + array ('time' => $time)); return $result; } else { - add_database_debug_trace ($sql, 0, mysql_affected_rows ()); + add_database_debug_trace ($sql, 0, mysql_affected_rows (), + array ('time' => $time)); while ($row = mysql_fetch_array ($result)) { array_push ($retval, $row); } @@ -2916,6 +2920,7 @@ function print_database_debug () { $table->size[2] = '30%'; $table->size[3] = '40px'; $table->size[4] = '40px'; + $table->size[5] = '40px'; $table->data = array (); $table->head = array (); $table->head[0] = '#'; @@ -2923,6 +2928,7 @@ function print_database_debug () { $table->head[2] = __('Result'); $table->head[3] = __('Rows'); $table->head[4] = __('Saved'); + $table->head[5] = __('Time (ms)'); if (! isset ($config['db_debug'])) $config['db_debug'] = array (); @@ -2935,6 +2941,7 @@ function print_database_debug () { $data[2] = (empty ($debug['result']) ? __('OK') : $debug['result']); $data[3] = $debug['affected']; $data[4] = $debug['saved']; + $data[5] = (isset ($debug['extra']['time']) ? format_numeric ($debug['extra']['time'] * 1000, 0) : ''); array_push ($table->data, $data); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index eeaa974985..f9f1892cc1 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -29,17 +29,17 @@ if (! give_acl ($config["id_user"], 0, "IR")) { exit; } -$delete = get_parameter ("delete"); -$validate = get_parameter ("validate"); +$delete = (bool) get_parameter ("delete"); +$validate = (bool) get_parameter ("validate"); //Process deletion (pass array or single value) -if (!empty ($delete)) { +if ($delete) { $eventid = (array) get_parameter ("eventid", -1); $return = delete_event ($eventid); //This function handles both single values as well arrays and cleans up before deleting print_error_message ($return, __('Events successfully deleted'), __('There was an error deleting events')); } //Process validation (pass array or single value) -if (!empty ($validate)) { +if ($validate) { $eventid = (array) get_parameter ("eventid", -1); $return = process_event_validate ($eventid); print_error_message ($return, __('Events successfully validated'), __('There was an error validating events')); @@ -50,7 +50,7 @@ if (!empty ($validate)) { // Main code form / page // *********************************************************************** -$offset = (int) get_parameter ( "offset", 0); +$offset = (int) get_parameter ("offset", 0); $ev_group = (int) get_parameter ("ev_group", 1); //1 = all $search = preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "%", rawurldecode (get_parameter ("search"))); //Replace all types of &# HTML with % so that it doesn't fail on quotes @@ -471,4 +471,4 @@ unset ($table); }); }); /* ]]> */ - \ No newline at end of file + diff --git a/pandora_console/reporting/fgraph.php b/pandora_console/reporting/fgraph.php index 88301b59ca..2c063de1d4 100644 --- a/pandora_console/reporting/fgraph.php +++ b/pandora_console/reporting/fgraph.php @@ -1613,13 +1613,16 @@ function odo_tactic ($value1, $value2, $value3) { } function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event, - $width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0 ) { + $width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0, $date = 0 ) { global $config; $resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph - $fechatope = get_system_time () - $periodo; // limit date + if (! $date) + $date = get_system_time (); + //$unix_timestamp = strtotime($mysql_timestamp) // Convert MYSQL format tio utime + $fechatope = $date - $periodo; // limit date $horasint = $periodo / $resolution; // Each intervalo is $horasint seconds length $id_agente = get_agentmodule_agent ($id_agente_modulo); $nombre_agente = get_agent_name ($id_agente); @@ -1697,6 +1700,7 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event, if ($result === false) { $result = array (); } + foreach ($result as $row) { $datos = $row["datos"]; $utimestamp = $row["utimestamp"]; @@ -1967,7 +1971,7 @@ if ($graphic_type) { $label, $unit_name, $draw_alerts, $avg_only, $pure, $date); break; case "boolean": - grafico_modulo_boolean ($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, 1, $pure); + grafico_modulo_boolean ($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, 1, $pure, $date); break; case "estado_incidente":