Fixed data in db information

This commit is contained in:
Arturo Gonzalez Diaz 2015-10-26 10:03:42 +01:00
parent 3cd2f87da0
commit d096263bb3

View File

@ -1870,90 +1870,98 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
$query_error = false; $query_error = false;
// Data from 1 day ago // Data from 1 day ago
$filter['utimestamp'] = '>' . $time_1day;
$num_1day = 0; $num_1day = 0;
$num_1day += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter); $num_1day += (int) db_get_sql('SELECT COUNT(*)
$num_1day += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter); FROM tagente_datos
$num_1day += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter); WHERE utimestamp > ' . $time_1day);
$num_1day += (int) db_get_sql('SELECT COUNT(*)
if ($num_1day !== false) { FROM tagente_datos_string
WHERE utimestamp > ' . $time_1day);
$num_1day += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1day);
if ($num_1day >= 0) {
// Data from 1 week ago // Data from 1 week ago
$filter['utimestamp'] = '>' . $time_1week;
$num_1week = 0; $num_1week = 0;
$num_1week += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter); $num_1week += (int) db_get_sql('SELECT COUNT(*)
$num_1week += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter); FROM tagente_datos
$num_1week += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter); WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
if ($num_1week !== false) { $num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
if ($num_1week >= 0) {
// Data from 1 month ago // Data from 1 month ago
$filter['utimestamp'] = '>' . $time_1month;
$num_1month = 0; $num_1month = 0;
$num_1month += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter); $num_1month += (int) db_get_sql('SELECT COUNT(*)
$num_1month += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter); FROM tagente_datos
$num_1month += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter); WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
if ($num_1month !== false) { $num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
if ($num_1month >= 0) {
// Data from 3 months ago // Data from 3 months ago
$filter['utimestamp'] = '>' . $time_3months;
$num_3months = 0; $num_3months = 0;
$num_3months += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter); $num_3months += (int) db_get_sql('SELECT COUNT(*)
$num_3months += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter); FROM tagente_datos
$num_3months += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter); WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
if ($num_3months !== false) { $num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
if ($num_3months >= 0) {
// All data // All data
unset($filter['utimestamp']); $num_all = 0;
$num_all += (int) db_get_sql('SELECT COUNT(*)
if (empty($filter)) { FROM tagente_datos
$num_all = 0; WHERE utimestamp < ' . $time_3months);
$num_all += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos'); $num_all += (int) db_get_sql('SELECT COUNT(*)
$num_all += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos_string'); FROM tagente_datos
$num_all += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos_log4x'); WHERE utimestamp < ' . $time_3months);
} $num_all += (int) db_get_sql('SELECT COUNT(*)
else { FROM tagente_datos
$num_all = 0; WHERE utimestamp < ' . $time_3months);
$num_all += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter); if ($num_all >= 0) {
$num_all += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter);
$num_all += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter);
}
if ($num_all !== false) {
$num_older = $num_all - $num_3months; $num_older = $num_all - $num_3months;
if ($config['history_db_enabled'] == 1) { if ($config['history_db_enabled'] == 1) {
// All data in common and history database // All data in common and history database
if (empty($filter)) { $num_all_w_history = 0;
$num_all_w_history = 0; $num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
$num_all_w_history += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos', true); FROM tagente_datos
$num_all_w_history += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos_string', true); WHERE utimestamp < ' . $num_older);
$num_all_w_history += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos_log4x', true); $num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
} FROM tagente_datos
else { WHERE utimestamp < ' . $num_older);
$num_all_w_history = 0; $num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
$num_all_w_history += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter, 'AND', true); FROM tagente_datos
$num_all_w_history += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter, 'AND', true); WHERE utimestamp < ' . $num_older);
$num_all_w_history += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter, 'AND', true); if ($num_all_w_history >= 0) {
}
if ($num_all_w_history !== false) {
$num_history = $num_all_w_history - $num_all; $num_history = $num_all_w_history - $num_all;
} else {
$query_error = true;
} }
} }
} else {
$query_error = true;
} }
} else {
$query_error = true;
} }
} else {
$query_error = true;
} }
} else {
$query_error = true;
} }
} else { }
else if (($num_1day == 0) && ($num_1week == 0) && ($num_1month == 0) && ($num_3months == 0) && ($num_all == 0)) {
//If no data, returns empty
$query_error = true; $query_error = true;
} }
@ -1984,7 +1992,6 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
$data[$str_3months] = $num_3months; $data[$str_3months] = $num_3months;
if (!empty($num_older)) if (!empty($num_older))
$data[$str_older] = $num_older; $data[$str_older] = $num_older;
if ($config['history_db_enabled'] == 1 && !empty($num_history)) { if ($config['history_db_enabled'] == 1 && !empty($num_history)) {
// In this pie chart only 5 elements are shown, so we need to remove // In this pie chart only 5 elements are shown, so we need to remove
// an element. With a history db enabled the >3 months element are dispensable // an element. With a history db enabled the >3 months element are dispensable