2013-01-18 Sergio Martin <sergio.martin@artica.es>
* operation/events/events_rss.php operation/events/export_csv.php operation/events/events_list.php operation/events/events.php operation/events/events.build_query.php: Fixed tag filters in event view and other filter elements missed in the csv and rss tools. Merged from 4.0.3 Now the code of query conditions for events is common for all of the pages where is retrieved git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7505 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
157c526c29
commit
6d010b9470
|
@ -1,3 +1,16 @@
|
|||
2013-01-18 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* operation/events/events_rss.php
|
||||
operation/events/export_csv.php
|
||||
operation/events/events_list.php
|
||||
operation/events/events.php
|
||||
operation/events/events.build_query.php: Fixed tag filters in
|
||||
event view and other filter elements missed in the csv and rss
|
||||
tools. Merged from 4.0.3
|
||||
|
||||
Now the code of query conditions for events is common for
|
||||
all of the pages where is retrieved
|
||||
|
||||
2013-01-17 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||
|
||||
* include/functions_graph.php
|
||||
|
|
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
$groups = users_get_groups($id_user, 'ER');
|
||||
|
||||
//Group selection
|
||||
if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) {
|
||||
|
||||
if($meta) {
|
||||
// In metaconsole the group search is performed by name
|
||||
$group_name = groups_get_name ($ev_group);
|
||||
$sql_post = " AND group_name = '$group_name'";
|
||||
}
|
||||
else {
|
||||
//If a group is selected and it's in the groups allowed
|
||||
$sql_post = " AND id_grupo = $ev_group";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_user_admin ($id_user)) {
|
||||
//Do nothing if you're admin, you get full access
|
||||
$sql_post = "";
|
||||
}
|
||||
else {
|
||||
//Otherwise select all groups the user has rights to.
|
||||
$sql_post = " AND id_grupo IN (" .
|
||||
implode (",", array_keys ($groups)) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
// Skip system messages if user is not PM
|
||||
if (!check_acl ($id_user, 0, "PM")) {
|
||||
$sql_post .= " AND id_grupo != 0";
|
||||
}
|
||||
|
||||
switch ($status) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
$sql_post .= " AND estado = " . $status;
|
||||
break;
|
||||
case 3:
|
||||
$sql_post .= " AND (estado = 0 OR estado = 2)";
|
||||
break;
|
||||
}
|
||||
|
||||
if ($search != "") {
|
||||
$sql_post .= " AND evento LIKE '%" . io_safe_input($search) . "%'";
|
||||
}
|
||||
|
||||
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") {
|
||||
$sql_post .= " AND event_type LIKE '%$event_type%' ";
|
||||
}
|
||||
elseif ($event_type == "not_normal") {
|
||||
$sql_post .= " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' ";
|
||||
}
|
||||
elseif ($event_type != "all") {
|
||||
$sql_post .= " AND event_type = '" . $event_type."'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($severity != -1) {
|
||||
switch($severity) {
|
||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
||||
$sql_post .= " AND (criticity = " . EVENT_CRIT_WARNING . " OR
|
||||
criticity = " . EVENT_CRIT_CRITICAL . ")";
|
||||
break;
|
||||
case EVENT_CRIT_NOT_NORMAL:
|
||||
$sql_post .= " AND criticity != " . EVENT_CRIT_NORMAL;
|
||||
break;
|
||||
default:
|
||||
$sql_post .= " AND criticity = $severity";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// In metaconsole mode the agent search is performed by name
|
||||
if($meta) {
|
||||
if($text_agent != __('All')) {
|
||||
$sql_post .= " AND agent_name LIKE '%$text_agent%'";
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($id_agent) {
|
||||
case 0:
|
||||
break;
|
||||
case -1:
|
||||
// Agent doesnt exist. No results will returned
|
||||
$sql_post .= " AND 1 = 0";
|
||||
break;
|
||||
default:
|
||||
$sql_post .= " AND id_agente = " . $id_agent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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 * SECONDS_1HOUR);
|
||||
$sql_post .= " AND (utimestamp > " . $unixtime . ")";
|
||||
}
|
||||
|
||||
//Search by tag
|
||||
if (!empty($tag_with)) {
|
||||
$sql_post .= ' AND ( ';
|
||||
$first = true;
|
||||
foreach ($tag_with as $id_tag) {
|
||||
if ($first) $first = false;
|
||||
else $sql_post .= " OR ";
|
||||
$sql_post .= "tags LIKE '%" . tags_get_name($id_tag) . "%'";
|
||||
}
|
||||
$sql_post .= ' ) ';
|
||||
}
|
||||
if (!empty($tag_without)) {
|
||||
$sql_post .= ' AND ( ';
|
||||
$first = true;
|
||||
foreach ($tag_without as $id_tag) {
|
||||
if ($first) $first = false;
|
||||
else $sql_post .= " OR ";
|
||||
$sql_post .= "tags NOT LIKE '%" . tags_get_name($id_tag) . "%'";
|
||||
}
|
||||
$sql_post .= ' ) ';
|
||||
}
|
||||
|
||||
// Filter/Only alerts
|
||||
if (isset($filter_only_alert)) {
|
||||
if ($filter_only_alert == 0)
|
||||
$sql_post .= " AND event_type NOT LIKE '%alert%'";
|
||||
else if ($filter_only_alert == 1)
|
||||
$sql_post .= " AND event_type LIKE '%alert%'";
|
||||
}
|
||||
|
||||
// Tags ACLS
|
||||
if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) {
|
||||
$group_array = (array) $ev_group;
|
||||
}
|
||||
else {
|
||||
$group_array = array_keys($groups);
|
||||
}
|
||||
|
||||
$tags_acls_condition = tags_get_acl_tags($id_user, $group_array, 'ER', 'event_condition', 'AND');
|
||||
|
||||
$sql_post .= $tags_acls_condition;
|
||||
|
||||
// Metaconsole fitlers
|
||||
if($meta) {
|
||||
$enabled_nodes = db_get_all_rows_sql('SELECT id FROM tmetaconsole_setup WHERE disabled = 0');
|
||||
|
||||
if(empty($enabled_nodes)) {
|
||||
$sql_post .= ' AND 1 = 0';
|
||||
}
|
||||
else {
|
||||
$enabled_nodes_id = array();
|
||||
foreach($enabled_nodes as $en) {
|
||||
$enabled_nodes_id[] = $en['id'];
|
||||
}
|
||||
$sql_post .= ' AND server_id IN ('.implode(',',$enabled_nodes_id).')';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -169,12 +169,11 @@ if (is_ajax ()) {
|
|||
|
||||
|
||||
$offset = (int) get_parameter ("offset", 0);
|
||||
$ev_group = (int) get_parameter ("ev_group", 0); //0 = all
|
||||
$ev_group = (int) get_parameter ("ev_group", 0); //0 all
|
||||
$event_type = get_parameter ("event_type", ''); // 0 all
|
||||
$severity = (int) get_parameter ("severity", -1); // -1 all
|
||||
$status = (int) get_parameter ("status", 3); // -1 all, 0 only new, 1 only validated, 2 only in process, 3 only not validated,
|
||||
$id_agent = (int) get_parameter ("id_agent", 0);
|
||||
$id_event = (int) get_parameter ("id_event", -1);
|
||||
$pagination = (int) get_parameter ("pagination", $config["block_size"]);
|
||||
$event_view_hr = (int) get_parameter ("event_view_hr", $history ? 0 : $config["event_view_hr"]);
|
||||
$id_user_ack = get_parameter ("id_user_ack", 0);
|
||||
|
@ -188,22 +187,59 @@ $filter_id = (int) get_parameter('filter_id', 0);
|
|||
$id_name = (string) get_parameter('id_name', '');
|
||||
$id_group = (int) get_parameter('id_group', 0);
|
||||
|
||||
$text_agent = (string) get_parameter("text_agent", __("All"));
|
||||
|
||||
$tag_with_json = base64_decode(get_parameter("tag_with", '')) ;
|
||||
$tag_with_json_clean = io_safe_output($tag_with_json);
|
||||
$tag_with_base64 = base64_encode($tag_with_json_clean);
|
||||
$tag_with = json_decode($tag_with_json_clean, true);
|
||||
if (empty($tag_with)) $tag_with = array();
|
||||
$tag_with = array_diff($tag_with, array(0 => 0));
|
||||
|
||||
$tag_without_json = base64_decode(get_parameter("tag_without", ''));
|
||||
$tag_without_json_clean = io_safe_output($tag_without_json);
|
||||
$tag_without_base64 = base64_encode($tag_without_json_clean);
|
||||
$tag_without = json_decode($tag_without_json_clean, true);
|
||||
if (empty($tag_without)) $tag_without = array();
|
||||
$tag_without = array_diff($tag_without, array(0 => 0));
|
||||
|
||||
$search = io_safe_output(preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", rawurldecode (get_parameter ("search"))));
|
||||
|
||||
users_get_groups ($config["id_user"], "ER");
|
||||
|
||||
$ids = (array) get_parameter ("eventid", -1);
|
||||
|
||||
$url = "index.php?sec=eventos&sec2=operation/events/events&search=" .
|
||||
io_safe_input($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;
|
||||
$params = "search=" . rawurlencode(io_safe_input($search)) .
|
||||
"&event_type=" . $event_type .
|
||||
"&severity=" . $severity .
|
||||
"&status=" . $status .
|
||||
"&ev_group=" . $ev_group .
|
||||
"&refr=" . $config["refr"] .
|
||||
"&id_agent=" . $id_agent .
|
||||
"&pagination=" . $pagination .
|
||||
"&group_rep=" . $group_rep .
|
||||
"&event_view_hr=" . $event_view_hr .
|
||||
"&id_user_ack=" . $id_user_ack .
|
||||
"&tag_with=". $tag_with_base64 .
|
||||
"&tag_without=" . $tag_without_base64 .
|
||||
"&filter_only_alert" . $filter_only_alert .
|
||||
"&offset=" . $offset .
|
||||
"&toogle_filter=no" .
|
||||
"&filter_id=" . $filter_id .
|
||||
"&id_name=" . $id_name .
|
||||
"&id_group=" . $id_group .
|
||||
"&history=" . (int)$history .
|
||||
"&section=" . $section .
|
||||
"&pure=" . $config["pure"];
|
||||
|
||||
if($meta) {
|
||||
$params .= "&text_agent=" . $text_agent;
|
||||
}
|
||||
|
||||
$url = "index.php?sec=eventos&sec2=operation/events/events&" . $params;
|
||||
|
||||
// Header
|
||||
if ($config["pure"] == 0 || defined ('METACONSOLE')) {
|
||||
if ($config["pure"] == 0 || $meta) {
|
||||
$pss = get_user_info($config['id_user']);
|
||||
$hashup = md5($config['id_user'] . $pss['password']);
|
||||
|
||||
|
@ -224,8 +260,7 @@ if ($config["pure"] == 0 || defined ('METACONSOLE')) {
|
|||
|
||||
// RSS
|
||||
$rss['active'] = false;
|
||||
$rss['text'] = '<a href="operation/events/events_rss.php?user=' . $config['id_user'] . '&hashup=' . $hashup .
|
||||
'&text_agent=' . $text_agent . '&ev_group='.$ev_group.'&event_type='.$event_type.'&search='.io_safe_input($search).'&severity='.$severity.'&status='.$status.'&event_view_hr='.$event_view_hr.'&id_agent='.$id_agent.'">' .
|
||||
$rss['text'] = '<a href="operation/events/events_rss.php?user=' . $config['id_user'] . '&hashup=' . $hashup . '&'.$params.'">' .
|
||||
html_print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .'</a>';
|
||||
|
||||
// Marquee
|
||||
|
@ -235,8 +270,7 @@ if ($config["pure"] == 0 || defined ('METACONSOLE')) {
|
|||
|
||||
// CSV
|
||||
$csv['active'] = false;
|
||||
$csv['text'] = '<a href="operation/events/export_csv.php?ev_group=' . $ev_group .
|
||||
'&text_agent=' . $text_agent . '&event_type='.$event_type.'&search='.io_safe_input($search).'&severity='.$severity.'&status='.$status.'&event_view_hr='.$event_view_hr.'&id_agent='.$id_agent.'">' .
|
||||
$csv['text'] = '<a href="operation/events/export_csv.php?' . $params . '">' .
|
||||
html_print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .'</a>';
|
||||
|
||||
// Sound events
|
||||
|
@ -800,4 +834,4 @@ $(document).ready( function() {
|
|||
}
|
||||
?>
|
||||
/* ]]> */
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -36,11 +36,6 @@ if (! check_acl ($config["id_user"], 0, "ER")) {
|
|||
return;
|
||||
}
|
||||
|
||||
$meta = false;
|
||||
if(enterprise_installed() && defined("METACONSOLE")) {
|
||||
$meta = true;
|
||||
}
|
||||
|
||||
if (is_ajax()) {
|
||||
$get_filter_values = get_parameter('get_filter_values', 0);
|
||||
$save_event_filter = get_parameter('save_event_filter', 0);
|
||||
|
@ -135,196 +130,21 @@ $tags = tags_get_user_tags($config['id_user'], 'ER');
|
|||
echo "<div id='show_filter_error'>";
|
||||
echo "</div>";
|
||||
|
||||
$tag_with_json = io_safe_output(get_parameter("tag_with"));
|
||||
$tag_with = json_decode($tag_with_json, true);
|
||||
if (empty($tag_with)) $tag_with = array();
|
||||
$tag_without_json = io_safe_output(get_parameter("tag_without"));
|
||||
$tag_without = json_decode($tag_without_json, true);
|
||||
if (empty($tag_without)) $tag_without = array();
|
||||
|
||||
$text_agent = (string) get_parameter("text_agent", __("All"));
|
||||
|
||||
if ($id_agent == 0 && $text_agent != __('All')) {
|
||||
$id_agent = -1;
|
||||
}
|
||||
|
||||
$groups = users_get_groups($config['id_user'], 'ER');
|
||||
/////////////////////////////////////////////
|
||||
// Build the condition of the events query
|
||||
|
||||
//Group selection
|
||||
if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) {
|
||||
if($meta) {
|
||||
// In metaconsole the group search is performed by name
|
||||
$group_name = groups_get_name ($ev_group);
|
||||
$sql_post = " AND group_name = '$group_name'";
|
||||
}
|
||||
else {
|
||||
//If a group is selected and it's in the groups allowed
|
||||
$sql_post = " AND id_grupo = $ev_group";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_user_admin ($config["id_user"])) {
|
||||
//Do nothing if you're admin, you get full access
|
||||
$sql_post = "";
|
||||
}
|
||||
else {
|
||||
//Otherwise select all groups the user has rights to.
|
||||
$sql_post = " AND id_grupo IN (" .
|
||||
implode (",", array_keys ($groups)) . ")";
|
||||
}
|
||||
}
|
||||
$sql_post = "";
|
||||
|
||||
// Skip system messages if user is not PM
|
||||
if (!check_acl ($config["id_user"], 0, "PM")) {
|
||||
$sql_post .= " AND id_grupo != 0";
|
||||
}
|
||||
$id_user = $config['id_user'];
|
||||
|
||||
switch ($status) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
$sql_post .= " AND estado = " . $status;
|
||||
break;
|
||||
case 3:
|
||||
$sql_post .= " AND (estado = 0 OR estado = 2)";
|
||||
break;
|
||||
}
|
||||
require('events.build_query.php');
|
||||
|
||||
if ($search != "") {
|
||||
$sql_post .= " AND evento LIKE '%" . io_safe_input($search) . "%'";
|
||||
}
|
||||
|
||||
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") {
|
||||
$sql_post .= " AND event_type LIKE '%$event_type%' ";
|
||||
}
|
||||
elseif ($event_type == "not_normal") {
|
||||
$sql_post .= " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' ";
|
||||
}
|
||||
else {
|
||||
$sql_post .= " AND event_type = '" . $event_type."'";
|
||||
}
|
||||
|
||||
}
|
||||
if ($severity != -1) {
|
||||
switch($severity) {
|
||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
||||
$sql_post .= " AND (criticity = " . EVENT_CRIT_WARNING . " OR
|
||||
criticity = " . EVENT_CRIT_CRITICAL . ")";
|
||||
break;
|
||||
case EVENT_CRIT_NOT_NORMAL:
|
||||
$sql_post .= " AND criticity != " . EVENT_CRIT_NORMAL;
|
||||
break;
|
||||
default:
|
||||
$sql_post .= " AND criticity = $severity";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// In metaconsole mode the agent search is performed by name
|
||||
if($meta) {
|
||||
if($text_agent != __('All')) {
|
||||
$sql_post .= " AND agent_name LIKE '%$text_agent%'";
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($id_agent) {
|
||||
case 0:
|
||||
break;
|
||||
case -1:
|
||||
// Agent doesnt exist. No results will returned
|
||||
$sql_post .= " AND 1 = 0";
|
||||
break;
|
||||
default:
|
||||
$sql_post .= " AND id_agente = " . $id_agent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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 * SECONDS_1HOUR);
|
||||
$sql_post .= " AND (utimestamp > " . $unixtime . ")";
|
||||
}
|
||||
|
||||
//Search by tag
|
||||
if (!empty($tag_with)) {
|
||||
$sql_post .= ' AND ( ';
|
||||
$first = true;
|
||||
foreach ($tag_with as $id_tag) {
|
||||
if ($first) $first = false;
|
||||
else $sql_post .= " OR ";
|
||||
$sql_post .= "tags LIKE '%" . tags_get_name($id_tag) . "%'";
|
||||
}
|
||||
$sql_post .= ' ) ';
|
||||
}
|
||||
if (!empty($tag_without)) {
|
||||
$sql_post .= ' AND ( ';
|
||||
$first = true;
|
||||
foreach ($tag_without as $id_tag) {
|
||||
if ($first) $first = false;
|
||||
else $sql_post .= " OR ";
|
||||
$sql_post .= "tags NOT LIKE '%" . tags_get_name($id_tag) . "%'";
|
||||
}
|
||||
$sql_post .= ' ) ';
|
||||
}
|
||||
|
||||
// Filter/Only alerts
|
||||
if (isset($filter_only_alert)) {
|
||||
if ($filter_only_alert == 0)
|
||||
$sql_post .= " AND event_type NOT LIKE '%alert%'";
|
||||
else if ($filter_only_alert == 1)
|
||||
$sql_post .= " AND event_type LIKE '%alert%'";
|
||||
}
|
||||
|
||||
// Tags ACLS
|
||||
if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) {
|
||||
$group_array = (array) $ev_group;
|
||||
}
|
||||
else {
|
||||
$group_array = array_keys($groups);
|
||||
}
|
||||
|
||||
$tags_acls_condition = tags_get_acl_tags($config['id_user'], $group_array, 'ER', 'event_condition', 'AND');
|
||||
|
||||
$sql_post .= $tags_acls_condition;
|
||||
|
||||
$url = "index.php?sec=eventos&sec2=operation/events/events&search=" .
|
||||
rawurlencode(io_safe_input($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 .
|
||||
"&tag_with=" . $tag_with .
|
||||
"&tag_without=" . $tag_without .
|
||||
"&filter_only_alert=" . $filter_only_alert .
|
||||
"&offset=" . $offset .
|
||||
"&toogle_filter=no" .
|
||||
"&filter_id=" . $filter_id .
|
||||
"&id_name=" . $id_name .
|
||||
"&id_group=" . $id_group .
|
||||
"&history=" . (int)$history .
|
||||
"&section=" . $section;
|
||||
|
||||
if($meta) {
|
||||
$url .= "&text_agent=" . $text_agent;
|
||||
}
|
||||
// Now $sql_post have all the where condition
|
||||
/////////////////////////////////////////////
|
||||
|
||||
echo "<br>";
|
||||
//Link to toggle filter
|
||||
|
@ -450,10 +270,6 @@ html_print_select ($repeated_sel, "group_rep", $group_rep, '');
|
|||
echo "</td></tr>";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td colspan='2'>" . __('Events with following tags') . "</td>";
|
||||
echo "<td colspan='2'>" . __('Events without following tags') . "</td>";
|
||||
|
@ -506,7 +322,7 @@ echo "<td valign='top'>";
|
|||
html_print_select ($tag_with_temp, 'tag_with_temp', array(), '', '',
|
||||
0, false, true,
|
||||
true, '', false, "width: 120px; height: 50px;");
|
||||
html_print_input_hidden('tag_with', json_encode($tag_with));
|
||||
html_print_input_hidden('tag_with', $tag_with_base64);
|
||||
echo "</td>";
|
||||
echo "<td valign='top'>";
|
||||
html_print_button(__('Remove'), 'remove_whith', $remove_with_tag_disabled,
|
||||
|
@ -516,7 +332,7 @@ echo "<td valign='top'>";
|
|||
html_print_select ($tag_without_temp, 'tag_without_temp', array(), '',
|
||||
'', 0, false, true,
|
||||
true, '', false, "width: 120px; height: 50px;");
|
||||
html_print_input_hidden('tag_without', json_encode($tag_without));
|
||||
html_print_input_hidden('tag_without', $tag_without_base64);
|
||||
echo "</td>";
|
||||
echo "<td valign='top'>";
|
||||
html_print_button(__('Remove'), 'remove_whithout', $remove_without_tag_disabled,
|
||||
|
@ -524,11 +340,6 @@ html_print_button(__('Remove'), 'remove_whithout', $remove_without_tag_disabled,
|
|||
echo "</td>";
|
||||
echo "</tr>";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "<tr>";
|
||||
|
||||
echo "<td>";
|
||||
|
@ -589,32 +400,7 @@ echo '</div>';
|
|||
echo '<div id="steps_clean"> </div>';
|
||||
echo '</div>';
|
||||
|
||||
// Choose the table where search if metaconsole or not
|
||||
if($meta) {
|
||||
if($history) {
|
||||
$event_table = 'tmetaconsole_event_history';
|
||||
}
|
||||
else {
|
||||
$event_table = 'tmetaconsole_event';
|
||||
}
|
||||
|
||||
// Show only the events of enabled nodes
|
||||
$enabled_nodes = db_get_all_rows_sql('SELECT id FROM tmetaconsole_setup WHERE disabled = 0');
|
||||
|
||||
if(empty($enabled_nodes)) {
|
||||
$sql_post .= ' AND 1 = 0';
|
||||
}
|
||||
else {
|
||||
$enabled_nodes_id = array();
|
||||
foreach($enabled_nodes as $en) {
|
||||
$enabled_nodes_id[] = $en['id'];
|
||||
}
|
||||
$sql_post .= ' AND server_id IN ('.implode(',',$enabled_nodes_id).')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$event_table = 'tevento';
|
||||
}
|
||||
$event_table = events_get_events_table($meta, $history);
|
||||
|
||||
if ($group_rep == 0) {
|
||||
switch ($config["dbtype"]) {
|
||||
|
@ -1109,7 +895,7 @@ foreach ($result as $event) {
|
|||
echo '<div id="events_list">';
|
||||
if (!empty ($table->data)) {
|
||||
echo '<div style="clear:both"></div>';
|
||||
ui_pagination ($total_events, $url."&pure=".$config["pure"], $offset, $pagination);
|
||||
ui_pagination ($total_events, $url, $offset, $pagination);
|
||||
|
||||
echo '<form method="post" id="form_events" action="'.$url.'">';
|
||||
echo "<input type='hidden' name='delete' id='hidden_delete_events' value='0' />";
|
||||
|
@ -1584,7 +1370,7 @@ function replace_hidden_tags(what_button) {
|
|||
value_store.push(val);
|
||||
});
|
||||
|
||||
$(id_hidden).val(jQuery.toJSON(value_store));
|
||||
$(id_hidden).val(Base64.encode(jQuery.toJSON(value_store)));
|
||||
}
|
||||
|
||||
function reorder_tags_inputs() {
|
||||
|
|
|
@ -19,9 +19,10 @@ require_once "../../include/config.php";
|
|||
require_once "../../include/functions.php";
|
||||
require_once "../../include/functions_db.php";
|
||||
require_once "../../include/functions_api.php";
|
||||
require_once("../../include/functions_agents.php");
|
||||
|
||||
ini_set ('display_errors', 0); //Don't display other errors, messes up XML
|
||||
require_once "../../include/functions_agents.php";
|
||||
require_once "../../include/functions_users.php";
|
||||
require_once "../../include/functions_tags.php";
|
||||
require_once "../../include/functions_groups.php";
|
||||
|
||||
$ipOrigin = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
|
@ -44,8 +45,6 @@ if ($hashup != $hashup2) {
|
|||
header("Content-Type: application/xml; charset=UTF-8"); //Send header before starting to output
|
||||
|
||||
function rss_error_handler ($errno, $errstr, $errfile, $errline) {
|
||||
global $config;
|
||||
|
||||
$url = ui_get_full_url(false);
|
||||
$selfurl = ui_get_full_url('?' . $_SERVER['QUERY_STRING'], false, true);
|
||||
|
||||
|
@ -66,140 +65,51 @@ function rss_error_handler ($errno, $errstr, $errfile, $errline) {
|
|||
set_error_handler ('rss_error_handler', E_ALL); //Errors output as RSS
|
||||
|
||||
$ev_group = get_parameter ("ev_group", 0); // group
|
||||
$search = get_parameter ("search", ""); // free 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);
|
||||
|
||||
$id_event = (int) get_parameter ("id_event", -1); //This will allow to select only 1 event (eg. RSS)
|
||||
$event_view_hr = (int) get_parameter ("event_view_hr", 0);
|
||||
$id_user_ack = get_parameter ("id_user_ack", 0);
|
||||
$search = io_safe_output(preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", rawurldecode (get_parameter ("search"))));
|
||||
$text_agent = (string) get_parameter("text_agent", __("All"));
|
||||
|
||||
$tag_with_json = base64_decode(get_parameter("tag_with", '')) ;
|
||||
$tag_with_json_clean = io_safe_output($tag_with_json);
|
||||
$tag_with_base64 = base64_encode($tag_with_json_clean);
|
||||
$tag_with = json_decode($tag_with_json_clean, true);
|
||||
if (empty($tag_with)) $tag_with = array();
|
||||
$tag_with = array_diff($tag_with, array(0 => 0));
|
||||
|
||||
$tag_without_json = base64_decode(get_parameter("tag_without", ''));
|
||||
$tag_without_json_clean = io_safe_output($tag_without_json);
|
||||
$tag_without_base64 = base64_encode($tag_without_json_clean);
|
||||
$tag_without = json_decode($tag_without_json_clean, true);
|
||||
if (empty($tag_without)) $tag_without = array();
|
||||
$tag_without = array_diff($tag_without, array(0 => 0));
|
||||
|
||||
$filter_only_alert = (int)get_parameter('filter_only_alert', -1);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Build the condition of the events query
|
||||
$sql_post = "";
|
||||
$meta = false;
|
||||
|
||||
if ($event_view_hr > 0) {
|
||||
$unixtime = (int) (get_system_time () - ($event_view_hr * SECONDS_1HOUR)); //Put hours in seconds
|
||||
$sql_post .= " AND tevento.utimestamp > ".$unixtime;
|
||||
}
|
||||
if ($ev_group > 1)
|
||||
$sql_post .= " AND tevento.id_grupo = $ev_group";
|
||||
$id_user = $user;
|
||||
|
||||
|
||||
switch($status) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
$sql_post .= " AND tevento.estado = ".$status;
|
||||
break;
|
||||
case 3:
|
||||
$sql_post .= " AND (tevento.estado = 0 OR tevento.estado = 2)";
|
||||
break;
|
||||
}
|
||||
require('events.build_query.php');
|
||||
|
||||
// Now $sql_post have all the where condition
|
||||
/////////////////////////////////////////////
|
||||
|
||||
if ($search != "")
|
||||
$sql_post .= " AND tevento.evento LIKE '%$search%'";
|
||||
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") {
|
||||
$sql_post .= " AND tevento.event_type LIKE '%$event_type%' ";
|
||||
}
|
||||
elseif ($event_type == "not_normal") {
|
||||
$sql_post .= " AND tevento.event_type LIKE '%warning%' OR tevento.event_type LIKE '%critical%' OR tevento.event_type LIKE '%unknown%' ";
|
||||
}
|
||||
else
|
||||
$sql_post .= " AND tevento.event_type = '".$event_type."'";
|
||||
}
|
||||
if ($severity != -1)
|
||||
$sql_post .= " AND tevento.criticity >= ".$severity;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
ORDER BY utimestamp DESC";
|
||||
|
||||
|
||||
if ($id_agent == -2) {
|
||||
$text_agent = (string) get_parameter("text_agent", __("All"));
|
||||
|
||||
switch ($text_agent)
|
||||
{
|
||||
case __('All'):
|
||||
$id_agent = -1;
|
||||
break;
|
||||
case __('Server'):
|
||||
$id_agent = 0;
|
||||
break;
|
||||
default:
|
||||
$id_agent = agents_get_agent_id($text_agent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($id_agent)
|
||||
{
|
||||
case -1:
|
||||
$text_agent = __('All');
|
||||
break;
|
||||
case 0:
|
||||
$text_agent = __('Server');
|
||||
break;
|
||||
default:
|
||||
$text_agent = agents_get_name($id_agent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($id_agent != -1)
|
||||
$sql_post .= " AND tevento.id_agente = ".$id_agent;
|
||||
if ($id_event != -1)
|
||||
$sql_post .= " AND id_evento = ".$id_event;
|
||||
|
||||
// Avoid to show system events to not administrators
|
||||
if(!check_acl($user, 0, "PM"))
|
||||
$sql_post .= " AND tevento.event_type <> 'system'";
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql="SELECT tevento.id_evento AS event_id,
|
||||
tevento.id_agente AS id_agent,
|
||||
tevento.id_usuario AS validated_by,
|
||||
tevento.id_grupo AS id_group,
|
||||
tevento.estado AS validated,
|
||||
tevento.evento AS event_descr,
|
||||
tevento.utimestamp AS unix_timestamp,
|
||||
tevento.event_type AS event_type
|
||||
FROM tevento
|
||||
WHERE 1 = 1" . $sql_post . "
|
||||
ORDER BY utimestamp DESC LIMIT 0 , 30";
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql="SELECT tevento.id_evento AS event_id,
|
||||
tevento.id_agente AS id_agent,
|
||||
tevento.id_usuario AS validated_by,
|
||||
tevento.id_grupo AS id_group,
|
||||
tevento.estado AS validated,
|
||||
tevento.evento AS event_descr,
|
||||
tevento.utimestamp AS unix_timestamp,
|
||||
tevento.event_type AS event_type
|
||||
FROM tevento
|
||||
WHERE 1 = 1" . $sql_post . "
|
||||
ORDER BY utimestamp DESC LIMIT 30 OFFSET 0";
|
||||
break;
|
||||
case "oracle":
|
||||
$sql="SELECT tevento.id_evento AS event_id,
|
||||
tevento.id_agente AS id_agent,
|
||||
tevento.id_usuario AS validated_by,
|
||||
tevento.id_grupo AS id_group,
|
||||
tevento.estado AS validated,
|
||||
tevento.evento AS event_descr,
|
||||
tevento.utimestamp AS unix_timestamp,
|
||||
tevento.event_type AS event_type
|
||||
FROM tevento
|
||||
WHERE (1 = 1" . $sql_post . ") AND rownum <= 30
|
||||
ORDER BY utimestamp DESC";
|
||||
break;
|
||||
}
|
||||
|
||||
$result= db_get_all_rows_sql ($sql);
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
|
||||
$url = ui_get_full_url(false);
|
||||
$selfurl = ui_get_full_url('?' . $_SERVER['QUERY_STRING'], false, true);
|
||||
|
@ -208,7 +118,7 @@ if (empty ($result)) {
|
|||
$lastbuild = 0; //Last build in 1970
|
||||
}
|
||||
else {
|
||||
$lastbuild = (int) $result[0]['unix_timestamp'];
|
||||
$lastbuild = (int) $result[0]['utimestamp'];
|
||||
}
|
||||
|
||||
$rss_feed = '<?xml version="1.0" encoding="utf-8" ?>' . "\n"; // ' <?php ' -- Fixes highlighters thinking that the closing tag is PHP
|
||||
|
@ -228,15 +138,15 @@ if (empty ($result)) {
|
|||
}
|
||||
|
||||
foreach ($result as $row) {
|
||||
if (!check_acl($user, $row["id_group"], "ER")) {
|
||||
if (!check_acl($user, $row["id_grupo"], "ER")) {
|
||||
continue;
|
||||
}
|
||||
if ($row["event_type"] == "system") {
|
||||
$agent_name = __('System');
|
||||
}
|
||||
elseif ($row["id_agent"] > 0) {
|
||||
elseif ($row["id_agente"] > 0) {
|
||||
// Agent name
|
||||
$agent_name = agents_get_name ($row["id_agent"]);
|
||||
$agent_name = agents_get_name ($row["id_agente"]);
|
||||
}
|
||||
else {
|
||||
$agent_name = __('Alert').__('SNMP');
|
||||
|
@ -244,20 +154,20 @@ foreach ($result as $row) {
|
|||
|
||||
//This is mandatory
|
||||
$rss_feed .= '<item><guid>';
|
||||
$rss_feed .= io_safe_input($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row['event_id']);
|
||||
$rss_feed .= io_safe_input($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row['id_evento']);
|
||||
$rss_feed .= '</guid><title>';
|
||||
$rss_feed .= $agent_name;
|
||||
$rss_feed .= '</title><description>';
|
||||
$rss_feed .= $row['event_descr'];
|
||||
if($row['validated'] == 1) {
|
||||
$rss_feed .= io_safe_input('<br /><br />'.'Validated by ' . $row['validated_by']);
|
||||
$rss_feed .= $row['evento'];
|
||||
if($row['estado'] == 1) {
|
||||
$rss_feed .= io_safe_input('<br /><br />'.'Validated by ' . $row['id_usuario']);
|
||||
}
|
||||
$rss_feed .= '</description><link>';
|
||||
$rss_feed .= io_safe_input($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row["event_id"]);
|
||||
$rss_feed .= io_safe_input($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row["id_evento"]);
|
||||
$rss_feed .= '</link>';
|
||||
|
||||
//The rest is optional
|
||||
$rss_feed .= '<pubDate>' . date(DATE_RFC822, $row['unix_timestamp']) . '</pubDate>';
|
||||
$rss_feed .= '<pubDate>' . date(DATE_RFC822, $row['utimestamp']) . '</pubDate>';
|
||||
|
||||
//This is mandatory again
|
||||
$rss_feed .= '</item>' . "\n";
|
||||
|
|
|
@ -33,9 +33,15 @@ if (! check_acl ($config["id_user"], 0, "ER") && ! check_acl ($config["id_user"]
|
|||
|
||||
global $config;
|
||||
|
||||
// loading l10n tables, because of being invoked not through index.php.
|
||||
$l10n = NULL;
|
||||
if (file_exists ($config['homedir'].'/include/languages/'.$user_language.'.mo')) {
|
||||
$l10n = new gettext_reader (new CachedFileReader ($config['homedir'].'/include/languages/'.$user_language.'.mo'));
|
||||
$l10n->load_tables();
|
||||
}
|
||||
|
||||
$offset = (int) get_parameter ("offset");
|
||||
$ev_group = (int) get_parameter ("ev_group"); // group
|
||||
//$search = (int) get_parameter ("search"); // free search
|
||||
$event_type = (string) get_parameter ("event_type", "all"); // 0 all
|
||||
$severity = (int) get_parameter ("severity", -1); // -1 all
|
||||
$status = (int) get_parameter ("status", -1); // -1 all, 0 only red, 1 only green
|
||||
|
@ -46,108 +52,61 @@ $event_view_hr = (int) get_parameter ("event_view_hr", $config["event_view_hr"])
|
|||
$id_user_ack = get_parameter ("id_user_ack", 0);
|
||||
$search = io_safe_output(preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", rawurldecode (get_parameter ("search"))));
|
||||
$text_agent = (string)get_parameter('text_agent', __("All"));
|
||||
$tag = get_parameter("tag", "");
|
||||
|
||||
$filter = array ();
|
||||
if ($ev_group > 1)
|
||||
$filter['id_grupo'] = $ev_group;
|
||||
$tag_with_json = base64_decode(get_parameter("tag_with", '')) ;
|
||||
$tag_with_json_clean = io_safe_output($tag_with_json);
|
||||
$tag_with_base64 = base64_encode($tag_with_json_clean);
|
||||
$tag_with = json_decode($tag_with_json_clean, true);
|
||||
if (empty($tag_with)) $tag_with = array();
|
||||
$tag_with = array_diff($tag_with, array(0 => 0));
|
||||
|
||||
$filter_state = '';
|
||||
switch ($status) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
$filter_state = " AND estado = " . $status;
|
||||
break;
|
||||
case 3:
|
||||
$filter_state = " AND (estado = 0 OR estado = 2)";
|
||||
$tag_without_json = base64_decode(get_parameter("tag_without", ''));
|
||||
$tag_without_json_clean = io_safe_output($tag_without_json);
|
||||
$tag_without_base64 = base64_encode($tag_without_json_clean);
|
||||
$tag_without = json_decode($tag_without_json_clean, true);
|
||||
if (empty($tag_without)) $tag_without = array();
|
||||
$tag_without = array_diff($tag_without, array(0 => 0));
|
||||
|
||||
$filter_only_alert = (int)get_parameter('filter_only_alert', -1);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Build the condition of the events query
|
||||
|
||||
$sql_post = "";
|
||||
$meta = false;
|
||||
|
||||
$id_user = $config['id_user'];
|
||||
|
||||
require('events.build_query.php');
|
||||
|
||||
// Now $sql_post have all the where condition
|
||||
/////////////////////////////////////////////
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
case "oracle":
|
||||
$sql = "SELECT *
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post."
|
||||
ORDER BY utimestamp DESC";
|
||||
break;
|
||||
}
|
||||
if ($search != "")
|
||||
$filter[] = 'evento LIKE "%'.io_safe_input($search).'%"';
|
||||
if (($event_type != "all") OR ($event_type != 0))
|
||||
$filter['event_type'] = $event_type;
|
||||
if ($severity != -1)
|
||||
$filter[] = 'criticity >= '.$severity;
|
||||
|
||||
if ($id_agent == -2) {
|
||||
$text_agent = (string) get_parameter("text_agent", __("All"));
|
||||
|
||||
switch ($text_agent)
|
||||
{
|
||||
case __('All'):
|
||||
$id_agent = -1;
|
||||
break;
|
||||
case __('Server'):
|
||||
$id_agent = 0;
|
||||
break;
|
||||
default:
|
||||
$id_agent = agents_get_agent_id($text_agent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($id_agent)
|
||||
{
|
||||
case -1:
|
||||
$text_agent = __('All');
|
||||
break;
|
||||
case 0:
|
||||
$text_agent = __('Server');
|
||||
break;
|
||||
default:
|
||||
$text_agent = agents_get_name($id_agent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($id_agent != -1)
|
||||
$filter['id_agente'] = $id_agent;
|
||||
|
||||
if ($id_event != -1)
|
||||
$filter['id_evento'] = $id_event;
|
||||
|
||||
$timestamp_filter = '';
|
||||
if ($event_view_hr > 0) {
|
||||
$unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds
|
||||
$timestamp_filter = " AND (utimestamp > $unixtime OR estado = 2)";
|
||||
}
|
||||
|
||||
if ($id_user_ack != "0")
|
||||
$filter['id_usuario'] = $id_user_ack;
|
||||
|
||||
//Search by tag
|
||||
if ($tag != "") {
|
||||
$filter['tags'] = "%".io_safe_input($tag)."%";
|
||||
}
|
||||
|
||||
//$filter['order'] = 'timestamp DESC';
|
||||
$now = date ("Y-m-d");
|
||||
|
||||
// Show contentype header
|
||||
// Show contentype header
|
||||
Header ("Content-type: text/txt");
|
||||
header ('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.txt"');
|
||||
|
||||
echo "timestamp, agent, group, event, status, user, event_type, severity";
|
||||
echo chr (13);
|
||||
|
||||
$fields = array ('id_grupo', 'id_agente', 'evento', 'estado', 'id_usuario',
|
||||
'event_type', 'criticity', 'timestamp');
|
||||
|
||||
$sql = db_get_all_rows_filter('tevento', $filter, $fields, 'AND', true, true);
|
||||
|
||||
// If filter is empty and there are others filters not empty append "WHERE" clause
|
||||
if (empty($filter) and (!empty($filter_state) or !empty($timestamp_filter)))
|
||||
$sql .= ' WHERE 1=1 ';
|
||||
|
||||
$sql .= $filter_state . $timestamp_filter . ' ORDER BY timestamp DESC';
|
||||
|
||||
$new = true;
|
||||
while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) {
|
||||
$new = false;
|
||||
if (!check_acl($config["id_user"], $event["id_grupo"], "ER") ||
|
||||
(!check_acl($config["id_user"], 0, "PM") && $event["event_type"] == 'system'))
|
||||
(!check_acl($config["id_user"], 0, "PM") && $event["event_type"] == 'system'))
|
||||
continue;
|
||||
|
||||
echo $event["timestamp"];
|
||||
|
@ -167,4 +126,5 @@ while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) {
|
|||
echo $event["criticity"];
|
||||
echo chr (13);
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
|
|
Loading…
Reference in New Issue