/** * This function calculates status of systems with profile sensor enabled * * @param object $conn DataBase access object * * @return array */ function calc_sensors_status($conn) { // Getting system list $avc_list = Av_center::get_avc_list($conn); $total = 0; $up_sensors = array(); $down_sensors = array(); // Getting DOWN systems $filters = array('level' => 'error', 'message_id' => Util::uuid_format('00000000000000000000000000010011')); $pagination = array('page' => 1, 'page_rows' => count($avc_list['data'])); $status = new System_notifications(); list($notification_list, $total_notifications) = $status->get_status_messages($filters, $pagination); if ($total_notifications > 0) { $down_systems = array(); foreach ($notification_list as $notification) { $down_systems[$notification['component_id']] = 1; } } //Calculating UP and DOWN sensors if (is_array($avc_list['data']) && !empty($avc_list['data'])) { foreach ($avc_list['data'] as $avc_data) { if (preg_match('/sensor/i', $avc_data['profile'])) { if (isset($down_systems[Util::uuid_format($avc_data['system_id'])])) { $down_sensors[$avc_data['sensor_id']] = 1; } else { $up_sensors[$avc_data['sensor_id']] = 1; } } } } $up = count($up_sensors); $down = count($down_sensors); $total = $up + $down; return array($total, $up, $down); }
if (!empty($type)) { $filters['message_type'] = $type; } if (!empty($level)) { $filters['level'] = $level; } /************************ ****** Pagination ****** ************************/ $pagination = array('page' => Util::calculate_pagination_page($from, $max_rows), 'page_rows' => $max_rows); /********************** ****** API Call ****** **********************/ // Call API to get status messages $status = new System_notifications(); list($message_list, $total_messages) = $status->get_status_messages($filters, $pagination); // Wiki Parser $wiki = new Wikiparser(); // Fill data array foreach ($message_list as $message) { $res = array(); $res['DT_RowId'] = $message['id']; $res['viewed'] = $message['viewed']; $res['description'] = $wiki->parse($message['message_description']); $res['actions'] = $wiki->parse($message['message_actions']); $res['alternative_actions'] = $wiki->parse($message['message_alternative_actions']); $res[] = $message['creation_time']; $res[] = $message['message_title'] . ($message['component_ip'] ? ' (' . $message['component_ip'] . ')' : ''); $res[] = $message['message_level']; $res[] = $message['message_type']; $res[] = '';