2009-02-26 Esteban Sanchez <estebans@artica.es>

* 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
This commit is contained in:
esanchezm 2009-02-26 09:08:48 +00:00
parent 4ba39935c8
commit 7dc50cf300
5 changed files with 34 additions and 12 deletions

View File

@ -1,3 +1,14 @@
2009-02-26 Esteban Sanchez <estebans@artica.es>
* 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 <estebans@artica.es> 2009-02-25 Esteban Sanchez <estebans@artica.es>
* include/functions_ui.php: Fixed typo that makes incorrect argument * include/functions_ui.php: Fixed typo that makes incorrect argument

View File

@ -26,7 +26,7 @@ if (isset($_SERVER['REQUEST_TIME'])) {
echo '<a class="white_bold" target="_blank" href="general/license/pandora_info_'.$config["language"].'.html">Pandora FMS '.$pandora_version.' - Build '.$build_version.'</a><br />'; echo '<a class="white_bold" target="_blank" href="general/license/pandora_info_'.$config["language"].'.html">Pandora FMS '.$pandora_version.' - Build '.$build_version.'</a><br />';
echo '<a class="white">'. __('Page generated at') . ' '. print_timestamp ($time, true, array ("prominent" => "timestamp")); //Always use timestamp here echo '<a class="white">'. __('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 ' - Saved '.format_numeric ($sql_cache["saved"]).' Queries';
} }
echo '</a><br />'; echo '</a><br />';

View File

@ -1753,7 +1753,9 @@ function process_sql ($sql, $rettype = "affected_rows") {
$sql_cache['saved']++; $sql_cache['saved']++;
add_database_debug_trace ($sql); add_database_debug_trace ($sql);
} else { } else {
$start = microtime (true);
$result = mysql_query ($sql); $result = mysql_query ($sql);
$time = microtime (true) - $start;
if ($result === false) { if ($result === false) {
$backtrace = debug_backtrace (); $backtrace = debug_backtrace ();
$error = sprintf ('%s (\'%s\') in <strong>%s</strong> on line %d', $error = sprintf ('%s (\'%s\') in <strong>%s</strong> on line %d',
@ -1772,10 +1774,12 @@ function process_sql ($sql, $rettype = "affected_rows") {
$result = mysql_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; return $result;
} else { } 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)) { while ($row = mysql_fetch_array ($result)) {
array_push ($retval, $row); array_push ($retval, $row);
} }
@ -2916,6 +2920,7 @@ function print_database_debug () {
$table->size[2] = '30%'; $table->size[2] = '30%';
$table->size[3] = '40px'; $table->size[3] = '40px';
$table->size[4] = '40px'; $table->size[4] = '40px';
$table->size[5] = '40px';
$table->data = array (); $table->data = array ();
$table->head = array (); $table->head = array ();
$table->head[0] = '#'; $table->head[0] = '#';
@ -2923,6 +2928,7 @@ function print_database_debug () {
$table->head[2] = __('Result'); $table->head[2] = __('Result');
$table->head[3] = __('Rows'); $table->head[3] = __('Rows');
$table->head[4] = __('Saved'); $table->head[4] = __('Saved');
$table->head[5] = __('Time (ms)');
if (! isset ($config['db_debug'])) if (! isset ($config['db_debug']))
$config['db_debug'] = array (); $config['db_debug'] = array ();
@ -2935,6 +2941,7 @@ function print_database_debug () {
$data[2] = (empty ($debug['result']) ? __('OK') : $debug['result']); $data[2] = (empty ($debug['result']) ? __('OK') : $debug['result']);
$data[3] = $debug['affected']; $data[3] = $debug['affected'];
$data[4] = $debug['saved']; $data[4] = $debug['saved'];
$data[5] = (isset ($debug['extra']['time']) ? format_numeric ($debug['extra']['time'] * 1000, 0) : '');
array_push ($table->data, $data); array_push ($table->data, $data);

View File

@ -29,17 +29,17 @@ if (! give_acl ($config["id_user"], 0, "IR")) {
exit; exit;
} }
$delete = get_parameter ("delete"); $delete = (bool) get_parameter ("delete");
$validate = get_parameter ("validate"); $validate = (bool) get_parameter ("validate");
//Process deletion (pass array or single value) //Process deletion (pass array or single value)
if (!empty ($delete)) { if ($delete) {
$eventid = (array) get_parameter ("eventid", -1); $eventid = (array) get_parameter ("eventid", -1);
$return = delete_event ($eventid); //This function handles both single values as well arrays and cleans up before deleting $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')); print_error_message ($return, __('Events successfully deleted'), __('There was an error deleting events'));
} }
//Process validation (pass array or single value) //Process validation (pass array or single value)
if (!empty ($validate)) { if ($validate) {
$eventid = (array) get_parameter ("eventid", -1); $eventid = (array) get_parameter ("eventid", -1);
$return = process_event_validate ($eventid); $return = process_event_validate ($eventid);
print_error_message ($return, __('Events successfully validated'), __('There was an error validating events')); print_error_message ($return, __('Events successfully validated'), __('There was an error validating events'));

View File

@ -1613,13 +1613,16 @@ function odo_tactic ($value1, $value2, $value3) {
} }
function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event, 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; global $config;
$resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph $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 $horasint = $periodo / $resolution; // Each intervalo is $horasint seconds length
$id_agente = get_agentmodule_agent ($id_agente_modulo); $id_agente = get_agentmodule_agent ($id_agente_modulo);
$nombre_agente = get_agent_name ($id_agente); $nombre_agente = get_agent_name ($id_agente);
@ -1697,6 +1700,7 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event,
if ($result === false) { if ($result === false) {
$result = array (); $result = array ();
} }
foreach ($result as $row) { foreach ($result as $row) {
$datos = $row["datos"]; $datos = $row["datos"];
$utimestamp = $row["utimestamp"]; $utimestamp = $row["utimestamp"];
@ -1967,7 +1971,7 @@ if ($graphic_type) {
$label, $unit_name, $draw_alerts, $avg_only, $pure, $date); $label, $unit_name, $draw_alerts, $avg_only, $pure, $date);
break; break;
case "boolean": 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; break;
case "estado_incidente": case "estado_incidente":