Fixed problems with column 'last contact'. Gitlab: #269

This commit is contained in:
m-lopez-f 2017-02-17 13:34:30 +01:00
parent 294cb5a14f
commit e118729398
3 changed files with 29 additions and 10 deletions

View File

@ -1391,6 +1391,29 @@ function agents_get_interval ($id_agent) {
return (int) db_get_value ('intervalo', 'tagente', 'id_agente', $id_agent);
}
/**
* Get all data of agent.
*
* @param Agent object.
*
* @return The interval value and status of last contact
*/
function agents_get_interval_status ($agent) {
$return = '';
$last_time = strtotime ($agent["ultimo_contacto"]);
$now = time ();
$diferencia = $now - $last_time;
$time = ui_print_timestamp ($last_time, true, array('style' => 'font-size:6.5pt'));
$min_interval = modules_get_agentmodule_mininterval($agent['id_agente']);
$return = $time;
if ($diferencia > ($min_interval["min_interval"] * 2))
$return = '<b><span style="color: #ff0000;">'.$time.'</span></b>';
return $return;
}
/**
* Get the operating system of an agent.
*

View File

@ -2490,6 +2490,11 @@ function modules_get_modules_name ($sql_from , $sql_conditions = '', $meta = fal
}
}
function modules_get_agentmodule_mininterval($id_agent) {
$sql = sprintf('SELECT min(current_interval) min_interval from tagente_estado where id_agente = %d', $id_agent);
return db_get_row_sql($sql);
}
function get_same_modules ($agents, $modules) {
$modules_to_report = array();
if ($modules != "") {

View File

@ -606,16 +606,7 @@ foreach ($agents as $agent) {
$data[7] = $alert_img;
$last_time = strtotime ($agent["ultimo_contacto"]);
$now = time ();
$diferencia = $now - $last_time;
$time = ui_print_timestamp ($last_time, true, array('style' => 'font-size:6.5pt'));
$style = '';
if ($diferencia > ($agent["intervalo"] * 2))
$data[8] = '<b><span style="color: #ff0000;">'.$time.'</span></b>';
else
$data[8] = $time;
$data[8] = agents_get_interval_status ($agent);
// This old code was returning "never" on agents without modules, BAD !!
// And does not print outdated agents in red. WRONG !!!!