';
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 9aec882fd2..7480fb48a2 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -109,6 +109,20 @@ function events_get_event ($id, $fields = false) {
return $event;
}
+function events_get_events_no_grouped($sql_post, $offset = 0,
+ $pagination = 1, $meta = false, $history = false, $total = false,
+ $history_db = false, $order = "ASC") {
+
+ global $config;
+
+ $table = events_get_events_table($meta, $history);
+
+ $sql = "SELECT * FROM $table te WHERE 1=1 " . $sql_post;
+
+ $events = db_get_all_rows_sql ($sql, $history_db);
+
+ return $events;
+}
function events_get_events_grouped($sql_post, $offset = 0,
$pagination = 1, $meta = false, $history = false, $total = false,
@@ -124,7 +138,7 @@ function events_get_events_grouped($sql_post, $offset = 0,
else {
$groupby_extra = '';
}
-
+
switch ($config["dbtype"]) {
case "mysql":
db_process_sql ('SET group_concat_max_len = 9999999');
@@ -136,19 +150,19 @@ function events_get_events_grouped($sql_post, $offset = 0,
}
else {
$sql = "SELECT *, MAX(id_evento) AS id_evento,
- GROUP_CONCAT(DISTINCT user_comment SEPARATOR '
') AS user_comment,
- GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids,
- COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
- MIN(utimestamp) AS timestamp_rep_min,
- (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user,
- (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario,
- (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente,
- (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity,
- (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp
- FROM $table te
- WHERE 1=1 " . $sql_post . "
- GROUP BY estado, evento, id_agentmodule" . $groupby_extra . "
- ORDER BY timestamp_rep " . $order . " LIMIT " . $offset . "," . $pagination;
+ GROUP_CONCAT(DISTINCT user_comment SEPARATOR '
') AS user_comment,
+ GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids,
+ COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
+ MIN(utimestamp) AS timestamp_rep_min,
+ (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user,
+ (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario,
+ (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente,
+ (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity,
+ (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp
+ FROM $table te
+ WHERE 1=1 " . $sql_post . "
+ GROUP BY estado, evento, id_agentmodule" . $groupby_extra . "
+ ORDER BY timestamp_rep " . $order . " LIMIT " . $offset . "," . $pagination;
}
break;
case "postgresql":
@@ -210,7 +224,6 @@ function events_get_events_grouped($sql_post, $offset = 0,
}
break;
}
-
//Extract the events by filter (or not) from db
$events = db_get_all_rows_sql ($sql, $history_db);
@@ -1173,89 +1186,6 @@ function events_print_type_description ($type, $return = false) {
echo $output;
}
-/**
- * Get all the events happened in a group during a period of time.
- *
- * The returned events will be in the time interval ($date - $period, $date]
- *
- * @param mixed $id_group Group id to get events for.
- * @param int $period Period of time in seconds to get events.
- * @param int $date Beginning date to get events.
- *
- * @return array An array with all the events happened.
- */
-function events_get_group_events ($id_group, $period, $date,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_search = false, $meta = false, $history = false,
- $filter_event_type = false) {
-
- global $config;
-
- $id_group = groups_safe_acl ($config["id_user"], $id_group, "ER");
-
- if (empty ($id_group)) {
- //An empty array means the user doesn't have access
- return false;
- }
-
- $datelimit = $date - $period;
-
- $sql_where = ' AND 1 = 1 ';
- $criticities = array();
- if ($filter_event_critical) {
- $criticities[] = 4;
- }
- if ($filter_event_warning) {
- $criticities[] = 3;
- }
- if (!empty($criticities)) {
- $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
- }
- if ($filter_event_validated) {
- $sql_where .= ' AND estado = 1 ';
- }
- if ($filter_event_no_validated) {
- $sql_where .= ' AND estado = 0 ';
- }
-
- if (!empty($filter_event_search)) {
- $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_search) . '%"'.
- ' OR id_evento LIKE "%' . io_safe_input($filter_event_search) . '%")';
- }
-
- if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
- $sql_where .= ' AND (';
- $type = array();
- foreach ($filter_event_type as $event_type) {
- if ($event_type != "") {
- // If normal, warning, could be several (going_up_warning, going_down_warning... too complex
- // for the user so for him is presented only "warning, critical and normal"
- if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
- $type[] = " event_type LIKE '%$event_type%' ";
- }
- else if ($event_type == "not_normal") {
- $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
- }
- else if ($event_type != "all") {
- $type[] = " event_type = '" . $event_type."'";
- }
- }
- }
-
- $sql_where .= implode(' OR ', $type) . ')';
- }
-
- $sql_where .= sprintf('
- AND id_grupo IN (%s)
- AND utimestamp > %d
- AND utimestamp <= %d ',
- implode (",", $id_group), $datelimit, $date);
-
- return events_get_events_grouped($sql_where, 0, 1000, $meta,
- false, false, $history);
-}
-
/**
* Get all the events happened in a group during a period of time.
*
@@ -1328,46 +1258,72 @@ function events_get_group_events_steps ($begin, &$result, $id_group, $period, $d
*
* @return array An array with all the events happened.
*/
-function events_get_agent ($id_agent, $period, $date = 0,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $history = false, $filter_event_type = false) {
-
+function events_get_agent ($id_agent, $period, $date = 0,
+ $history = false, $show_summary_group = false, $filter_event_severity = false,
+ $filter_event_type = false, $filter_event_status = false, $filter_event_filter_search=false,
+ $id_group = false, $events_group = false, $id_agent_module = false, $events_module = false) {
+ global $config;
+
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
+
+ if($events_group){
+ $id_group = groups_safe_acl ($config["id_user"], $id_group, "ER");
- $datelimit = $date - $period;
-
- $sql_where = '';
-
- $criticities = array();
- if ($filter_event_critical) {
- $criticities[] = 4;
- }
- if ($filter_event_warning) {
- $criticities[] = 3;
- }
- if (!empty($criticities)) {
- $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
- }
-
- if ( $filter_event_validated && $filter_event_no_validated ) {
- $sql_where .= " AND (estado = 1 OR estado = 0)";
- }
- else {
- if ($filter_event_validated) {
- $sql_where .= ' AND estado = 1 ';
- } else {
- if ($filter_event_no_validated) {
- $sql_where .= ' AND estado = 0 ';
- }
+ if (empty ($id_group)) {
+ //An empty array means the user doesn't have access
+ return false;
}
}
+ $datelimit = $date - $period;
+
+ $sql_where = '';
+ $severity_all = 0;
+ if (!empty($filter_event_severity)) {
+ foreach ($filter_event_severity as $key => $value) {
+ switch ($value) {
+ case -1:
+ $severity_all = 1;
+ break;
+ case 34:
+ $filter_event_severity[$key] = '3, 4';
+ break;
+ case 20:
+ $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
+ break;
+ case 21:
+ $filter_event_severity[$key] = '4, 2';
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$severity_all){
+ $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
+ }
+ }
+
+ $status_all = 0;
+ if(!empty($filter_event_status)){
+ foreach ($filter_event_status as $key => $value) {
+ switch ($value) {
+ case -1:
+ $status_all = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$status_all){
+ $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
+ }
+ }
+
if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
$sql_where .= ' AND (';
$type = array();
@@ -1386,52 +1342,35 @@ function events_get_agent ($id_agent, $period, $date = 0,
}
}
}
-
$sql_where .= implode(' OR ', $type) . ')';
}
-
- $sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d
- AND utimestamp <= %d ', $id_agent, $datelimit, $date);
-
- return events_get_events_grouped($sql_where, 0, 1000,
- is_metaconsole(), false, false, $history);
-}
-/**
- * Get all the events happened in an Agent during a period of time.
- *
- * The returned events will be in the time interval ($date - $period, $date]
- *
- * @param int $id_agent_module Module id to get events.
- * @param int $period Period of time in seconds to get events.
- * @param int $date Beginning date to get events.
- *
- * @return array An array with all the events happened.
- */
-function events_get_module ($id_agent_module, $period, $date = 0, $history = false) {
- global $config;
-
- if (!is_numeric ($date)) {
- $date = strtotime ($date);
- }
- if (empty ($date)) {
- $date = get_system_time ();
+ if (!empty($filter_event_filter_search)) {
+ $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
+ ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
- $datelimit = $date - $period;
-
- $sql_where = sprintf(' AND id_agentmodule = %d AND utimestamp > %d
+ if($events_group){
+ $sql_where .= sprintf(' AND id_grupo IN (%s) AND utimestamp > %d
+ AND utimestamp <= %d ', implode (",", $id_group), $datelimit, $date);
+ }
+ elseif($events_module){
+ $sql_where .= sprintf(' AND id_agentmodule = %d AND utimestamp > %d
AND utimestamp <= %d ', $id_agent_module, $datelimit, $date);
-
- return events_get_events_grouped($sql_where, 0, 1000, false,
- false, false, $history);
-
- $sql = sprintf ('SELECT evento, event_type, criticity, count(*) as count_rep, max(timestamp) AS time2
- FROM tevento
- WHERE id_agentmodule = %d AND utimestamp > %d AND utimestamp <= %d
- GROUP BY id_agentmodule, evento ORDER BY time2 DESC', $id_agent_module, $datelimit, $date);
-
- return db_get_all_rows_sql ($sql);
+ }
+ else{
+ $sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d
+ AND utimestamp <= %d ', $id_agent, $datelimit, $date);
+ }
+
+ if($show_summary_group){
+ return events_get_events_grouped($sql_where, 0, 1000,
+ is_metaconsole(), false, false, $history);
+ }
+ else{
+ return events_get_events_no_grouped($sql_where, 0, 1000,
+ is_metaconsole(), false, false, $history);
+ }
}
/**
@@ -1549,13 +1488,22 @@ function events_get_severity_types ($severity_id) {
*
* @return array Status description array.
*/
-function events_get_all_status () {
+function events_get_all_status ($report = false) {
$fields = array ();
- $fields[-1] = __('All event');
- $fields[0] = __('Only new');
- $fields[1] = __('Only validated');
- $fields[2] = __('Only in process');
- $fields[3] = __('Only not validated');
+ if(!$report){
+ $fields[-1] = __('All event');
+ $fields[0] = __('Only new');
+ $fields[1] = __('Only validated');
+ $fields[2] = __('Only in process');
+ $fields[3] = __('Only not validated');
+ }
+ else{
+ $fields[-1] = __('All event');
+ $fields[0] = __('New');
+ $fields[1] = __('Validated');
+ $fields[2] = __('In process');
+ $fields[3] = __('Not Validated');
+ }
return $fields;
}
@@ -2643,12 +2591,20 @@ function events_clean_tags ($tags) {
* @return array An array with all the events happened.
*/
function events_get_count_events_by_agent ($id_group, $period, $date,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_search = false) {
+ $filter_event_severity = false, $filter_event_type = false,
+ $filter_event_status = false, $filter_event_filter_search = false) {
global $config;
-
+
+ //date
+ if (!is_numeric ($date)) {
+ $date = strtotime ($date);
+ }
+ if (empty ($date)) {
+ $date = get_system_time ();
+ }
+
+ //group
$id_group = groups_safe_acl ($config["id_user"], $id_group, "AR");
if (empty ($id_group)) {
@@ -2658,30 +2614,74 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
$datelimit = $date - $period;
- $sql_where = ' AND 1 = 1 ';
- $criticities = array();
- if ($filter_event_critical) {
- $criticities[] = 4;
+ $sql_where = '';
+ $severity_all = 0;
+ if (!empty($filter_event_severity)) {
+ foreach ($filter_event_severity as $key => $value) {
+ switch ($value) {
+ case -1:
+ $severity_all = 1;
+ break;
+ case 34:
+ $filter_event_severity[$key] = '3, 4';
+ break;
+ case 20:
+ $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
+ break;
+ case 21:
+ $filter_event_severity[$key] = '4, 2';
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$severity_all){
+ $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
+ }
}
- if ($filter_event_warning) {
- $criticities[] = 3;
- }
- if (!empty($criticities)) {
- $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
+
+ $status_all = 0;
+ if(!empty($filter_event_status)){
+ foreach ($filter_event_status as $key => $value) {
+ switch ($value) {
+ case -1:
+ $status_all = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$status_all){
+ $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
+ }
}
- if ($filter_event_validated) {
- $sql_where .= ' AND estado = 1 ';
+ if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
+ $sql_where .= ' AND (';
+ $type = array();
+ foreach ($filter_event_type as $event_type) {
+ if ($event_type != "") {
+ // If normal, warning, could be several (going_up_warning, going_down_warning... too complex
+ // for the user so for him is presented only "warning, critical and normal"
+ if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
+ $type[] = " event_type LIKE '%$event_type%' ";
+ }
+ else if ($event_type == "not_normal") {
+ $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
+ }
+ else if ($event_type != "all") {
+ $type[] = " event_type = '" . $event_type."'";
+ }
+ }
+ }
+ $sql_where .= implode(' OR ', $type) . ')';
}
- if ($filter_event_no_validated) {
- $sql_where .= ' AND estado = 0 ';
+
+ if (!empty($filter_event_filter_search)) {
+ $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
+ ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
-
- if (!empty($filter_event_search)) {
- $sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'.
- ' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")';
- }
-
+
$sql = sprintf ('SELECT id_agente,
(SELECT t2.nombre
FROM tagente t2
@@ -2689,9 +2689,9 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
COUNT(*) AS count
FROM tevento t3
WHERE utimestamp > %d AND utimestamp <= %d
- AND id_grupo IN (%s) ' . $sql_where . '
+ AND id_grupo IN (%s) %s
GROUP BY id_agente',
- $datelimit, $date, implode (",", $id_group));
+ $datelimit, $date, implode (",", $id_group), $sql_where);
$rows = db_get_all_rows_sql ($sql);
@@ -2722,12 +2722,10 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
* @return array An array with all the events happened.
*/
function events_get_count_events_validated_by_user ($filter, $period, $date,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_search = false) {
-
+ $filter_event_severity = false, $filter_event_type = false,
+ $filter_event_status = false, $filter_event_filter_search = false) {
global $config;
-
+ //group
$sql_filter = ' AND 1=1 ';
if (isset($filter['id_group'])) {
$id_group = groups_safe_acl ($config["id_user"], $filter['id_group'], "AR");
@@ -2740,35 +2738,93 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
$sql_filter .=
sprintf(' AND id_grupo IN (%s) ', implode (",", $id_group));
}
+
if (!empty($filter['id_agent'])) {
$sql_filter .=
sprintf(' AND id_agente = %d ', $filter['id_agent']);
}
+ if(!empty($filter['id_agentmodule'])){
+ $sql_filter .=
+ sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']);
+ }
+
+ //date
+ if (!is_numeric ($date)) {
+ $date = strtotime ($date);
+ }
+ if (empty ($date)) {
+ $date = get_system_time ();
+ }
+
$datelimit = $date - $period;
- $sql_where = ' AND 1 = 1 ';
- $criticities = array();
- if ($filter_event_critical) {
- $criticities[] = 4;
+ $sql_where = '';
+ $severity_all = 0;
+ if (!empty($filter_event_severity)) {
+ foreach ($filter_event_severity as $key => $value) {
+ switch ($value) {
+ case -1:
+ $severity_all = 1;
+ break;
+ case 34:
+ $filter_event_severity[$key] = '3, 4';
+ break;
+ case 20:
+ $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
+ break;
+ case 21:
+ $filter_event_severity[$key] = '4, 2';
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$severity_all){
+ $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
+ }
}
- if ($filter_event_warning) {
- $criticities[] = 3;
- }
- if (!empty($criticities)) {
- $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
+
+ $status_all = 0;
+ if(!empty($filter_event_status)){
+ foreach ($filter_event_status as $key => $value) {
+ switch ($value) {
+ case -1:
+ $status_all = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$status_all){
+ $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
+ }
}
- if ($filter_event_validated) {
- $sql_where .= ' AND estado = 1 ';
+ if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
+ $sql_where .= ' AND (';
+ $type = array();
+ foreach ($filter_event_type as $event_type) {
+ if ($event_type != "") {
+ // If normal, warning, could be several (going_up_warning, going_down_warning... too complex
+ // for the user so for him is presented only "warning, critical and normal"
+ if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
+ $type[] = " event_type LIKE '%$event_type%' ";
+ }
+ else if ($event_type == "not_normal") {
+ $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
+ }
+ else if ($event_type != "all") {
+ $type[] = " event_type = '" . $event_type."'";
+ }
+ }
+ }
+ $sql_where .= implode(' OR ', $type) . ')';
}
- if ($filter_event_no_validated) {
- $sql_where .= ' AND estado = 0 ';
- }
-
- if (!empty($filter_event_search)) {
- $sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'.
- ' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")';
+
+ if (!empty($filter_event_filter_search)) {
+ $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
+ ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
$sql = sprintf ('SELECT id_usuario,
@@ -2778,10 +2834,9 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
COUNT(*) AS count
FROM tevento t3
WHERE utimestamp > %d AND utimestamp <= %d
- %s ' . $sql_where . '
+ %s %s
GROUP BY id_usuario',
- $datelimit, $date, $sql_filter);
-
+ $datelimit, $date, $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql);
if ($rows == false)
@@ -2795,7 +2850,6 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
}
$return[$user_name] = $row['count'];
}
-
return $return;
}
@@ -2811,9 +2865,8 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
* @return array An array with all the events happened.
*/
function events_get_count_events_by_criticity ($filter, $period, $date,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_search = false) {
+ $filter_event_severity = false, $filter_event_type = false,
+ $filter_event_status = false, $filter_event_filter_search = false) {
global $config;
@@ -2829,44 +2882,101 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
$sql_filter .=
sprintf(' AND id_grupo IN (%s) ', implode (",", $id_group));
}
+
if (!empty($filter['id_agent'])) {
$sql_filter .=
sprintf(' AND id_agente = %d ', $filter['id_agent']);
}
+
+ if(!empty($filter['id_agentmodule'])){
+ $sql_filter .=
+ sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']);
+ }
+
+ if (!is_numeric ($date)) {
+ $date = strtotime ($date);
+ }
+ if (empty ($date)) {
+ $date = get_system_time ();
+ }
$datelimit = $date - $period;
- $sql_where = ' AND 1 = 1 ';
- $criticities = array();
- if ($filter_event_critical) {
- $criticities[] = 4;
+ $sql_where = '';
+ $severity_all = 0;
+ if (!empty($filter_event_severity)) {
+ foreach ($filter_event_severity as $key => $value) {
+ switch ($value) {
+ case -1:
+ $severity_all = 1;
+ break;
+ case 34:
+ $filter_event_severity[$key] = '3, 4';
+ break;
+ case 20:
+ $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
+ break;
+ case 21:
+ $filter_event_severity[$key] = '4, 2';
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$severity_all){
+ $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
+ }
}
- if ($filter_event_warning) {
- $criticities[] = 3;
- }
- if (!empty($criticities)) {
- $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
+
+ $status_all = 0;
+ if(!empty($filter_event_status)){
+ foreach ($filter_event_status as $key => $value) {
+ switch ($value) {
+ case -1:
+ $status_all = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$status_all){
+ $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
+ }
}
- if ($filter_event_validated) {
- $sql_where .= ' AND estado = 1 ';
+ if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
+ $sql_where .= ' AND (';
+ $type = array();
+ foreach ($filter_event_type as $event_type) {
+ if ($event_type != "") {
+ // If normal, warning, could be several (going_up_warning, going_down_warning... too complex
+ // for the user so for him is presented only "warning, critical and normal"
+ if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
+ $type[] = " event_type LIKE '%$event_type%' ";
+ }
+ else if ($event_type == "not_normal") {
+ $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
+ }
+ else if ($event_type != "all") {
+ $type[] = " event_type = '" . $event_type."'";
+ }
+ }
+ }
+ $sql_where .= implode(' OR ', $type) . ')';
}
- if ($filter_event_no_validated) {
- $sql_where .= ' AND estado = 0 ';
+
+ if (!empty($filter_event_filter_search)) {
+ $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
+ ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
-
- if (!empty($filter_event_search)) {
- $sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'.
- ' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")';
- }
-
+
$sql = sprintf ('SELECT criticity,
COUNT(*) AS count
FROM tevento
WHERE utimestamp > %d AND utimestamp <= %d
- %s ' . $sql_where . '
+ %s %s
GROUP BY criticity',
- $datelimit, $date, $sql_filter);
+ $datelimit, $date, $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql);
@@ -2893,12 +3003,12 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
* @return array An array with all the events happened.
*/
function events_get_count_events_validated ($filter, $period = null, $date = null,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_search = false) {
+ $filter_event_severity = false, $filter_event_type = false,
+ $filter_event_status = false, $filter_event_filter_search = false) {
global $config;
+ //group
$sql_filter = " 1=1 ";
if (isset($filter['id_group'])) {
$id_group = groups_safe_acl ($config["id_user"], $filter['id_group'], "AR");
@@ -2911,11 +3021,25 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul
$sql_filter .=
sprintf(" AND id_grupo IN (%s) ", implode (",", $id_group));
}
+ //agent
if (!empty($filter['id_agent'])) {
$sql_filter .=
sprintf(" AND id_agente = %d ", $filter['id_agent']);
}
+ //module
+ if(!empty($filter['id_agentmodule'])){
+ $sql_filter .=
+ sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']);
+ }
+ //date
+ if (!is_numeric ($date)) {
+ $date = strtotime ($date);
+ }
+ if (empty ($date)) {
+ $date = get_system_time ();
+ }
+
$date_filter = '';
if (!empty($date) && !empty($period)) {
$datelimit = $date - $period;
@@ -2934,31 +3058,75 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul
$date_filter .= sprintf (" AND utimestamp <= %d ", $date);
}
- $sql_where = " AND 1=1 ";
- $criticities = array();
- if ($filter_event_critical) {
- $criticities[] = 4;
- }
- if ($filter_event_warning) {
- $criticities[] = 3;
- }
- if (!empty($criticities)) {
- $sql_where .= " AND criticity IN (" . implode(",", $criticities) . ")";
- }
-
- if ($filter_event_validated) {
- $sql_where .= " AND estado = 1 ";
- }
- if ($filter_event_no_validated) {
- $sql_where .= " AND estado = 0 ";
- }
-
- if (!empty($filter_event_search)) {
- $sql_where .= " AND (evento LIKE '%%" . io_safe_input($filter_event_search) . "%%'" .
- " OR id_evento LIKE '%%" . io_safe_input($filter_event_search) . "%%')";
+ $sql_where = '';
+ $severity_all = 0;
+ if (!empty($filter_event_severity)) {
+ foreach ($filter_event_severity as $key => $value) {
+ switch ($value) {
+ case -1:
+ $severity_all = 1;
+ break;
+ case 34:
+ $filter_event_severity[$key] = '3, 4';
+ break;
+ case 20:
+ $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
+ break;
+ case 21:
+ $filter_event_severity[$key] = '4, 2';
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$severity_all){
+ $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
+ }
}
- $sql = sprintf ("SELECT estado, COUNT(*) AS count FROM tevento WHERE %s " . $sql_where . " GROUP BY estado", $sql_filter);
+ $status_all = 0;
+ if(!empty($filter_event_status)){
+ foreach ($filter_event_status as $key => $value) {
+ switch ($value) {
+ case -1:
+ $status_all = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ if(!$status_all){
+ $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
+ }
+ }
+
+ if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
+ $sql_where .= ' AND (';
+ $type = array();
+ foreach ($filter_event_type as $event_type) {
+ if ($event_type != "") {
+ // If normal, warning, could be several (going_up_warning, going_down_warning... too complex
+ // for the user so for him is presented only "warning, critical and normal"
+ if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
+ $type[] = " event_type LIKE '%$event_type%' ";
+ }
+ else if ($event_type == "not_normal") {
+ $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
+ }
+ else if ($event_type != "all") {
+ $type[] = " event_type = '" . $event_type."'";
+ }
+ }
+ }
+ $sql_where .= implode(' OR ', $type) . ')';
+ }
+
+ if (!empty($filter_event_filter_search)) {
+ $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
+ ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
+ }
+
+ $sql = sprintf ("SELECT estado, COUNT(*) AS count FROM tevento WHERE %s %s GROUP BY estado", $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql);
diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php
index b0d4cfd18f..7e78271df1 100644
--- a/pandora_console/include/functions_graph.php
+++ b/pandora_console/include/functions_graph.php
@@ -2997,7 +2997,7 @@ function graph_events_validated($width = 300, $height = 200, $url = "", $meta =
global $config;
global $graphic_type;
- $data_graph = reporting_get_count_events_validated(
+ $data_graph = events_get_count_events_validated(
array('id_group' => array_keys(users_get_groups())));
$colors = array();
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index 54bd61c303..d309387606 100644
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -405,15 +405,6 @@ function reporting_make_reporting_data($report = null, $id_report,
$report,
$content);
break;
- case 'agent_detailed_event':
- case 'event_report_agent':
- $report['contents'][] = reporting_event_report_agent(
- $report,
- $content,
- $type,
- $force_width_chart,
- $force_height_chart);
- break;
case 'group_report':
$report['contents'][] = reporting_group_report(
$report,
@@ -444,10 +435,23 @@ function reporting_make_reporting_data($report = null, $id_report,
$content,
$type);
break;
+ case 'agent_detailed_event':
+ case 'event_report_agent':
+ $report['contents'][] = reporting_event_report_agent(
+ $report,
+ $content,
+ $type,
+ $force_width_chart,
+ $force_height_chart);
+ break;
case 'event_report_module':
$report['contents'][] = reporting_event_report_module(
$report,
- $content);
+ $content,
+ $type,
+ $force_width_chart,
+ $force_height_chart,
+ $pdf);
break;
case 'event_report_group':
$report['contents'][] = reporting_event_report_group(
@@ -1287,26 +1291,25 @@ function reporting_event_report_group($report, $content,
$return["date"] = reporting_get_date_text($report, $content);
$event_filter = $content['style'];
-
- $filter_event_no_validated = $event_filter['filter_event_no_validated'];
- $filter_event_validated = $event_filter['filter_event_validated'];
- $filter_event_critical = $event_filter['filter_event_critical'];
- $filter_event_warning = $event_filter['filter_event_warning'];
+ $return['show_summary_group'] = $event_filter['show_summary_group'];
+ //filter
+ $show_summary_group = $event_filter['show_summary_group'];
+ $filter_event_severity = json_decode($event_filter['filter_event_severity'],true);
+ $filter_event_type = json_decode($event_filter['filter_event_type'],true);
+ $filter_event_status = json_decode($event_filter['filter_event_status'],true);
$filter_event_filter_search = $event_filter['event_filter_search'];
- $filter_event_type = json_decode($event_filter['filter_event_type'],true);
- $event_graph_by_agent = $event_filter['event_graph_by_agent'];
- $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
- $event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
+ //graphs
+ $event_graph_by_agent = $event_filter['event_graph_by_agent'];
+ $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
+ $event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated'];
-
- $data = reporting_get_group_detailed_event(
- $content['id_group'], $content['period'], $report["datetime"],
- true, true, $filter_event_validated, $filter_event_critical,
- $filter_event_warning, $filter_event_no_validated,
- $filter_event_filter_search, 'hash', $history, $filter_event_type);
-
+ $data = events_get_agent (false, $content['period'], $report["datetime"],
+ $history, $show_summary_group, $filter_event_severity,
+ $filter_event_type, $filter_event_status, $filter_event_filter_search,
+ $content['id_group'], true);
+
if (empty($data)) {
$return['failed'] = __('No events');
}
@@ -1314,8 +1317,6 @@ function reporting_event_report_group($report, $content,
$return['data'] = array_reverse($data);
}
-
-
reporting_set_conf_charts($width, $height, $only_image, $type,
$content, $ttl);
@@ -1327,22 +1328,16 @@ function reporting_event_report_group($report, $content,
$height = $force_height_chart;
}
-
-
$return['chart']['by_agent'] = null;
$return['chart']['by_user_validator'] = null;
$return['chart']['by_criticity'] = null;
$return['chart']['validated_vs_unvalidated'] = null;
if ($event_graph_by_agent) {
- $data_graph = reporting_get_count_events_by_agent(
- $content['id_group'], $content['period'],
- $report["datetime"],
- $filter_event_validated,
- $filter_event_critical,
- $filter_event_warning,
- $filter_event_no_validated,
- $filter_event_filter_search);
+ $data_graph = events_get_count_events_by_agent(
+ $content['id_group'], $content['period'], $report["datetime"],
+ $filter_event_severity, $filter_event_type,
+ $filter_event_status, $filter_event_filter_search);
$return['chart']['by_agent']= pie3d_graph(
false,
@@ -1358,15 +1353,10 @@ function reporting_event_report_group($report, $content,
}
if ($event_graph_by_user_validator) {
- $data_graph =
- reporting_get_count_events_validated_by_user(
- array('id_group' => $content['id_group']), $content['period'],
- $report["datetime"],
- $filter_event_validated,
- $filter_event_critical,
- $filter_event_warning,
- $filter_event_no_validated,
- $filter_event_filter_search);
+ $data_graph = events_get_count_events_validated_by_user(
+ array('id_group' => $content['id_group']), $content['period'],
+ $report["datetime"],$filter_event_severity, $filter_event_type,
+ $filter_event_status, $filter_event_filter_search);
$return['chart']['by_user_validator'] = pie3d_graph(
false,
@@ -1382,14 +1372,10 @@ function reporting_event_report_group($report, $content,
}
if ($event_graph_by_criticity) {
- $data_graph = reporting_get_count_events_by_criticity(
+ $data_graph = events_get_count_events_by_criticity(
array('id_group' => $content['id_group']), $content['period'],
- $report["datetime"],
- $filter_event_validated,
- $filter_event_critical,
- $filter_event_warning,
- $filter_event_no_validated,
- $filter_event_filter_search);
+ $report["datetime"],$filter_event_severity, $filter_event_type,
+ $filter_event_status, $filter_event_filter_search);
$colors = get_criticity_pie_colors($data_graph);
@@ -1409,15 +1395,10 @@ function reporting_event_report_group($report, $content,
}
if ($event_graph_validated_vs_unvalidated) {
- $data_graph =
- reporting_get_count_events_validated(
- array('id_group' => $content['id_group']), $content['period'],
- $report["datetime"],
- $filter_event_validated,
- $filter_event_critical,
- $filter_event_warning,
- $filter_event_no_validated,
- $filter_event_filter_search);
+ $data_graph = events_get_count_events_validated(
+ array('id_group' => $content['id_group']), $content['period'],
+ $report["datetime"],$filter_event_severity, $filter_event_type,
+ $filter_event_status, $filter_event_filter_search);
$return['chart']['validated_vs_unvalidated'] = pie3d_graph(
false,
@@ -1436,14 +1417,30 @@ function reporting_event_report_group($report, $content,
metaconsole_restore_db();
}
- $return['total_events'] = count($return['data']);
+ //total_events
+ if(isset($return['data'])){
+ $return['total_events'] = count($return['data']);
+ }
+ else{
+ $return['total_events'] = 0;
+ }
return reporting_check_structure_content($return);
}
-function reporting_event_report_module($report, $content) {
- global $config;
+function reporting_event_report_module($report, $content,
+ $type = 'dinamic', $force_width_chart = null,
+ $force_height_chart = null, $pdf=0) {
+ global $config;
+
+ if($pdf){
+ $ttl = 2;
+ }
+ else{
+ $ttl = 1;
+ }
+
$return['type'] = 'event_report_module';
if (empty($content['name'])) {
@@ -1467,23 +1464,39 @@ function reporting_event_report_module($report, $content) {
$return["date"] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
- $data = reporting_get_module_detailed_event(
- $content['id_agent_module'], $content['period'],
- $report["datetime"], true, false, true);
+ $event_filter = $content['style'];
+ $return['show_summary_group'] = $event_filter['show_summary_group'];
+ //filter
+ $show_summary_group = $event_filter['show_summary_group'];
+ $filter_event_severity = json_decode($event_filter['filter_event_severity'],true);
+ $filter_event_type = json_decode($event_filter['filter_event_type'],true);
+ $filter_event_status = json_decode($event_filter['filter_event_status'],true);
+ $filter_event_filter_search = $event_filter['event_filter_search'];
+ //graphs
+ $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
+ $event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
+ $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated'];
+
+ //data events
+ $data = reporting_get_module_detailed_event (
+ $content['id_agent_module'], $content['period'], $report["datetime"],
+ $show_summary_group, $filter_event_severity, $filter_event_type,
+ $filter_event_status, $filter_event_filter_search, $force_width_chart,
+ $event_graph_by_user_validator, $event_graph_by_criticity,
+ $event_graph_validated_vs_unvalidated, $ttl);
+
if (empty($data)) {
$return['failed'] = __('No events');
}
else {
$return['data'] = array_reverse($data);
- }
-
+ }
+
if ($config['metaconsole']) {
metaconsole_restore_db();
}
- $return['total_events'] = count($return['data']);
-
return reporting_check_structure_content($return);
}
@@ -2176,38 +2189,39 @@ function reporting_event_report_agent($report, $content,
if ($config['history_event_enabled'])
$history = true;
- $return['title'] = $content['name'];
- $return['subtitle'] = agents_get_name($content['id_agent']);
- $return["description"] = $content["description"];
- $return["date"] = reporting_get_date_text($report, $content);
- $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
+ $return['title'] = $content['name'];
+ $return['subtitle'] = agents_get_name($content['id_agent']);
+ $return["description"] = $content["description"];
+ $return["date"] = reporting_get_date_text($report, $content);
+ $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
+ $return['show_summary_group'] = $content['style']['show_summary_group'];
$style = $content['style'];
-
- $filter_event_no_validated = $style['filter_event_no_validated'];
- $filter_event_validated = $style['filter_event_validated'];
- $filter_event_critical = $style['filter_event_critical'];
- $filter_event_warning = $style['filter_event_warning'];
- $filter_event_type = json_decode($style['filter_event_type'], true);
-
- $event_graph_by_user_validator = $style['event_graph_by_user_validator'];
- $event_graph_by_criticity = $style['event_graph_by_criticity'];
+
+ //filter
+ $show_summary_group = $style['show_summary_group'];
+ $filter_event_severity = json_decode($style['filter_event_severity'], true);
+ $filter_event_type = json_decode($style['filter_event_type'], true);
+ $filter_event_status = json_decode($style['filter_event_status'], true);
+ $filter_event_filter_search = $style['event_filter_search'];
+
+ //graph
+ $event_graph_by_user_validator = $style['event_graph_by_user_validator'];
+ $event_graph_by_criticity = $style['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
-
+
$return['data'] = reporting_get_agents_detailed_event(
$content['id_agent'],
$content['period'],
$report["datetime"],
true,
- $filter_event_validated,
- $filter_event_critical,
- $filter_event_warning,
- $filter_event_no_validated,
true,
$history,
- $filter_event_type);
-
-
+ $show_summary_group,
+ $filter_event_severity,
+ $filter_event_type,
+ $filter_event_status,
+ $filter_event_filter_search);
reporting_set_conf_charts($width, $height, $only_image, $type,
$content, $ttl);
@@ -2220,26 +2234,19 @@ function reporting_event_report_agent($report, $content,
$height = $force_height_chart;
}
-
-
$return["chart"]["by_user_validator"] = null;
$return["chart"]["by_criticity"] = null;
$return["chart"]["validated_vs_unvalidated"] = null;
if ($event_graph_by_user_validator) {
- $data_chart =
- reporting_get_count_events_validated_by_user(
- array('id_agent' => $content['id_agent']),
- $content['period'],
- $report["datetime"],
- $filter_event_validated,
- $filter_event_critical,
- $filter_event_warning,
- $filter_event_no_validated);
+ $data_graph = events_get_count_events_validated_by_user(
+ array('id_agent' => $content['id_agent']), $content['period'],
+ $report["datetime"],$filter_event_severity, $filter_event_type,
+ $filter_event_status, $filter_event_filter_search);
$return["chart"]["by_user_validator"] = pie3d_graph(
false,
- $data_chart,
+ $data_graph,
500,
150,
__("other"),
@@ -2251,13 +2258,10 @@ function reporting_event_report_agent($report, $content,
}
if ($event_graph_by_criticity) {
- $data_graph = reporting_get_count_events_by_criticity(
+ $data_graph = events_get_count_events_by_criticity(
array('id_agent' => $content['id_agent']), $content['period'],
- $report["datetime"],
- $filter_event_validated,
- $filter_event_critical,
- $filter_event_warning,
- $filter_event_no_validated);
+ $report["datetime"],$filter_event_severity, $filter_event_type,
+ $filter_event_status, $filter_event_filter_search);
$colors = get_criticity_pie_colors($data_graph);
@@ -2277,13 +2281,10 @@ function reporting_event_report_agent($report, $content,
}
if ($event_graph_validated_vs_unvalidated) {
- $data_graph = reporting_get_count_events_validated(
+ $data_graph = events_get_count_events_validated(
array('id_agent' => $content['id_agent']), $content['period'],
- $report["datetime"],
- $filter_event_validated,
- $filter_event_critical,
- $filter_event_warning,
- $filter_event_no_validated);
+ $report["datetime"],$filter_event_severity, $filter_event_type,
+ $filter_event_status, $filter_event_filter_search);
$return["chart"]["validated_vs_unvalidated"] = pie3d_graph(
false,
@@ -2302,8 +2303,14 @@ function reporting_event_report_agent($report, $content,
metaconsole_restore_db();
}
- $return['total_events'] = count($return['data']);
-
+ //total_events
+ if(isset($return['data'])){
+ $return['total_events'] = count($return['data']);
+ }
+ else{
+ $return['total_events'] = 0;
+ }
+
return reporting_check_structure_content($return);
}
@@ -6036,13 +6043,6 @@ function reporting_set_conf_charts(&$width, &$height, &$only_image, $type,
}
}
-
-
-
-
-
-
-
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
@@ -6051,221 +6051,6 @@ function reporting_set_conf_charts(&$width, &$height, &$only_image, $type,
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
-/**
- * Gets a detailed reporting of groups's events.
- *
- * @param unknown_type $id_group Id of the group.
- * @param unknown_type $period Time period of the report.
- * @param unknown_type $date Date of the report.
- * @param unknown_type $return Whether to return or not.
- * @param unknown_type $html Whether to return HTML code or not.
- *
- * @return string Report of groups's events
- */
-function reporting_get_count_events_validated ($filter, $period = 0,
- $date = 0,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_search = false) {
-
- if (!is_numeric ($date)) {
- $date = strtotime ($date);
- }
- if (empty ($date)) {
- $date = get_system_time ();
- }
-
- return events_get_count_events_validated($filter, $period, $date,
- $filter_event_validated, $filter_event_critical,
- $filter_event_warning, $filter_event_no_validated,
- $filter_event_search);
-}
-
-/**
- * Gets a detailed reporting of groups's events.
- *
- * @param unknown_type $id_group Id of the group.
- * @param unknown_type $period Time period of the report.
- * @param unknown_type $date Date of the report.
- * @param unknown_type $return Whether to return or not.
- * @param unknown_type $html Whether to return HTML code or not.
- *
- * @return string Report of groups's events
- */
-function reporting_get_count_events_by_criticity ($filter, $period = 0,
- $date = 0,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_search = false) {
-
- if (!is_numeric ($date)) {
- $date = strtotime ($date);
- }
- if (empty ($date)) {
- $date = get_system_time ();
- }
-
- return events_get_count_events_by_criticity($filter, $period, $date,
- $filter_event_validated, $filter_event_critical,
- $filter_event_warning, $filter_event_no_validated,
- $filter_event_search);
-}
-
-/**
- * Gets a detailed reporting of groups's events.
- *
- * @param unknown_type $filter.
- * @param unknown_type $period Time period of the report.
- * @param unknown_type $date Date of the report.
- * @param unknown_type $return Whether to return or not.
- * @param unknown_type $html Whether to return HTML code or not.
- *
- * @return string Report of groups's events
- */
-function reporting_get_count_events_validated_by_user ($filter, $period = 0,
- $date = 0,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_search = false) {
-
- if (!is_numeric ($date)) {
- $date = strtotime ($date);
- }
- if (empty ($date)) {
- $date = get_system_time ();
- }
-
- return events_get_count_events_validated_by_user($filter, $period, $date,
- $filter_event_validated, $filter_event_critical,
- $filter_event_warning, $filter_event_no_validated, $filter_event_search);
-}
-
-/**
- * Gets a detailed reporting of groups's events.
- *
- * @param unknown_type $id_group Id of the group.
- * @param unknown_type $period Time period of the report.
- * @param unknown_type $date Date of the report.
- * @param unknown_type $return Whether to return or not.
- * @param unknown_type $html Whether to return HTML code or not.
- *
- * @return string Report of groups's events
- */
-function reporting_get_group_detailed_event ($id_group, $period = 0,
- $date = 0, $return = false, $html = true,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_filter_search = null, $return_type = false,
- $history = false, $filter_event_type = false) {
-
- global $config;
-
- if (!is_numeric ($date)) {
- $date = strtotime ($date);
- }
- if (empty ($date)) {
- $date = get_system_time ();
- }
-
- $table = new stdClass();
- $table->width = '99%';
-
- $table->align = array();
- $table->align[0] = 'center';
- $table->align[2] = 'center';
-
- $table->data = array ();
-
- $table->head = array ();
- $table->head[0] = __('Status');
- $table->head[1] = __('Name');
- $table->head[2] = __('Type');
- $table->head[3] = __('Agent');
- $table->head[4] = __('Severity');
- $table->head[5] = __('Val. by');
- $table->head[6] = __('Timestamp');
-
- $events = events_get_group_events($id_group, $period, $date,
- $filter_event_validated, $filter_event_critical,
- $filter_event_warning, $filter_event_no_validated,
- $filter_event_filter_search, false, $history, $filter_event_type);
-
- if ($return_type === 'hash') {
- return $events;
- }
-
- if ($events) {
- $note = '';
- if (count($events) >= 1000) {
- $note .= '* ' . __('Maximum of events shown') . ' (1000)
';
- }
- foreach ($events as $k => $event) {
- //First pass along the class of this row
- $table->cellclass[$k][1] = $table->cellclass[$k][3] =
- $table->cellclass[$k][4] = $table->cellclass[$k][5] =
- $table->cellclass[$k][6] =
- get_priority_class ($event["criticity"]);
-
- $data = array ();
-
- // Colored box
- switch ($event['estado']) {
- case 0:
- $img_st = "images/star.png";
- $title_st = __('New event');
- break;
- case 1:
- $img_st = "images/tick.png";
- $title_st = __('Event validated');
- break;
- case 2:
- $img_st = "images/hourglass.png";
- $title_st = __('Event in process');
- break;
- }
- $data[] = html_print_image ($img_st, true,
- array ("class" => "image_status",
- "width" => 16,
- "title" => $title_st,
- "id" => 'status_img_' . $event["id_evento"]));
-
- $data[] = ui_print_truncate_text(
- io_safe_output($event['evento']),
- 140, false, true);
-
- //$data[1] = $event['event_type'];
- $data[] = events_print_type_img ($event["event_type"], true);
-
- if (!empty($event['id_agente']))
- $data[] = agents_get_name($event['id_agente']);
- else
- $data[] = __('Pandora System');
- $data[] = get_priority_name ($event['criticity']);
- if (empty($event['id_usuario']) && $event['estado'] == EVENT_VALIDATE) {
- $data[] = '
' . __('System') . '';
- }
- else {
- $user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']);
- $data[] = io_safe_output($user_name);
- }
- $data[] = '
' .
- date($config['date_format'], $event['timestamp_rep']) .
- '';
- array_push ($table->data, $data);
- }
-
- if ($html) {
- return html_print_table ($table, $return) . $note;
- }
- else {
- return $table;
- }
- }
- else {
- return false;
- }
-}
-
/**
* Get a detailed report of summarized events per agent
*
@@ -6281,7 +6066,11 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
* @return mixed A table object (XHTML) or object table is false the html.
*/
function reporting_get_module_detailed_event ($id_modules, $period = 0,
- $date = 0, $return = false, $html = true, $only_data = false) {
+ $date = 0, $show_summary_group = false, $filter_event_severity = false,
+ $filter_event_type = false, $filter_event_status = false,
+ $filter_event_filter_search = false, $force_width_chart = false,
+ $event_graph_by_user_validator = false, $event_graph_by_criticity = false,
+ $event_graph_validated_vs_unvalidated = false, $ttl = 1) {
global $config;
@@ -6301,72 +6090,93 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
$events = array ();
foreach ($id_modules as $id_module) {
- $event = events_get_module ($id_module, (int) $period, (int) $date, $history);
+ $event['data'] = events_get_agent (false, (int) $period, (int) $date,
+ $history, $show_summary_group, $filter_event_severity,
+ $filter_event_type, $filter_event_status, $filter_event_filter_search,
+ false, false, $id_module, true);
+
+ //total_events
+ if(isset($event['data'])){
+ $event['total_events'] = count($event['data']);
+ }
+ else{
+ $event['total_events'] = 0;
+ }
+
+ //graphs
+ if (!empty($force_width_chart)) {
+ $width = $force_width_chart;
+ }
+
+ if (!empty($force_height_chart)) {
+ $height = $force_height_chart;
+ }
+
+ if ($event_graph_by_user_validator) {
+ $data_graph = events_get_count_events_validated_by_user(
+ array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity,
+ $filter_event_type, $filter_event_status, $filter_event_filter_search);
+
+ $event['chart']['by_user_validator'] = pie3d_graph(
+ false,
+ $data_graph,
+ 500,
+ 150,
+ __("other"),
+ ui_get_full_url(false, false, false, false),
+ ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png",
+ $config['fontpath'],
+ $config['font_size'],
+ $ttl);
+ }
+
+ if ($event_graph_by_criticity) {
+ $data_graph = events_get_count_events_by_criticity(
+ array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity,
+ $filter_event_type, $filter_event_status, $filter_event_filter_search);
+
+ $colors = get_criticity_pie_colors($data_graph);
+
+ $event['chart']['by_criticity'] = pie3d_graph(
+ false,
+ $data_graph,
+ 500,
+ 150,
+ __("other"),
+ ui_get_full_url(false, false, false, false),
+ ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png",
+ $config['fontpath'],
+ $config['font_size'],
+ $ttl,
+ false,
+ $colors);
+ }
+
+ if ($event_graph_validated_vs_unvalidated) {
+ $data_graph = events_get_count_events_validated(
+ array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity,
+ $filter_event_type, $filter_event_status, $filter_event_filter_search);
+
+ $event['chart']['validated_vs_unvalidated'] = pie3d_graph(
+ false,
+ $data_graph,
+ 500,
+ 150,
+ __("other"),
+ ui_get_full_url(false, false, false, false),
+ ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png",
+ $config['fontpath'],
+ $config['font_size'],
+ $ttl);
+ }
+
if (!empty ($event)) {
array_push ($events, $event);
}
}
-
- if ($only_data) {
- return $event;
- }
-
- if ($events) {
- $note = '';
- if (count($events) >= 1000) {
- $note .= '* ' . __('Maximum of events shown') . ' (1000)
';
- }
- foreach ($events as $eventRow) {
- foreach ($eventRow as $k => $event) {
- //$k = count($table->data);
- $table->cellclass[$k][1] = $table->cellclass[$k][2] =
- $table->cellclass[$k][3] = $table->cellclass[$k][4] =
- $table->cellclass[$k][5] = get_priority_class ($event["criticity"]);
-
- $data = array ();
-
- // Colored box
- switch ($event['estado']) {
- case 0:
- $img_st = "images/star.png";
- $title_st = __('New event');
- break;
- case 1:
- $img_st = "images/tick.png";
- $title_st = __('Event validated');
- break;
- case 2:
- $img_st = "images/hourglass.png";
- $title_st = __('Event in process');
- break;
- }
- $data[0] = html_print_image ($img_st, true,
- array ("class" => "image_status",
- "width" => 16,
- "title" => $title_st,
- "id" => 'status_img_' . $event["id_evento"]));
-
- $data[1] = io_safe_output($event['evento']);
- $data[2] = $event['event_type'];
- $data[3] = get_priority_name ($event['criticity']);
- $data[4] = $event['event_rep'];
- $data[5] = date($config['date_format'], $event['timestamp_rep']);
- array_push ($table->data, $data);
- }
- }
-
- if ($html) {
- return html_print_table ($table, $return) . $note;
- }
- else {
- return $table;
- }
- }
- else {
- return false;
- }
-}
+ return $events;
+}
/**
* Get a detailed report of summarized events per agent
@@ -6382,10 +6192,10 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
* @return A table object (XHTML)
*/
function reporting_get_agents_detailed_event ($id_agents, $period = 0,
- $date = 0, $return = false, $filter_event_validated = false,
- $filter_event_critical = false, $filter_event_warning = false,
- $filter_event_no_validated = false, $only_data = false,
- $history = false, $filter_event_type = false) {
+ $date = 0, $return = false, $only_data = false, $history = false,
+ $show_summary_group = false, $filter_event_severity = false,
+ $filter_event_type = false, $filter_event_status = false,
+ $filter_event_filter_search = false) {
global $config;
@@ -6407,12 +6217,10 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0,
$events = array ();
foreach ($id_agents as $id_agent) {
- $event = events_get_agent ($id_agent,
- (int)$period,
- (int)$date,
- $filter_event_validated, $filter_event_critical,
- $filter_event_warning, $filter_event_no_validated,
- $history, $filter_event_type);
+ $event = events_get_agent ($id_agent, (int)$period, (int)$date,
+ $history, $show_summary_group, $filter_event_severity,
+ $filter_event_type, $filter_event_status,
+ $filter_event_filter_search, false, false);
if (empty($event)) {
$event = array();
@@ -6421,17 +6229,28 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0,
if ($only_data) {
$nevents = count($event);
for($i=$nevents-1; $i >= 0; $i--) {
- $e = $event[$i];
- //foreach ($event as $e) {
- $return_data[] = array(
- 'status' => $e['estado'],
- 'count' => $e['event_rep'],
- 'name' => $e['evento'],
- 'type' => $e["event_type"],
- 'criticity' => $e["criticity"],
- 'validated_by' => $e['id_usuario'],
- 'timestamp' => $e['timestamp_rep']
- );
+ $e = $event[$i];
+ if($show_summary_group){
+ $return_data[] = array(
+ 'status' => $e['estado'],
+ 'count' => $e['event_rep'],
+ 'name' => $e['evento'],
+ 'type' => $e["event_type"],
+ 'criticity' => $e["criticity"],
+ 'validated_by' => $e['id_usuario'],
+ 'timestamp' => $e['timestamp_rep']
+ );
+ }
+ else{
+ $return_data[] = array(
+ 'status' => $e['estado'],
+ 'name' => $e['evento'],
+ 'type' => $e["event_type"],
+ 'criticity' => $e["criticity"],
+ 'validated_by' => $e['id_usuario'],
+ 'timestamp' => $e['timestamp']
+ );
+ }
}
}
else {
@@ -8625,36 +8444,6 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
return $downtime_dates;
}
-/**
- * Gets a detailed reporting of groups's events.
- *
- * @param unknown_type $id_group Id of the group.
- * @param unknown_type $period Time period of the report.
- * @param unknown_type $date Date of the report.
- * @param unknown_type $return Whether to return or not.
- * @param unknown_type $html Whether to return HTML code or not.
- *
- * @return string Report of groups's events
- */
-function reporting_get_count_events_by_agent ($id_group, $period = 0,
- $date = 0,
- $filter_event_validated = false, $filter_event_critical = false,
- $filter_event_warning = false, $filter_event_no_validated = false,
- $filter_event_filter_search = null) {
-
- if (!is_numeric ($date)) {
- $date = strtotime ($date);
- }
- if (empty ($date)) {
- $date = get_system_time ();
- }
-
- return events_get_count_events_by_agent($id_group, $period, $date,
- $filter_event_validated, $filter_event_critical,
- $filter_event_warning, $filter_event_no_validated,
- $filter_event_filter_search);
-}
-
/**
* Get the maximum value of an agent module in a period of time.
*
diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php
index c9aacc65e8..a81eb7099d 100644
--- a/pandora_console/include/functions_reporting_html.php
+++ b/pandora_console/include/functions_reporting_html.php
@@ -130,17 +130,13 @@ function reporting_html_print_report($report, $mini = false) {
$table->data['description_row']['description'] = $item['description'];
- if($item['type']=='event_report_agent' || $item['type']=='event_report_module' || $item['type']=='event_report_group'){
-
+ if($item['type']=='event_report_agent' || $item['type']=='event_report_group'){
if($item['description'] != '' && $item['description'] != null){
$table->data['description_row']['description'] .= " - ";
}
-
$table->data['description_row']['description'] .= "Total events: ".$item["total_events"];
-
-
}
$table->colspan['description_row']['description'] = 3;
@@ -250,10 +246,6 @@ function reporting_html_print_report($report, $mini = false) {
case 'database_serialized':
reporting_html_database_serialized($table, $item);
break;
- case 'agent_detailed_event':
- case 'event_report_agent':
- reporting_html_event_report_agent($table, $item);
- break;
case 'group_report':
reporting_html_group_report($table, $item);
break;
@@ -269,6 +261,10 @@ function reporting_html_print_report($report, $mini = false) {
case 'inventory_changes':
reporting_html_inventory_changes($table, $item);
break;
+ case 'agent_detailed_event':
+ case 'event_report_agent':
+ reporting_html_event_report_agent($table, $item);
+ break;
case 'event_report_module':
reporting_html_event_report_module($table, $item);
break;
@@ -750,9 +746,8 @@ function reporting_html_top_n($table, $item) {
}
}
-function reporting_html_event_report_group($table, $item) {
+function reporting_html_event_report_group($table, $item, $pdf = 0) {
global $config;
-
if (!empty($item['failed'])) {
$table->colspan['events']['cell'] = 3;
$table->data['events']['cell'] = $item['failed'];
@@ -763,26 +758,49 @@ function reporting_html_event_report_group($table, $item) {
$table1->align = array();
$table1->align[0] = 'center';
- $table1->align[2] = 'center';
-
+ if($item['show_summary_group']){
+ $table1->align[3] = 'center';
+ }
+ else{
+ $table1->align[2] = 'center';
+ }
$table1->data = array ();
$table1->head = array ();
- $table1->head[0] = __('Status');
- $table1->head[1] = __('Name');
- $table1->head[2] = __('Type');
- $table1->head[3] = __('Agent');
- $table1->head[4] = __('Severity');
- $table1->head[5] = __('Val. by');
- $table1->head[6] = __('Timestamp');
-
+ if($item['show_summary_group']){
+ $table1->head[0] = __('Status');
+ $table1->head[1] = __('Count');
+ $table1->head[2] = __('Name');
+ $table1->head[3] = __('Type');
+ $table1->head[4] = __('Agent');
+ $table1->head[5] = __('Severity');
+ $table1->head[6] = __('Val. by');
+ $table1->head[7] = __('Timestamp');
+ }
+ else{
+ $table1->head[0] = __('Status');
+ $table1->head[1] = __('Name');
+ $table1->head[2] = __('Type');
+ $table1->head[3] = __('Agent');
+ $table1->head[4] = __('Severity');
+ $table1->head[5] = __('Val. by');
+ $table1->head[6] = __('Timestamp');
+ }
+
foreach ($item['data'] as $k => $event) {
//First pass along the class of this row
- $table1->cellclass[$k][1] = $table1->cellclass[$k][3] =
- $table1->cellclass[$k][4] = $table1->cellclass[$k][5] =
- $table1->cellclass[$k][6] =
- get_priority_class ($event["criticity"]);
-
+ if($item['show_summary_group']){
+ $table1->cellclass[$k][1] = $table1->cellclass[$k][2] =
+ $table1->cellclass[$k][4] = $table1->cellclass[$k][5] =
+ $table1->cellclass[$k][6] = $table1->cellclass[$k][7] =
+ get_priority_class ($event["criticity"]);
+ }
+ else{
+ $table1->cellclass[$k][1] = $table1->cellclass[$k][3] =
+ $table1->cellclass[$k][4] = $table1->cellclass[$k][5] =
+ $table1->cellclass[$k][6] =
+ get_priority_class ($event["criticity"]);
+ }
$data = array ();
// Colored box
@@ -805,6 +823,10 @@ function reporting_html_event_report_group($table, $item) {
"width" => 16,
"title" => $title_st,
"id" => 'status_img_' . $event["id_evento"]));
+
+ if($item['show_summary_group']){
+ $data[] = $event['event_rep'];
+ }
$data[] = ui_print_truncate_text(
io_safe_output($event['evento']),
@@ -825,17 +847,27 @@ function reporting_html_event_report_group($table, $item) {
$user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']);
$data[] = io_safe_output($user_name);
}
- $data[] = '
' .
- date($config['date_format'], $event['timestamp_rep']) .
- '';
+
+ if($item['show_summary_group']){
+ $data[] = '
' . date($config['date_format'], $event['timestamp_rep']) . '';
+ }
+ else{
+ $data[] = '
' . date($config['date_format'], strtotime($event['timestamp'])) . '';
+ }
+
array_push ($table1->data, $data);
}
- $table->colspan['events']['cell'] = 3;
- $table->data['events']['cell'] = html_print_table($table1, true);
-
-
-
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export = html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['events']['cell'] = 3;
+ $table->data['events']['cell'] = html_print_table($table1, true);
+ }
+
if (!empty($item['chart']['by_agent'])) {
$table1 = new stdClass();
$table1->width = '99%';
@@ -843,9 +875,16 @@ function reporting_html_event_report_group($table, $item) {
$table1->head[0] = __('Events by agent');
$table1->data[0][0] = $item['chart']['by_agent'];
- $table->colspan['chart_by_agent']['cell'] = 3;
- $table->cellstyle['chart_by_agent']['cell'] = 'text-align: center;';
- $table->data['chart_by_agent']['cell'] = html_print_table($table1, true);
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_by_agent']['cell'] = 3;
+ $table->cellstyle['chart_by_agent']['cell'] = 'text-align: center;';
+ $table->data['chart_by_agent']['cell'] = html_print_table($table1, true);
+ }
}
if (!empty($item['chart']['by_user_validator'])) {
@@ -855,9 +894,16 @@ function reporting_html_event_report_group($table, $item) {
$table1->head[0] = __('Events by user validator');
$table1->data[0][0] = $item['chart']['by_user_validator'];
- $table->colspan['chart_by_user_validator']['cell'] = 3;
- $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;';
- $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true);
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_by_user_validator']['cell'] = 3;
+ $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;';
+ $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true);
+ }
}
if (!empty($item['chart']['by_criticity'])) {
@@ -867,9 +913,16 @@ function reporting_html_event_report_group($table, $item) {
$table1->head[0] = __('Events by Severity');
$table1->data[0][0] = $item['chart']['by_criticity'];
- $table->colspan['chart_by_criticity']['cell'] = 3;
- $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;';
- $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true);
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_by_criticity']['cell'] = 3;
+ $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;';
+ $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true);
+ }
}
if (!empty($item['chart']['validated_vs_unvalidated'])) {
@@ -879,77 +932,196 @@ function reporting_html_event_report_group($table, $item) {
$table1->head[0] = __('Events validated vs unvalidated');
$table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
- $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3;
- $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;';
- $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true);
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3;
+ $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;';
+ $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true);
+ }
+ }
+
+ if($pdf){
+ return $pdf_export;
}
}
}
-function reporting_html_event_report_module($table, $item) {
-
+function reporting_html_event_report_module($table, $item, $pdf = 0) {
global $config;
-
+ $show_summary_group = $item['show_summary_group'];
if (!empty($item['failed'])) {
$table->colspan['events']['cell'] = 3;
$table->data['events']['cell'] = $item['failed'];
}
else {
- $table1 = new stdClass();
- $table1->width = '99%';
- $table1->data = array ();
- $table1->head = array ();
- $table1->head[0] = __('Status');
- $table1->head[1] = __('Event name');
- $table1->head[2] = __('Event type');
- $table1->head[3] = __('Severity');
- $table1->head[4] = __('Count');
- $table1->head[5] = __('Timestamp');
- $table1->style[0] = 'text-align: center;';
- $table1->style[4] = 'text-align: center;';
-
-
- foreach ($item['data'] as $i => $event) {
- $data = array();
-
- $table1->cellclass[$i][1] =
- $table1->cellclass[$i][2] =
- $table1->cellclass[$i][3] =
- $table1->cellclass[$i][4] =
- $table1->cellclass[$i][5] = get_priority_class($event["criticity"]);
-
- // Colored box
- switch ($event['estado']) {
- case 0:
- $img_st = "images/star.png";
- $title_st = __('New event');
- break;
- case 1:
- $img_st = "images/tick.png";
- $title_st = __('Event validated');
- break;
- case 2:
- $img_st = "images/hourglass.png";
- $title_st = __('Event in process');
- break;
+ foreach ($item['data'] as $item) {
+ $table1 = new stdClass();
+ $table1->width = '99%';
+ $table1->data = array ();
+ $table1->head = array ();
+ if($show_summary_group){
+ $table1->head[0] = __('Status');
+ $table1->head[1] = __('Event name');
+ $table1->head[2] = __('Event type');
+ $table1->head[3] = __('Severity');
+ $table1->head[4] = __('Count');
+ $table1->head[5] = __('Timestamp');
+ $table1->style[0] = 'text-align: center;';
+ }
+ else{
+ $table1->head[0] = __('Status');
+ $table1->head[1] = __('Event name');
+ $table1->head[2] = __('Event type');
+ $table1->head[3] = __('Severity');
+ $table1->head[4] = __('Timestamp');
+ $table1->style[0] = 'text-align: center;';
+ }
+ $table->data['tatal_events']['cell'] = "Total events: ".$item["total_events"];
+ if (is_array($item['data']) || is_object($item['data'])){
+ $item_data = array_reverse($item['data']);
}
- $data[0] = html_print_image ($img_st, true,
- array ("class" => "image_status",
- "width" => 16,
- "title" => $title_st,
- "id" => 'status_img_' . $event["id_evento"]));
- $data[1] = io_safe_output($event['evento']);
- $data[2] = $event['event_type'];
- $data[3] = get_priority_name ($event['criticity']);
- $data[4] = $event['event_rep'];
- $data[5] = date($config['date_format'], $event['timestamp_rep']);
+ if (is_array($item_data) || is_object($item_data)){
+ foreach ($item_data as $i => $event) {
+ $data = array();
+ if($show_summary_group){
+ $table1->cellclass[$i][1] = $table1->cellclass[$i][2] =
+ $table1->cellclass[$i][3] = $table1->cellclass[$i][4] =
+ $table1->cellclass[$i][5] = get_priority_class($event["criticity"]);
+ }
+ else{
+ $table1->cellclass[$i][1] = $table1->cellclass[$i][2] =
+ $table1->cellclass[$i][3] =
+ $table1->cellclass[$i][4] = get_priority_class($event["criticity"]);
+ }
+ // Colored box
+ switch ($event['estado']) {
+ case 0:
+ $img_st = "images/star.png";
+ $title_st = __('New event');
+ break;
+ case 1:
+ $img_st = "images/tick.png";
+ $title_st = __('Event validated');
+ break;
+ case 2:
+ $img_st = "images/hourglass.png";
+ $title_st = __('Event in process');
+ break;
+ }
+
+ $data[0] = html_print_image ($img_st, true,
+ array ("class" => "image_status",
+ "width" => 16,
+ "title" => $title_st,
+ "id" => 'status_img_' . $event["id_evento"]));
+ $data[1] = io_safe_output($event['evento']);
+ $data[2] = $event['event_type'];
+ $data[3] = get_priority_name ($event['criticity']);
+ if($show_summary_group){
+ $data[4] = $event['event_rep'];
+ $data[5] = date($config['date_format'], $event['timestamp_rep']);
+ }
+ else{
+ $data[4] = date($config['date_format'], strtotime($event['timestamp']));
+ }
+ $table1->data[] = $data;
+ }
+ }
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export = html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['events']['cell'] = 3;
+ $table->data['events']['cell'] = html_print_table($table1, true);
+ }
- $table1->data[] = $data;
+ if (!empty($item['chart']['by_agent'])) {
+ $table1 = new stdClass();
+ $table1->width = '99%';
+ $table1->head = array ();
+ $table1->head[0] = __('Events by agent');
+ $table1->data[0][0] = $item['chart']['by_agent'];
+
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_by_agent']['cell'] = 3;
+ $table->cellstyle['chart_by_agent']['cell'] = 'text-align: center;';
+ $table->data['chart_by_agent']['cell'] = html_print_table($table1, true);
+ }
+ }
+
+ if (!empty($item['chart']['by_user_validator'])) {
+ $table1 = new stdClass();
+ $table1->width = '99%';
+ $table1->head = array ();
+ $table1->head[0] = __('Events by user validator');
+ $table1->data[0][0] = $item['chart']['by_user_validator'];
+
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_by_user_validator']['cell'] = 3;
+ $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;';
+ $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true);
+ }
+ }
+
+ if (!empty($item['chart']['by_criticity'])) {
+ $table1 = new stdClass();
+ $table1->width = '99%';
+ $table1->head = array ();
+ $table1->head[0] = __('Events by Severity');
+ $table1->data[0][0] = $item['chart']['by_criticity'];
+
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_by_criticity']['cell'] = 3;
+ $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;';
+ $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true);
+ }
+ }
+
+ if (!empty($item['chart']['validated_vs_unvalidated'])) {
+ $table1 = new stdClass();
+ $table1->width = '99%';
+ $table1->head = array ();
+ $table1->head[0] = __('Events validated vs unvalidated');
+ $table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
+
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3;
+ $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;';
+ $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true);
+ }
+ }
+
+ if($pdf){
+ return $pdf_export;
+ }
}
-
- $table->colspan['events']['cell'] = 3;
- $table->data['events']['cell'] = html_print_table($table1, true);
}
}
@@ -1366,12 +1538,10 @@ function reporting_html_group_report($table, $item) {
";
}
-function reporting_html_event_report_agent($table, $item) {
+function reporting_html_event_report_agent($table, $item, $pdf = 0) {
global $config;
-
$table1 = new stdClass();
$table1->width = '99%';
-
$table1->align = array();
$table1->align[0] = 'center';
$table1->align[1] = 'center';
@@ -1381,7 +1551,9 @@ function reporting_html_event_report_agent($table, $item) {
$table1->head = array ();
$table1->head[0] = __('Status');
- $table1->head[1] = __('Count');
+ if($item['show_summary_group']){
+ $table1->head[1] = __('Count');
+ }
$table1->head[2] = __('Name');
$table1->head[3] = __('Type');
$table1->head[4] = __('Severity');
@@ -1389,13 +1561,21 @@ function reporting_html_event_report_agent($table, $item) {
$table1->head[6] = __('Timestamp');
foreach ($item['data'] as $i => $event) {
- $table1->cellclass[$i][1] =
- $table1->cellclass[$i][2] =
- $table1->cellclass[$i][4] =
- $table1->cellclass[$i][5] =
- $table1->cellclass[$i][6] =
- get_priority_class ($event["criticity"]);
-
+ if($item['show_summary_group']){
+ $table1->cellclass[$i][1] =
+ $table1->cellclass[$i][2] =
+ $table1->cellclass[$i][4] =
+ $table1->cellclass[$i][5] =
+ $table1->cellclass[$i][6] =
+ get_priority_class ($event["criticity"]);
+ }
+ else{
+ $table1->cellclass[$i][1] =
+ $table1->cellclass[$i][3] =
+ $table1->cellclass[$i][4] =
+ $table1->cellclass[$i][5] =
+ get_priority_class ($event["criticity"]);
+ }
$data = array ();
// Colored box
switch ($event['status']) {
@@ -1417,8 +1597,10 @@ function reporting_html_event_report_agent($table, $item) {
"width" => 16,
"title" => $title_st));
- $data[] = $event['count'];
-
+ if($item['show_summary_group']){
+ $data[] = $event['count'];
+ }
+
$data[] = ui_print_truncate_text(
io_safe_output($event['name']),
140, false, true);
@@ -1433,14 +1615,25 @@ function reporting_html_event_report_agent($table, $item) {
$user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['validated_by']);
$data[] = io_safe_output($user_name);
}
- $data[] = '
' .
- date($config['date_format'], $event['timestamp']) . '';
+ if($item['show_summary_group']){
+ $data[] = '
' . date($config['date_format'], $event['timestamp']) . '';
+ }
+ else{
+ $data[] = '
' . date($config['date_format'], strtotime($event['timestamp'])) . '';
+ }
array_push ($table1->data, $data);
}
- $table->colspan['event_list']['cell'] = 3;
- $table->cellstyle['event_list']['cell'] = 'text-align: center;';
- $table->data['event_list']['cell'] = html_print_table($table1, true);
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export = html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['event_list']['cell'] = 3;
+ $table->cellstyle['event_list']['cell'] = 'text-align: center;';
+ $table->data['event_list']['cell'] = html_print_table($table1, true);
+ }
if (!empty($item['chart']['by_user_validator'])) {
$table1 = new stdClass();
@@ -1449,9 +1642,16 @@ function reporting_html_event_report_agent($table, $item) {
$table1->head[0] = __('Events validated by user');
$table1->data[0][0] = $item['chart']['by_user_validator'];
- $table->colspan['chart_by_user_validator']['cell'] = 3;
- $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;';
- $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true);
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_by_user_validator']['cell'] = 3;
+ $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;';
+ $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true);
+ }
}
if (!empty($item['chart']['by_criticity'])) {
@@ -1461,9 +1661,16 @@ function reporting_html_event_report_agent($table, $item) {
$table1->head[0] = __('Events by severity');
$table1->data[0][0] = $item['chart']['by_criticity'];
- $table->colspan['chart_by_criticity']['cell'] = 3;
- $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;';
- $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true);
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_by_criticity']['cell'] = 3;
+ $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;';
+ $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true);
+ }
}
if (!empty($item['chart']['validated_vs_unvalidated'])) {
@@ -1473,9 +1680,20 @@ function reporting_html_event_report_agent($table, $item) {
$table1->head[0] = __('Amount events validated');
$table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
- $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3;
- $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;';
- $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true);
+ if($pdf){
+ $table1->class = 'table-beauty';
+ $pdf_export .= html_print_table($table1, true);
+ $pdf_export .= '
';
+ }
+ else{
+ $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3;
+ $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;';
+ $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true);
+ }
+ }
+
+ if($pdf){
+ return $pdf_export;
}
}
diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php
index 5ee628472b..a32223abe7 100755
--- a/pandora_console/include/functions_visual_map.php
+++ b/pandora_console/include/functions_visual_map.php
@@ -2454,7 +2454,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true,
}
if (defined('METACONSOLE')) {
- echo "