'.__('Event').'';
echo ''.__('Type').':
';
print_event_type_img ($event["event_type"]);
echo ' ';
if ($event["event_type"] == "system") {
echo __('System');
} elseif ($event["id_agente"] > 0) {
// Agent name
echo get_agent_name ($event["id_agente"]);
} else {
echo __('Alert').__('SNMP');
}
echo '
';
echo ''.__('Timestamp').':
';
print_timestamp ($event['utimestamp']);
echo '
';
echo ''.__('Description').':
';
echo $event['evento'];
return;
}
if ($validate_event) {
$id = (int) get_parameter ("id");
$similars = (bool) get_parameter ('similars');
$return = validate_event ($id, $similars);
if ($return)
echo 'ok';
else
echo 'error';
return;
}
if ($delete_event) {
$id = (array) get_parameter ("id");
$similars = (bool) get_parameter ('similars');
$return = delete_event ($id, $similars);
if ($return)
echo 'ok';
else
echo 'error';
return;
}
return;
}
$offset = (int) get_parameter ("offset", 0);
$ev_group = (int) get_parameter ("ev_group", 1); //1 = all
$search = preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "%", rawurldecode (get_parameter ("search")));
$event_type = get_parameter ("event_type", ''); // 0 all
$severity = (int) get_parameter ("severity", -1); // -1 all
$status = (int) get_parameter ("status", 0); // -1 all, 0 only red, 1 only green
$id_agent = (int) get_parameter ("id_agent", -1); //-1 all, 0 system
$id_event = (int) get_parameter ("id_event", -1);
$pagination = (int) get_parameter ("pagination", $config["block_size"]);
$groups = get_user_groups ($config["id_user"], "AR");
$event_view_hr = (int) get_parameter ("event_view_hr", $config["event_view_hr"]);
$id_user_ack = get_parameter ("id_user_ack", 0);
$group_rep = (int) get_parameter ("group_rep", 1);
/* Show always the system events */
$groups[0] = __('System');
$delete = (bool) get_parameter ("delete");
$validate = (bool) get_parameter ("validate");
//Process deletion (pass array or single value)
if ($delete) {
$ids = (array) get_parameter ("eventid", -1);
$return = delete_event ($ids, ($group_rep == 1));
print_result_message ($return,
__('Successfully deleted'),
__('Could not be deleted'));
}
//Process validation (pass array or single value)
if ($validate) {
$ids = (array) get_parameter ("eventid", -1);
$return = validate_event ($ids, ($group_rep == 1));
print_result_message ($return,
__('Successfully validated'),
__('Could not be validated'));
}
//Group selection
if ($ev_group > 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 (is_user_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."'";
if ($event_view_hr > 0) {
$unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds
$sql_post .= " AND utimestamp > ".$unixtime;
}
$url = "index.php?sec=eventos&sec2=operation/events/events&search=".rawurlencode($search)."&event_type=".$event_type."&severity=".$severity."&status=".$status."&ev_group=".$ev_group."&refr=".$config["refr"]."&id_agent=".$id_agent."&id_event=".$id_event."&pagination=".$pagination."&group_rep=".$group_rep."&event_view_hr=".$event_view_hr."&id_user_ack=".$id_user_ack;
echo '
';
echo "";
//Link to toggle filter
echo ''.__('Event control filter').' '.print_image ("images/wand.png", true, array ("title" => __('Toggle filter'))).'';
//Start div
echo '';
// Table for filter controls
echo '
"; //This is the filter div
echo '
';
print_image ("reporting/fgraph.php?tipo=group_events&width=220&height=180&url=".rawurlencode ($sql_post), false, array ("border" => 0));
echo '
';
echo '
';
echo '
';
if ($group_rep == 0) {
$sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination;
} else {
$sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination;
}
$result = get_db_all_rows_sql ($sql);
if ($group_rep == 0) {
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 ".$sql_post;
} else {
$sql = "SELECT COUNT(DISTINCT(evento)) FROM tevento WHERE 1=1 ".$sql_post;
}
$total_events = (int) get_db_sql ($sql);
if (empty ($result)) {
$result = array ();
}
$table->width = '99%';
$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';
if ($group_rep == 0) {
$table->head[6] = __('User ID');
} else {
$table->head[6] = __('Count');
}
$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 $event) {
$data = array ();
//First pass along the class of this row
$table->rowclass[] = get_priority_class ($event["criticity"]);
// Colored box
if ($event["estado"] == 0) {
$img = "images/pixel_red.png";
} else {
$img = "images/pixel_green.png";
}
$data[0] = print_image ($img, true,
array ("class" => "image_status",
"width" => 20,
"height" => 20,
"title" => get_priority_name ($event["criticity"])));
$data[1] = print_event_type_img ($event["event_type"], true);
// Event description
$data[2] = '';
$data[2] .= '';
if (strlen ($event["evento"]) > 50) {
$data[2] .= mb_substr ($event["evento"], 0, 50)."...";
} else {
$data[2] .= $event["evento"];
}
$data[2] .= '';
if ($event["event_type"] == "system") {
$data[3] = __('System');
} elseif ($event["id_agente"] > 0) {
// Agent name
$data[3] = print_agent_name ($event["id_agente"], true);
} else {
$data[3] = __('Alert').__('SNMP');
}
$data[4] = '';
if ($event["id_agentmodule"] != 0) {
$data[4] .= '';
$data[4] .= print_image ("images/bricks.png", true,
array ("title" => __('Go to data overview')));
$data[4] .= ' ';
}
if ($event["id_alert_am"] != 0) {
$data[4] .= '';
$data[4] .= print_image ("images/bell.png", true,
array ("title" => __('Go to alert overview')));
$data[4] .= '';
}
$data[5] = print_group_icon ($event["id_grupo"], true);
if ($group_rep == 1) {
$data[6] = $event["event_rep"];
} else {
if (!empty ($event["estado"])) {
if ($event["id_usuario"] != '0' && $event["id_usuario"] != ''){
$data[6] = ''.mb_substr ($event["id_usuario"],0,8).'';
} else {
$data[6] = __('System');
}
} else {
$data[6] = '';
}
}
//Time
if ($group_rep == 1) {
$data[7] = print_timestamp ($event['timestamp_rep'], true);
} else {
$data[7] = print_timestamp ($event["timestamp"], true);
}
//Actions
$data[8] = '';
// Validate event
if (($event["estado"] == 0) and (give_acl ($config["id_user"], $event["id_grupo"], "IW") == 1)) {
$data[8] .= '';
$data[8] .= print_image ("images/ok.png", true,
array ("title" => __('Validate event')));
$data[8] .= '';
}
// Delete event
if (give_acl ($config["id_user"], $event["id_grupo"], "IM") == 1) {
$data[8] .= '';
$data[8] .= print_image ("images/cross.png", true,
array ("title" => __('Delete event')));
$data[8] .= '';
}
// Create incident from this event
if (give_acl ($config["id_user"], $event["id_grupo"], "IW") == 1) {
$data[8] .= '';
$data[8] .= print_image ("images/page_lightning.png", true,
array ("title" => __('Create incident from event')));
$data[8] .= '';
}
//Checkbox
$data[9] = print_checkbox_extended ("eventid[]", $event["id_evento"], false, false, false, 'class="chk"', true);
array_push ($table->data, $data);
}
echo '';
if (!empty ($table->data)) {
pagination ($total_events, $url."&pure=".$config["pure"], $offset, $pagination);
echo '
';
if ($config["pure"]== 0) {
//Print legend
echo '
';
echo '
'.__('Status').'
';
print_image ("images/pixel_green.png", false,
array ("width" => 10,
"height" => 10,
"title" => __('Validated event')));
echo ' - '.__('Validated event');
echo '
';
print_image ("images/pixel_red.png", false,
array ("width" => 10,
"height" => 10,
"title" => __('Event not validated')));
echo ' - '.__('Event not validated');
echo '';
echo '
'.__('Actions').'
';
print_image ("images/ok.png", false,
array ("title" => __('Validate event')));
echo ' - '.__('Validate event');
echo '
';
print_image ("images/cross.png", false,
array ("title" => __('Delete event')));
echo ' - '.__('Delete event');
echo '
';
print_image ("images/page_lightning.png", false,
array ("title" => __('Create incident from event')));
echo ' - '.__('Create incident from event');
echo '
';
}
} else {
echo '
'.__('No events').'
';
}
echo '
';
unset ($table);
?>