$conn = $db->connect(); //Agents trends if ($agent['ip'] == '127.0.0.1') { // Get default system uuid $system_id = Util::get_system_uuid(); $system_info = Av_center::get_system_info_by_id($conn, $system_id); if ($system_info['status'] == 'success') { $sensor_ip = $system_info['data']['admin_ip']; } $ip_cidr = empty($sensor_ip) ? $agent['ip'] : $sensor_ip; } else { $agent_idm_data = Ossec_agent::get_idm_data($sensor_id, $agent['ip']); $agent_idm_ip = $agent_idm_data['ip']; if (empty($agent_idm_ip)) { try { $agent_idm_ip = Ossec_agent::get_last_ip($sensor_id, $agent); } catch (Exception $e) { } } $ip_cidr = Asset_host_ips::valid_ip($agent_idm_ip) ? $agent_idm_ip : $agent['ip']; } $data = array(); if (!preg_match('/Never connected/i', $agent['status']) && Asset_host_ips::valid_ip($ip_cidr)) { $data = Ossec_utilities::SIEM_trends_hids($conn, $ip_cidr); } $trend_plot = "<div style='color:gray; margin:15px; text-align:center;'>" . _('Trend chart not available') . "</div>"; if (is_array($data) && !empty($data)) { $trend = ''; $max = 7; for ($ii = $max - 1; $ii >= 0; $ii--) { $d = gmdate("j M", $timetz - 86400 * $ii);
$timetz = gmdate("U") + 3600 * $tz; // time to generate dates with timezone correction //HIDS trend $data = array(); if ($agent_status > 1) { if (Asset_host::is_in_db($conn, $asset_id)) { $data = Ossec_utilities::hids_trend_by_id($conn, $asset_id); } else { if ($ip_cidr == '127.0.0.1') { // Getting default sensor IP $sensor_ip = Av_sensor::get_ip_by_id($conn, $sensor_id); $ip_cidr = empty($sensor_ip) ? $ip_cidr : $sensor_ip; } else { try { $agent = array('name' => $agent_name, 'ip_cidr' => $ip_cidr); $ip_cidr = Ossec_agent::get_last_ip($sensor_id, $agent); } catch (Exception $e) { } } if (Asset_host_ips::valid_ip($ip_cidr)) { $data = Ossec_utilities::hids_trend_by_ip($conn, $ip_cidr); } } } $trend_plot = "<div style='color:gray; margin:15px; text-align:center;'>" . _('Trend chart not available') . "</div>"; if (is_array($data) && !empty($data)) { $trend = ''; $max = 7; for ($ii = $max - 1; $ii >= 0; $ii--) { $d = gmdate("j M", $timetz - 86400 * $ii); $trend[$d] = $data[$d] != '' ? $data[$d] : 0;