'.__('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;
}
if ($config['flash_charts']) {
require_once ("include/fgraph.php");
}
$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
$text_agent = (string) get_parameter("id_agent", "All");
switch ($text_agent)
{
case 'All':
$id_agent = -1;
break;
case 'Server':
$id_agent = 0;
default:
$id_agent = get_agent_id($text_agent);
break;
}
$id_event = (int) get_parameter ("id_event", -1);
$pagination = (int) get_parameter ("pagination", $config["block_size"]);
$groups = get_user_groups ($config["id_user"], "IR");
$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/down.png", true, array ("title" => __('Toggle filter(s)'))).'
';
//Start div
echo '';
// Table for filter controls
echo '
"; //This is the filter div
echo '
';
if ($config['flash_charts']) {
echo grafico_eventos_grupo (220, 180, rawurlencode ($sql_post));
} else {
print_image ("include/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;
}
//Extract the events by filter (or not) from db
$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;
}
//Count the events with this filter (TODO but not utimestamp).
$total_events = (int) get_db_sql ($sql);
if (empty ($result)) {
$result = array ();
}
$table->width = '100%';
$table->id = "eventtable";
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->class = "databox";
$table->head = array ();
$table->data = array ();
$table->head[0] = "" . __('V.') . "";
$table->align[0] = 'center';
$table->head[1] = "" . __('S.') . "";
$table->align[1] = 'center';
$table->head[2] ="" . __('T.') . "";
$table->headclass[2] = 'f9';
$table->align[2] = 'center';
$table->head[3] = __('Event name');
$table->head[4] = __('Agent name');
$table->align[4] = 'center';
$table->head[5] = __('S.');
$table->align[5] = 'center';
$table->head[6] = __('G.');
$table->align[6] = 'center';
if ($group_rep == 0) {
$table->head[7] = __('User ID');
} else {
$table->head[7] = __('Count');
}
$table->align[7] = 'center';
$table->head[8] = __('Timestamp');
$table->align[8] = 'center';
$table->head[9] = __('Action');
$table->align[9] = 'right';
$table->size[9] = '50px';
$table->head[10] = print_checkbox ("allbox", "1", false, true);
$table->align[10] = '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/tick_off.png";
$title = __('Event validate');
}
else {
$img = "images/tick.png";
$title = __('Event not validate');
}
$data[0] = print_image ($img, true,
array ("class" => "image_status",
"width" => 16,
"height" => 16,
"title" => $title));
switch ($event["criticity"]) {
default:
case 0:
$img = "images/status_sets/default/severity_maintenance.png";
break;
case 1:
$img = "images/status_sets/default/severity_informational.png";
break;
case 2:
$img = "images/status_sets/default/severity_normal.png";
break;
case 3:
$img = "images/status_sets/default/severity_warning.png";
break;
case 4:
$img = "images/status_sets/default/severity_critical.png";
break;
}
$data[1] = print_image ($img, true,
array ("class" => "image_status",
"width" => 12,
"height" => 12,
"title" => get_priority_name ($event["criticity"])));
$data[2] = print_event_type_img ($event["event_type"], true);
// Event description
$data[3] = '';
$data[3] .= '';
if (strlen ($event["evento"]) > 50) {
$data[3] .= mb_substr ($event["evento"], 0, 50)."...";
}
else {
$data[3] .= $event["evento"];
}
$data[3] .= '';
if ($event["event_type"] == "system") {
$data[4] = __('System');
}
elseif ($event["id_agente"] > 0) {
// Agent name
$data[4] = print_agent_name ($event["id_agente"], true);
}
else {
$data[4] = __('Alert').__('SNMP');
}
$data[5] = '';
if ($event["id_agentmodule"] != 0) {
$data[5] .= '';
$data[5] .= print_image ("images/bricks.png", true,
array ("title" => __('Go to data overview')));
$data[5] .= ' ';
}
if ($event["id_alert_am"] != 0) {
$data[5] .= '';
$data[5] .= print_image ("images/bell.png", true,
array ("title" => __('Go to alert overview')));
$data[5] .= '';
}
$data[6] = print_group_icon ($event["id_grupo"], true);
if ($group_rep == 1) {
$data[7] = $event["event_rep"];
}
else {
if (!empty ($event["estado"])) {
if ($event["id_usuario"] != '0' && $event["id_usuario"] != ''){
$data[7] = ''.mb_substr ($event["id_usuario"],0,8).'';
}
else {
$data[7] = __('System');
}
}
else {
$data[7] = '';
}
}
//Time
if ($group_rep == 1) {
$data[8] = print_timestamp ($event['timestamp_rep'], true);
}
else {
$data[8] = print_timestamp ($event["timestamp"], true);
}
//Actions
$data[9] = '';
// Validate event
if (($event["estado"] == 0) and (give_acl ($config["id_user"], $event["id_grupo"], "IW") == 1)) {
$data[9] .= '';
$data[9] .= print_image ("images/ok.png", true,
array ("title" => __('Validate event')));
$data[9] .= '';
}
// Delete event
if (give_acl ($config["id_user"], $event["id_grupo"], "IM") == 1) {
$data[9] .= '';
$data[9] .= print_image ("images/cross.png", true,
array ("title" => __('Delete event')));
$data[9] .= '';
}
// Create incident from this event
if (give_acl ($config["id_user"], $event["id_grupo"], "IW") == 1) {
$data[9] .= '';
$data[9] .= print_image ("images/page_lightning.png", true,
array ("title" => __('Create incident from event')));
$data[9] .= '';
}
//Checkbox
$data[10] = 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 '
';
}
else {
echo '
'.__('No events').'
';
}
echo '
';
unset ($table);
require_jquery_file ('bgiframe');
require_jquery_file ('autocomplete');
?>