1 && in_array ($ev_group, array_keys ($groups))) { //If a group is selected and it's in the groups allowed $sql_post = " AND id_grupo = $ev_group"; } elseif (dame_admin ($config["id_user"])) { //Do nothing if you're admin, you get full access $sql_post = ""; $groups[0] = __('System Events'); } else { //Otherwise select all groups the user has rights to. $sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")"; } if ($status == 1) { $sql_post .= " AND estado = 1"; } elseif ($status == 0) { $sql_post .= " AND estado = 0"; } if ($search != "") $sql_post .= " AND evento LIKE '%$search%'"; if ($event_type != "") $sql_post .= " AND event_type = '$event_type'"; if ($severity != -1) $sql_post .= " AND criticity >= ".$severity; if ($id_agent != -1) $sql_post .= " AND id_agente = ".$id_agent; if ($id_event != -1) $sql_post .= " AND id_evento = ".$id_event; if ($id_user_ack != 0) $sql_post .= " AND id_usuario == '$id_user_ack' "; $unixtime = date("U") - ($event_view_hr*60*60); $sql_post .= " AND utimestamp > $unixtime "; $url = "index.php?sec=eventos&sec2=operation/events/events&search=$search&event_type=$event_type&severity=$severity&status=$status&ev_group=$ev_group&refr=60&id_agent=$id_agent&id_event=$id_event&pagination=$pagination"; echo "

".__('Events')." > ".__('Main event view'). " "; if ($config["pure"] == 1) { echo ""; } else { // Fullscreen echo ""; } echo "

"; echo ''.__('Event control filter').' '.''; echo '
 
'; $sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; $result = get_db_all_rows_sql ($sql); $sql = "SELECT COUNT(id_evento) FROM tevento WHERE id_evento > 0 ".$sql_post; $total_events = get_db_sql ($sql); if (empty ($result)) { $result = array (); } if (empty ($total_events)) { $total_events = 0; } // Show pagination header $offset = get_parameter ("offset", 0); pagination ($total_events, $url."&pure=".$config["pure"], $offset, $pagination); // If pure, table width takes more space if ($config["pure"] != 0) { $table->width = 765; } else { $table->width = 750; } $table->id = "eventtable"; $table->cellpadding = 4; $table->cellspacing = 4; $table->class = "databox"; $table->head = array (); $table->data = array (); $table->head[0] = ''; $table->align[0] = 'center'; $table->head[1] = __('Type'); $table->headclass[1] = 'f9'; $table->align[1] = 'center'; $table->head[2] = __('Event name'); $table->head[3] = __('Agent name'); $table->align[3] = 'center'; $table->head[4] = __('Source'); $table->align[4] = 'center'; $table->head[5] = __('Group'); $table->align[5] = 'center'; $table->head[6] = __('User ID'); $table->align[6] = 'center'; $table->head[7] = __('Timestamp'); $table->align[7] = 'center'; $table->head[8] = __('Action'); $table->align[8] = 'center'; $table->head[9] = print_checkbox ("allbox", "1", false, true); $table->align[9] = 'center'; //Arrange data. We already did ACL's in the query foreach ($result as $row) { $data = array (); //First pass along the class of this row $table->rowclass[] = get_priority_class ($row["criticity"]); // Colored box if ($row["estado"] == 0) { $data[0] = ''; } else { $data[0] = ''; } switch ($row["event_type"]) { case "alert_recovered": $data[1] = ''; break; case "alert_manual_validation": $data[1] = ''; break; case "going_up_warning": $data[1] = ''; break; case "going_up_critical": $data[1] = ''; break; case "going_down_normal": $data[1] = ''; break; case "going_down_warning": $data[1] = ''; break; case "alert_fired": $data[1] = ''; break; case "system"; $data[1] = ''; break; case "recon_host_detected"; $data[1] = ''; break; case "new_agent"; $data[1] = ''; break; case "unknown": default: $data[1] = ''; break; } // Event description $data[2] = ''; if (strlen ($row["evento"]) > 39) { $data[2] .= substr ($row["evento"], 0, 37)."..."; } else { $data[2] .= $row["evento"]; } $data[2] .= ''; if ($row["event_type"] == "system") { $data[3] = __('System'); } elseif ($row["id_agente"] > 0) { // Agent name $agent_name = get_agent_name ($row["id_agente"]); $data[3] = ''; if (strlen ($agent_name) > 16) { $data[3] .= substr ($agent_name, 0, 14)."..."; } else { $data[3] .= $agent_name; } $data[3] .= ''; } else { $data[3] = __('Alert').__('SNMP'); } $data[4] = ''; if ($row["id_agentmodule"] != 0) { $data[4] .= ' '; } if ($row["id_alert_am"] != 0) { $data[4] .= ''; } $data[5] = print_group_icon ($row["id_grupo"], true); if (!empty ($row["estado"])) { if ($row["id_usuario"] != '0' && $row["id_usuario"] != ''){ $data[6] = ''.substr ($row["id_usuario"],0,8).''; } else { $data[6]=__('System'); } } else { $data[6] = ''; } //Time $data[7] = print_timestamp ($row["timestamp"], true); //Actions $data[8] = ''; // Validate event if (($row["estado"] == 0) and (give_acl ($config["id_user"], $row["id_grupo"], "IW") == 1)) { $data[8] .= ''; } // Delete event if (give_acl ($config["id_user"], $row["id_grupo"], "IM") == 1) { $data[8] .= ''; } // Create incident from this event if (give_acl ($config["id_user"], $row["id_grupo"], "IW") == 1) { $data[8] .= ''; } //Checkbox $data[9] = print_checkbox_extended ("eventid[]", $row["id_evento"], false, false, false, 'class="chk"', true); array_push ($table->data, $data); } if (!empty ($table->data)) { echo '
'; print_table ($table); echo '
'; if (give_acl ($config["id_user"], 0, "IW") == 1) { print_submit_button (__('Validate'), 'validate', false, 'class="sub ok"'); } if (give_acl ($config["id_user"], 0,"IM") == 1) { print_submit_button (__('Delete'), 'delete', false, 'class="sub delete"'); } echo '
'; } else { echo '
'.__('No events').'
'; } unset ($table); if ($config["pure"]== 0) { echo '
'; echo '

'.__('Status').'

'; echo ' - '.__('Validated event'); echo '
'; echo ' - '.__('Not validated event'); echo '
'; echo '

'.__('Action').'

'; echo ' - '.__('Validate event'); echo '
'; echo ' - '.__('Delete event'); echo '
'; echo ' - '.__('Create incident'); echo '
 
'; } ?>