Merge branch '1025-problems-with-charts-when-have-history-db-data-dev' into 'develop'
Added changes to resolve bad history database data See merge request !643
This commit is contained in:
commit
6cc4e1756a
|
@ -579,11 +579,46 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
|||
}
|
||||
else {
|
||||
$data = db_get_all_rows_filter ('tagente_datos',
|
||||
array ('id_agente_modulo' => (int)$agent_module_id,
|
||||
"utimestamp > $datelimit",
|
||||
"utimestamp < $date",
|
||||
'order' => 'utimestamp ASC'),
|
||||
array ('datos', 'utimestamp'), 'AND', $search_in_history_db);
|
||||
array ('id_agente_modulo' => (int)$agent_module_id,
|
||||
"utimestamp > $datelimit",
|
||||
"utimestamp < $date",
|
||||
'order' => 'utimestamp ASC'),
|
||||
array ('datos', 'utimestamp'), 'AND', false);
|
||||
|
||||
if ($search_in_history_db) {
|
||||
$cache = false;
|
||||
$history = false;
|
||||
|
||||
$sql = "SELECT datos, utimestamp FROM tagente_datos WHERE id_agente_modulo = " . (int)$agent_module_id .
|
||||
" AND utimestamp > " . $datelimit . " AND utimestamp < " . $date .
|
||||
" ORDER BY utimestamp ASC";
|
||||
|
||||
// Connect to the history DB
|
||||
if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) {
|
||||
$config['history_db_connection'] = db_connect($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false);
|
||||
}
|
||||
if ($config['history_db_connection'] !== false) {
|
||||
$history = mysql_db_process_sql ($sql, 'affected_rows', $config['history_db_connection'], false);
|
||||
}
|
||||
|
||||
if ($history === false) {
|
||||
$history = array ();
|
||||
}
|
||||
|
||||
$new_data = array();
|
||||
$last_timestamp = 0;
|
||||
foreach($history as $h) {
|
||||
$new_data[] = $h;
|
||||
$last_timestamp = $h['utimestamp'];
|
||||
}
|
||||
foreach($data as $d) {
|
||||
if ($d['utimestamp'] > $last_timestamp) {
|
||||
$new_data[] = $d;
|
||||
$last_timestamp = $d['utimestamp'];
|
||||
}
|
||||
}
|
||||
$data = $new_data;
|
||||
}
|
||||
}
|
||||
|
||||
// Get module warning_min and critical_min
|
||||
|
@ -3868,7 +3903,9 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
|
|||
$timestamp_short = date($time_format, $timestamp);
|
||||
$long_index[$timestamp_short] = date(
|
||||
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
|
||||
$timestamp = $timestamp_short;
|
||||
if (!$fullscale) {
|
||||
$timestamp = $timestamp_short;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
if ($total > $max_value) {
|
||||
|
|
Loading…
Reference in New Issue