2012-02-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* images/skin/skin_default/include/styles/menu.css
	 include/styles/menu.css: Added godmode events icon in menu.

	* include/functions_events.php: Added functions to support custom 
	event filters. 

	* pandoradb.sql
	 pandoradb.postgreSQL.sql
	 pandoradb.oracle.sql
	 extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql
	 extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql
	 extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: Added table 
	 tevent_filter.
      
	* operation/events/events_list.php
	 operation/events/events.php: Added event filters 'live' editor.

	* general/shortcut_bar.php: Fixed some bugs due to ACLs.
	
	* general/header.php: Removed trace.

	* godmode/menu.php: Added event godmode section.
	 
	* godmode/events/event_edit_filter.php
	 godmode/events/custom_events.php
	 godmode/events/events.php
	 godmode/events/event_filter.php: Added files: Entry point in event
	 godmode section, events filter editor and event custom fields view.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5517 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2012-02-08 13:04:18 +00:00
parent 08274f0d96
commit be7a82bf7c
19 changed files with 1333 additions and 45 deletions

View File

@ -1,3 +1,34 @@
2012-02-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* images/skin/skin_default/include/styles/menu.css
include/styles/menu.css: Added godmode events icon in menu.
* include/functions_events.php: Added functions to support custom
event filters.
* pandoradb.sql
pandoradb.postgreSQL.sql
pandoradb.oracle.sql
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: Added table
tevent_filter.
* operation/events/events_list.php
operation/events/events.php: Added event filters 'live' editor.
* general/shortcut_bar.php: Fixed some bugs due to ACLs.
* general/header.php: Removed trace.
* godmode/menu.php: Added event godmode section.
* godmode/events/event_edit_filter.php
godmode/events/custom_events.php
godmode/events/events.php
godmode/events/event_filter.php: Added files: Entry point in event
godmode section, events filter editor and event custom fields view.
2012-02-08 Vanessa Gil <vanessa.gil@artica.es>
* godmode/events/custom_events.php
* operation/events/events_list.php: Added criticity alert to event view.

View File

@ -125,3 +125,25 @@ ALTER TABLE `tnetwork_component` CHANGE COLUMN `post_process` `post_process` dou
-- Table `tgraph_source` Alter table to allow negative values in weight
-- -----------------------------------------------------
ALTER TABLE tgraph_source MODIFY weight FLOAT(5,3) NOT NULL DEFAULT '0.000';
-- -----------------------------------------------------
-- Table `tevent_filter`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tevent_filter` (
`id_filter` int(10) unsigned NOT NULL auto_increment,
`id_name` varchar(600) NOT NULL,
`id_group` int(10) NOT NULL default 0,
`event_type` text NOT NULL default '',
`severity` int(10) NOT NULL default -1,
`status` int(10) NOT NULL default -1,
`search` TEXT default '',
`text_agent` TEXT default '',
`pagination` int(10) NOT NULL default 25,
`event_view_hr` int(10) NOT NULL default 8,
`id_user_ack` TEXT,
`group_rep` int(10) NOT NULL default 0,
`tag` varchar(600) NOT NULL default '',
`filter_only_alert` int(10) NOT NULL default -1,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -122,3 +122,23 @@ ALTER TABLE talert_snmp add (_snmp_f5_ CLOB default '');
ALTER TABLE talert_snmp add (_snmp_f6_ CLOB default '');
ALTER TABLE talert_snmp add (trap_type NUMBER(10, 0) DEFAULT -1 NOT NULL);
ALTER TABLE talert_snmp add (single_value VARCHAR2(255) DEFAULT '');
-- -----------------------------------------------------
-- Table `tevent_filter`
-- -----------------------------------------------------
CREATE TABLE tevent_filter (
id_filter NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_name VARCHAR2(600) NOT NULL,
id_group NUMBER(10, 0) default 0 NOT NULL,
event_type CLOB default '' NOT NULL,
severity NUMBER(10, 0) default -1 NOT NULL,
status NUMBER(10, 0) default -1 NOT NULL,
search CLOB default '',
text_agent CLOB default '',
pagination NUMBER(10, 0) default 25 NOT NULL,
event_view_hr NUMBER(10, 0) default 8 NOT NULL,
id_user_ack CLOB,
group_rep NUMBER(10, 0) default 0 NOT NULL,
tag VARCHAR2(600) default '' NOT NULL,
filter_only_alert NUMBER(10, 0) default -1 NOT NULL
);

View File

@ -107,3 +107,23 @@ ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f5_" text DEFAULT '';
ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f6_" text DEFAULT '';
ALTER TABLE "talert_snmp" ADD COLUMN "trap_type" INTEGER NOT NULL DEFAULT '-1';
ALTER TABLE "talert_snmp" ADD COLUMN "single_value" varchar(255) DEFAULT '';
-- -----------------------------------------------------
-- Table `tevent_filter`
-- -----------------------------------------------------
CREATE TABLE "tevent_filter" (
"id_filter" SERIAL NOT NULL PRIMARY KEY,
"id_name" varchar(600) NOT NULL,
"id_group" INTEGER NOT NULL default 0,
"event_type" TEXT NOT NULL default '',
"severity" INTEGER NOT NULL default -1,
"status" INTEGER NOT NULL default -1,
"search" TEXT default '',
"text_agent" TEXT default '',
"pagination" INTEGER NOT NULL default 25,
"event_view_hr" INTEGER NOT NULL default 8,
"id_user_ack" TEXT,
"group_rep" INTEGER NOT NULL default 0,
"tag" varchar(600) NOT NULL default '',
"filter_only_alert" INTEGER NOT NULL default -1
);

View File

@ -208,7 +208,6 @@ $("#yougotalert").click(function () {
$("#agent_access").css("display", "none");
});
$("#ui_close_dialog_titlebar").click(function () {
alert("LOLOLO");
$("#agent_access").css("display","");
});

View File

@ -39,9 +39,9 @@
$own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
$own_groups = array_keys(users_get_groups($config['id_user'], "LM"));
$own_groups = array_keys(users_get_groups($config['id_user'], "IR"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "LM", false));
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
// Get events in the last 8 hours
$shortcut_events_update = events_get_group_events($own_groups, 28800, time());
@ -63,9 +63,9 @@
$own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
$own_groups = array_keys(users_get_groups($config['id_user'], "LM"));
$own_groups = array_keys(users_get_groups($config['id_user'], "IR"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "LM", false));
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
$sql = "SELECT count(*) total_incidents FROM tincidencia WHERE
id_grupo IN (".implode (",",array_keys ($own_groups)).") AND estado IN (0)
@ -104,7 +104,19 @@
}
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=120&filter=fired&free_search=&filter_button=Filter'>";
$own_info = get_user_info ($config['id_user']);
// If user is admin can see all groups
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")){
echo "<a href='index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=120&filter=fired&free_search=&filter_button=Filter'>";
}
else{
$own_groups = array_keys(users_get_groups($config['id_user'], "AR", false));
if (!empty($own_groups)){
$alerts_group = array_shift($own_groups);
echo "<a href='index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=120&filter=fired&free_search=&ag_group=$alerts_group&filter_button=Filter'>";
}
}
html_print_image("images/bell.png", false, array("title" => __("Alerts fired"), "style" => "margin-bottom: -5px;"));
echo "&nbsp;";
@ -112,9 +124,24 @@
$data_reporting = reporting_get_group_stats();
echo "<span id='shortcut_alerts_fired' style='font-size: 9pt; color:#696969; font-weight: bold;' title='" . __('Alerts fired') . "'>" . $data_reporting['monitor_alerts_fired'] . "</span>";
echo "</a>";
if (!empty($own_groups)){
echo "</a>";
}
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href='index.php?sec=eventos&sec2=operation/events/events&status=3&severity=4&event_view_hr=8&ev_group=0&group_rep=1&filter_only_alert=-1'>";
$own_info = get_user_info ($config['id_user']);
// If user is admin can see all groups
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")){
echo "<a href='index.php?sec=eventos&sec2=operation/events/events&status=3&severity=4&event_view_hr=8&ev_group=0&group_rep=1&filter_only_alert=-1'>";
}
else {
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
if (!empty($own_groups)){
$events_group = array_shift($own_groups);
echo "<a href='index.php?sec=eventos&sec2=operation/events/events&status=3&severity=4&event_view_hr=8&ev_group=0&group_rep=1&ev_group=$events_group&filter_only_alert=-1'>";
}
}
html_print_image("images/lightning_go.png", false, array("title" => __("Critical events"), "style" => "margin-bottom: -5px;"));
echo "&nbsp;";
@ -122,9 +149,9 @@
$own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
$own_groups = array_keys(users_get_groups($config['id_user'], "LM"));
$own_groups = array_keys(users_get_groups($config['id_user'], "IR"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "LM", false));
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
// Get events in the last 8 hours
$shortcut_events = events_get_group_events($own_groups, 28800, time());

View File

@ -25,8 +25,6 @@ if (! check_acl($config['id_user'], 0, "PM")) {
return;
}
// Header
ui_print_page_header (__('Custom events'), "", false, "", true);
$update = get_parameter('update_config', 0);
@ -105,7 +103,7 @@ $table->data[1][2] .= '<br><br><br><br>' . html_print_image('images/darrowleft.p
$table->data[1][3] = '<b>' . __('Fields selected') . '</b>';
$table->data[1][4] = html_print_select($result_selected, 'fields_selected[]', true, '', __('None'), '', true, true, false);
echo '<form id="custom_events" method="post" action="index.php?sec=gsetup&sec2=godmode/events/custom_events">';
echo '<form id="custom_events" method="post" action="index.php?sec=gsetup&sec2=godmode/events/events&section=fields">';
html_print_table($table);

View File

@ -0,0 +1,293 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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; 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.
global $config;
check_login ();
if (! check_acl ($config["id_user"], 0, "IR")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$id = (int) get_parameter ('id');
$update = (string)get_parameter('update', 0);
$create = (string)get_parameter('create', 0);
if ($id){
$permission = events_check_event_filter_group ($id);
if (!$permission) { // User doesn't have permissions to see this filter
require ("general/noaccess.php");
return;
}
}
$buttons = array(
'view' => array('active' => false,
'text' => '<a href="index.php?sec=geventos&sec2=operation/events/events">' .
html_print_image("images/zoom.png", true, array("title" => __('View events'))) . '</a>'),
'filter' => array('active' => true,
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&amp;section=filter">' .
html_print_image("images/lightning_go.png", true, array ("title" => __('Create filter'))) . '</a>'),
'fields' => array('active' => false,
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&amp;section=fields">' .
html_print_image("images/god6.png", true, array ("title" => __('Custom fields'))) . '</a>'),
);
ui_print_page_header (__("Manage events") . ' - ' . __('Filters'), "images/lightning_go.png", false, "", true, $buttons);
if ($id) {
$filter = events_get_event_filter ($id);
$id_group = $filter['id_group'];
$id_name = $filter['id_name'];
$event_type = $filter['event_type'];
$severity = $filter['severity'];
$status = $filter['status'];
$search = $filter['search'];
$text_agent = $filter['text_agent'];
$pagination = $filter['pagination'];
$event_view_hr = $filter['event_view_hr'];
$id_user_ack = $filter['id_user_ack'];
$group_rep = $filter['group_rep'];
$tag = $filter['tag'];
$filter_only_alert = $filter['filter_only_alert'];
} else {
$id_group = '';
$id_name = '';
$event_type = '';
$severity = '';
$status = '';
$search = '';
$text_agent = __('All');
$pagination = '';
$event_view_hr = '';
$id_user_ack = '';
$group_rep = '';
$tag = '';
$filter_only_alert = '';
}
if ($update) {
$id_group = (string) get_parameter ('id_group');
$id_name = (string) get_parameter ('id_name');
$event_type = get_parameter('event_type', '');
$severity = get_parameter('severity', '');
$status = get_parameter('status', '');
$search = get_parameter('search', '');
$text_agent = get_parameter('text_agent', __('All'));
$pagination = get_parameter('pagination', '');
$event_view_hr = get_parameter('event_view_hr', '');
$id_user_ack = get_parameter('id_user_ack', '');
$group_rep = get_parameter('group_rep', '');
$tag = get_parameter('tag', '');
$filter_only_alert = get_parameter('filter_only_alert','');
if ($id_name == '') {
ui_print_error_message (__('Not updated. Blank name'));
} else {
$values = array ('id_filter' => $id,
'id_name' => $id_name,
'id_group' => $id_group,
'event_type' => $event_type,
'severity' => $severity,
'status' => $status,
'search' => $search,
'text_agent' => $text_agent,
'pagination' => $pagination,
'event_view_hr' => $event_view_hr,
'id_user_ack' => $id_user_ack,
'group_rep' => $group_rep,
'tag' => $tag,
'filter_only_alert' => $filter_only_alert
);
$result = db_process_sql_update ('tevent_filter', $values, array ('id_filter' => $id));
ui_print_result_message ($result,
__('Successfully updated'),
__('Not updated. Error updating data'));
}
}
if ($create) {
$id_group = (string) get_parameter ('id_group');
$id_name = (string) get_parameter ('id_name');
$event_type = get_parameter('event_type', '');
$severity = get_parameter('severity', '');
$status = get_parameter('status', '');
$search = get_parameter('search', '');
$text_agent = get_parameter('text_agent', '');
$pagination = get_parameter('pagination', '');
$event_view_hr = get_parameter('event_view_hr', '');
$id_user_ack = get_parameter('id_user_ack', '');
$group_rep = get_parameter('group_rep',' ');
$tag = get_parameter('tag', '');
$filter_only_alert = get_parameter('filter_only_alert', '');
$values = array (
'id_name' => $id_name,
'id_group' => $id_group,
'event_type' => $event_type,
'severity' => $severity,
'status' => $status,
'search' => $search,
'text_agent' => $text_agent,
'pagination' => $pagination,
'event_view_hr' => $event_view_hr,
'id_user_ack' => $id_user_ack,
'group_rep' => $group_rep,
'tag' => $tag,
'filter_only_alert' => $filter_only_alert
);
$id = db_process_sql_insert('tevent_filter', $values);
if ($id === false) {
ui_print_error_message ('Error creating filter');
} else {
ui_print_success_message ('Filter created successfully');
}
}
$table->width = '98%';
$table->border = 0;
$table->cellspacing = 3;
$table->cellpadding = 5;
$table->class = "databox_color";
$table->style[0] = 'vertical-align: top;';
$table->data = array ();
$table->data[0][0] = '<b>'.__('Name').'</b>';
$table->data[0][1] = html_print_input_text ('id_name', $id_name, false, 20, 80, true);
$own_info = get_user_info ($config['id_user']);
$table->data[1][0] = '<b>'.__('Group').'</b>';
$table->data[1][1] = html_print_select_groups($config['id_user'], "IW",
$own_info['is_admin'], 'id_group', $id_group, '', '', -1, true,
false, false);
$types = get_event_types ();
// Expand standard array to add not_normal (not exist in the array, used only for searches)
$types["not_normal"] = __("Not normal");
$table->data[2][0] = '<b>' . __('Event type') . '</b>';
$table->data[2][1] = html_print_select ($types, 'event_type', $event_type, '', __('All'), '', true);
$table->data[3][0] = '<b>' . __('Severity') . '</b>';
$table->data[3][1] = html_print_select (get_priorities (), "severity", $severity, '', __('All'), '-1', true);
$fields = events_get_all_status();
$table->data[4][0] = '<b>' . __('Event status') . '</b>';
$table->data[4][1] = html_print_select ($fields, 'status', $status, '', '', '', true);
$table->data[5][0] = '<b>' . __('Free search') . '</b>';
$table->data[5][1] = html_print_input_text ('search', io_safe_output($search), '', 15, 255, true);
$table->data[6][0] = '<b>' . __('Agent search') . '</b>';
$src_code = html_print_image('images/lightning.png', true, false, true);
$table->data[6][1] = html_print_input_text_extended ('text_agent', $text_agent, 'text_id_agent', '', 30, 100, false, '',
array('style' => 'background: url(' . $src_code . ') no-repeat right;'), true)
. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>';
$lpagination[25] = 25;
$lpagination[50] = 50;
$lpagination[100] = 100;
$lpagination[200] = 200;
$lpagination[500] = 500;
$table->data[7][0] = '<b>' . __('Block size for pagination') . '</b>';
$table->data[7][1] = html_print_select ($lpagination, "pagination", $pagination, '', __('Default'), $config["block_size"], true);
$table->data[8][0] = '<b>' . __('Max. hours old') . '</b>';
$table->data[8][1] = html_print_input_text ('event_view_hr', $event_view_hr, '', 5, 255, true);
$table->data[9][0] = '<b>' . __('User ack.') . '</b>';
$users = users_get_info ();
$table->data[9][1] = html_print_select ($users, "id_user_ack", $id_user_ack, '', __('Any'), 0, true);
$repeated_sel[0] = __("All events");
$repeated_sel[1] = __("Group events");
$table->data[10][0] = '<b>' . __('Repeated') . '</b>';
$table->data[10][1] = html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', '', true);
$tags = tags_search_tag();
if($tags === false) {
$tags = array();
}
$tags_name = array();
foreach($tags as $t) {
$tags_name[$t['name']] = $t['name'];
}
$table->data[11][0] = '<b>' . __('Tag') . '</b>';
$table->data[11][1] = html_print_select ($tags_name, "tag", $tag, '', __('All'), "", true);
$table->data[12][0] = '<b>' . __('Alert events') . '</b>';
$table->data[12][1] = html_print_select (array('-1' => __('All'), '0' => __('Filter alert events'), '1' => __('Only alert events')), "filter_only_alert", $filter_only_alert, '', '', '', true);
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/event_edit_filter">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden ('update', 1);
html_print_input_hidden ('id', $id);
html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else {
html_print_input_hidden ('create', 1);
html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';
ui_require_jquery_file ('bgiframe');
ui_require_jquery_file ('autocomplete');
?>
<script language="javascript" type="text/javascript">
/* <![CDATA[ */
$(document).ready( function() {
$("#text_id_agent").autocomplete(
"ajax.php",
{
minChars: 2,
scroll:true,
extraParams: {
page: "operation/agentes/exportdata",
search_agents: 1,
add: '<?php echo json_encode(array('-1' => "All", '0' => "System"));?>',
id_group: function() { return $("#id_group").val(); }
},
formatItem: function (data, i, total) {
if (total == 0)
$("#text_id_agent").css ('background-color', '#cc0000');
else
$("#text_id_agent").css ('background-color', '');
if (data == "")
return false;
return data[0]+'<br><span class="ac_extra_field"><?php echo __("IP") ?>: '+data[1]+'</span>';
},
delay: 200
}
);
});
/* ]]> */
</script>

View File

@ -0,0 +1,188 @@
<?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.
// Load global vars
global $config;
check_login ();
if (! check_acl ($config["id_user"], 0, "IR")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$delete = (bool) get_parameter ('delete', 0);
$multiple_delete = (bool)get_parameter('multiple_delete', 0);
// Show header in delete action
if ($delete or $multiple_delete){
// Prints header tabs
$buttons = array(
'view' => array('active' => false,
'text' => '<a href="index.php?sec=geventos&sec2=operation/events/events">' .
html_print_image("images/zoom.png", true, array("title" => __('View events'))) . '</a>'),
'filter' => array('active' => true,
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&amp;section=filter">' .
html_print_image("images/lightning_go.png", true, array ("title" => __('Create filter'))) . '</a>'),
'fields' => array('active' => false,
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&amp;section=fields">' .
html_print_image("images/god6.png", true, array ("title" => __('Custom fields'))) . '</a>'),
);
ui_print_page_header (__("Manage events") . ' - ' . __('Filters'), "images/lightning_go.png", false, "", true, $buttons);
}
if ($delete){
$id = (int) get_parameter('id');
$id_filter = db_get_value('id_name', 'tevent_filter', 'id_filter', $id);
if ($id_filter === false) {
$result = false;
}
else {
$result = db_process_sql_delete ('tevent_filter', array ('id_filter' => $id));
}
if ($result !== false) {
$result = true;
} else {
$result = false;
}
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
if ($multiple_delete) {
$ids = (array)get_parameter('delete_multiple', array());
db_process_sql_begin();
foreach ($ids as $id) {
$result = db_process_sql_delete ('tevent_filter',
array ('id_filter' => $id));
if ($result === false) {
db_process_sql_rollback();
break;
}
}
if ($result !== false) {
db_process_sql_commit();
}
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
$own_info = get_user_info ($config['id_user']);
// Get group list that user has access
$groups_user = users_get_groups ($config['id_user'], "AW", $own_info['is_admin'], true);
$sql = "SELECT * FROM tevent_filter WHERE id_group IN (".implode(',', array_keys ($groups_user)).")";
$filters = db_get_all_rows_sql($sql);
if ($filters === false)
$filters = array ();
$table->width = '98%';
$table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('Group');
$table->head[2] = __('Event type');
$table->head[3] = __('Event status');
$table->head[4] = __('Severity');
$table->head[5] = __('Action') .
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->align = array ();
$table->align[1] = 'center';
$table->align[2] = 'center';
$table->align[3] = 'center';
$table->align[4] = 'center';
$table->align[5] = 'center';
$table->size = array ();
$table->size[0] = '50%';
$table->size[1] = '5px';
$table->size[2] = '80px';
$table->size[3] = '80px';
$table->size[4] = '80px';
$table->size[5] = '40px';
$table->data = array ();
$total_filters = db_get_all_rows_filter ('tevent_filter', false, 'COUNT(*) AS total');
$total_filters = $total_filters[0]['total'];
//ui_pagination ($total_filters, $url);
foreach ($filters as $filter) {
$data = array ();
$data[0] = '<a href="index.php?sec=geventos&sec2=godmode/events/event_edit_filter&id='.$filter['id_filter'].'">'.$filter['id_name'].'</a>';
$data[1] = ui_print_group_icon ($filter['id_group'], true);
$data[2] = events_get_event_types($filter['event_type']);
$data[3] = events_get_status($filter['status']);
$data[4] = events_get_severity_types($filter['severity']);
$data[5] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;'
href='index.php?sec=geventos&sec2=godmode/events/event_filter&delete=1&id=".$filter['id_filter']."&offset=0'>" .
html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "</a>" .
html_print_checkbox_extended ('delete_multiple[]', $filter['id_filter'], false, false, '', 'class="check_delete"', true);
array_push ($table->data, $data);
}
if(isset($data)) {
echo "<form method='post' action='index.php?sec=geventos&sec2=godmode/events/event_filter'>";
html_print_input_hidden('multiple_delete', 1);
html_print_table ($table);
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo "</div>";
echo "</form>";
}
else {
echo "<div class='nf'>".__('There are no defined filters')."</div>";
}
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/event_edit_filter">';
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
html_print_submit_button (__('Create filter'), 'crt', false, 'class="sub wand"');
echo "</div>";
echo '</form>';
?>
<script type="text/javascript">
function check_all_checkboxes() {
if ($("input[name=all_delete]").attr('checked')) {
$(".check_delete").attr('checked', true);
}
else {
$(".check_delete").attr('checked', false);
}
}
</script>

View File

@ -0,0 +1,71 @@
<?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.
// Load global vars
global $config;
check_login ();
if (! check_acl ($config["id_user"], 0, "IW")) {
db_pandora_audit("ACL Violation",
"Trying to access event manage");
require ("general/noaccess.php");
return;
}
// Gets section to jump to another section
$section = (string) get_parameter ("section", "filter");
// Draws header
$buttons = array(
'view' => array('active' => false,
'text' => '<a href="index.php?sec=eventos&sec2=operation/events/events">' .
html_print_image("images/zoom.png", true, array("title" => __('View events'))) . '</a>'),
'separator' => array(),
'filter' => array('active' => false,
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&amp;section=filter">' .
html_print_image("images/lightning_go.png", true, array ("title" => __('Create filter'))) . '</a>'),
'fields' => array('active' => false,
'text' => '<a href="index.php?sec=geventos&sec2=godmode/events/events&amp;section=fields">' .
html_print_image("images/god6.png", true, array ("title" => __('Custom fields'))) . '</a>'),
);
switch ($section){
case 'filter': $buttons['filter']['active'] = true;
$subpage = ' - ' . __('Filters');
break;
case 'fields': $buttons['fields']['active'] = true;
$subpage = ' - ' . __('Custom fields');
break;
case 'view': $buttons['view']['active'] = true;
break;
default: $buttons['filter']['active'] = true;
$subpage = ' - ' . __('Filters');
break;
}
ui_print_page_header (__("Manage events") . $subpage, "images/lightning_go.png", false, "", true, $buttons);
switch($section) {
case 'filter':
require_once('godmode/events/event_filter.php');
break;
case 'fields':
require_once('godmode/events/custom_events.php');
break;
}
?>

View File

@ -164,6 +164,19 @@ if (check_acl ($config['id_user'], 0, "IW")) {
}
}
if (check_acl ($config['id_user'], 0, "IW")) {
// Manage events
$menu["geventos"]["text"] = __('Manage events');
$menu["geventos"]["sec2"] = "godmode/events/events&amp;section=filter";
$menu["geventos"]["id"] = "god-events";
// Custom event fields
$sub = array ();
$sub["godmode/events/events&amp;section=fields"]["text"] = __('Custom events');
$menu["geventos"]["sub"] = $sub;
}
if (check_acl ($config['id_user'], 0, "AW")) {
// Servers
@ -223,8 +236,6 @@ if (check_acl ($config['id_user'], 0, "PM")) {
enterprise_hook ('enterprise_acl_submenu');
enterprise_hook ('skins_submenu');
$sub["extras/pandora_diag"]["text"] = __('Diagnostic info');
$sub["godmode/events/custom_events"]["text"] = __('Custom events');
$menu["gsetup"]["sub"] = $sub;
}

View File

@ -189,4 +189,6 @@
#icon_god-tag {
background-image: url(../../images/tag_red.png);
}
#icon_god-events {
background-image: url(../../images/lightning_go.png);
}

View File

@ -727,4 +727,207 @@ function events_get_module ($id_agent_module, $period, $date = 0) {
return db_get_all_rows_sql ($sql);
}
/**
* Decode a numeric type into type description.
*
* @param int $type_id Numeric type.
*
* @return string Type description.
*/
function events_get_event_types ($type_id){
$diferent_types = get_event_types ();
$type_desc = '';
switch($type_id) {
case 'unknown': $type_desc = __('Unknown');
break;
case 'critical': $type_desc = __('Monitor Critical');
break;
case 'warning': $type_desc = __('Monitor Warning');
break;
case 'normal': $type_desc = __('Monitor Normal');
break;
case 'alert_fired': $type_desc = __('Alert fired');
break;
case 'alert_recovered': $type_desc = __('Alert recovered');
break;
case 'alert_ceased': $type_desc = __('Alert ceased');
break;
case 'alert_manual_validation': $type_desc = __('Alert manual validation');
break;
case 'recon_host_detected': $type_desc = __('Recon host detected');
break;
case 'system': $type_desc = __('System');
break;
case 'error': $type_desc = __('Error');
break;
case 'not_normal': $type_desc = __('Not normal');
break;
default:
if (isset($config['text_char_long'])) {
foreach ($diferent_types as $key => $type) {
if ($key == $type_id){
$type_desc = ui_print_truncate_text($type, $config['text_char_long'], false, true, false);
}
}
}
break;
}
return $type_desc;
}
/**
* Decode a numeric severity into severity description.
*
* @param int $severity_id Numeric severity.
*
* @return string Severity description.
*/
function events_get_severity_types ($severity_id){
$diferent_types = get_priorities ();
$severity_desc = '';
switch ($severity_id) {
case 0: $severity_desc = __('Maintenance');
break;
case 1: $severity_desc = __('Informational');
break;
case 2: $severity_desc = __('Normal');
break;
case 3: $severity_desc = __('Warning');
break;
case 4: $severity_desc = __('Critical');
break;
default:
if (isset($config['text_char_long'])) {
foreach ($diferent_types as $key => $type) {
if ($key == $severity_id){
$severity_desc = ui_print_truncate_text($type, $config['text_char_long'], false, true, false);
}
}
}
break;
}
return $severity_desc;
}
/**
* Return all descriptions of event status.
*
* @return array Status description array.
*/
function events_get_all_status (){
$fields = array ();
$fields[-1] = __('All event');
$fields[0] = __('Only new');
$fields[1] = __('Only validated');
$fields[2] = __('Only in process');
$fields[3] = __('Only not validated');
return $fields;
}
/**
* Decode a numeric status into status description.
*
* @param int $status_id Numeric status.
*
* @return string Status description.
*/
function events_get_status ($status_id){
switch($status_id) {
case -1: $status_desc = __('All event');
break;
case 0: $status_desc = __('Only new');
break;
case 1: $status_desc = __('Only validated');
break;
case 2: $status_desc = __('Only in process');
break;
case 3: $status_desc = __('Only not validated');
break;
}
return $status_desc;
}
/**
* Checks if a user has permissions to see an event filter.
*
* @param int $id_filter Id of the event filter.
*
* @return bool True if the user has permissions or false otherwise.
*/
function events_check_event_filter_group ($id_filter) {
global $config;
$id_group = db_get_value('id_group', 'tevent_filter', 'id_filter', $id_filter);
$own_info = get_user_info ($config['id_user']);
// Get group list that user has access
$groups_user = users_get_groups ($config['id_user'], "IW", $own_info['is_admin'], true);
$groups_id = array();
$has_permission = false;
foreach($groups_user as $key => $groups){
if ($groups['id_grupo'] == $id_group)
return true;
}
return false;
}
/**
* Get a event filter.
*
* @param int Filter id to be fetched.
* @param array Extra filter.
* @param array Fields to be fetched.
*
* @return array A event filter matching id and filter or false.
*/
function events_get_event_filter ($id_filter, $filter = false, $fields = false) {
if (empty($id_filter)){
return false;
}
if (! is_array ($filter)){
$filter = array ();
$filter['id_filter'] = (int) $id_filter;
}
return db_get_row_filter ('tevent_filter', $filter, $fields);
}
/**
* Get a event filters in select format.
*
* @return array A event filter matching id and filter or false.
*/
function events_get_event_filter_select(){
global $config;
$user_groups = users_get_groups ($config['id_user'], "AW", true, true);
$sql = "SELECT id_filter, id_name FROM tevent_filter WHERE id_group IN (".implode(',', array_keys ($user_groups)).")";
$event_filters = db_get_all_rows_sql($sql);
if ($event_filters === false){
return array();
}
else{
$result = array();
foreach ($event_filters as $event_filter){
$result[$event_filter['id_filter']] = $event_filter['id_name'];
}
}
return $result;
}
?>

View File

@ -194,4 +194,6 @@
#icon_god-tag {
background-image: url(../../images/tag_red.png);
}
#icon_god-events {
background-image: url(../../images/lightning_go.png);
}

View File

@ -166,8 +166,10 @@ $group_rep = (int) get_parameter ("group_rep", 1);
$delete = (bool) get_parameter ("delete");
$validate = (bool) get_parameter ("validate", 0);
$section = (string) get_parameter ("section", "list");
$text_agent = (string)get_parameter('text_agent', __("All"));
$filter_only_alert = (int)get_parameter('filter_only_alert', -1);
$text_agent = (string) get_parameter('text_agent', __("All"));
$filter_only_alert = (int) get_parameter('filter_only_alert', -1);
$filter_id = (int) get_parameter('filter_id', 0);
$id_name = (string) get_parameter('id_name', '');
$search = io_safe_output(preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", rawurldecode (get_parameter ("search"))));
@ -187,27 +189,57 @@ $url = "index.php?sec=eventos&amp;sec2=operation/events/events&amp;search=" .
if ($config["pure"] == 0) {
$pss = get_user_info($config['id_user']);
$hashup = md5($config['id_user'] . $pss['password']);
// Fullscreen
$fullscreen['active'] = false;
$fullscreen['text'] = '<a href="'.$url.'&amp;pure=1">' .
html_print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .'</a>';
$buttons = array(
'fullscreen' => array('active' => false,
'text' => '<a href="'.$url.'&amp;pure=1">' .
html_print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .'</a>'),
'rss' => array('active' => false,
'text' => '<a href="operation/events/events_rss.php?user=' . $config['id_user'] . '&hashup=' . $hashup .
'&text_agent=' . $text_agent . '&ev_group='.$ev_group.'&amp;event_type='.$event_type.'&amp;search='.io_safe_input($search).'&amp;severity='.$severity.'&amp;status='.$status.'&amp;event_view_hr='.$event_view_hr.'&amp;id_agent='.$id_agent.'">' .
html_print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .'</a>'),
'marquee' => array('active' => false,
'text' => '<a href="operation/events/events_marquee.php">' .
html_print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .'</a>'),
'csv' => array('active' => false,
'text' => '<a href="operation/events/export_csv.php?ev_group=' . $ev_group .
'&text_agent=' . $text_agent . '&amp;event_type='.$event_type.'&amp;search='.io_safe_input($search).'&amp;severity='.$severity.'&amp;status='.$status.'&amp;event_view_hr='.$event_view_hr.'&amp;id_agent='.$id_agent.'">' .
html_print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .'</a>'),
'sound_event' => array('active' => false,
'text' => '<a href="javascript: openSoundEventWindow();">' . html_print_image('images/music_note.png', true, array('title' => __('Sound events'))) . '</a>')
);
// Event list
$list['active'] = false;
$list['text'] = '<a href="index.php?sec=eventos&sec2=operation/events/events">' .
html_print_image("images/god6.png", true, array("title" => __('Event list'))) . '</a>';
$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.'&amp;event_type='.$event_type.'&amp;search='.io_safe_input($search).'&amp;severity='.$severity.'&amp;status='.$status.'&amp;event_view_hr='.$event_view_hr.'&amp;id_agent='.$id_agent.'">' .
html_print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .'</a>';
ui_print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $buttons);
// Marquee
$marquee['active'] = false;
$marquee['text'] = '<a href="operation/events/events_marquee.php">' .
html_print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .'</a>';
$csv['active'] = false;
$csv['text'] = '<a href="operation/events/export_csv.php?ev_group=' . $ev_group .
'&text_agent=' . $text_agent . '&amp;event_type='.$event_type.'&amp;search='.io_safe_input($search).'&amp;severity='.$severity.'&amp;status='.$status.'&amp;event_view_hr='.$event_view_hr.'&amp;id_agent='.$id_agent.'">' .
html_print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .'</a>';
// Sound events
$sound_event['active'] = false;
$sound_event['text'] = '<a href="javascript: openSoundEventWindow();">' . html_print_image('images/music_note.png', true, array('title' => __('Sound events'))) . '</a>';
// If the user has administrator permission display manage tab
if (check_acl ($config["id_user"], 0, "IW")) {
// Manage events
$manage_events['active'] = false;
$manage_events['text'] = '<a href="index.php?sec=geventos&sec2=godmode/events/events&amp;section=filter">' .
html_print_image("images/setup.png", true, array ("title" => __('Manage events'))) . '</a>';
$onheader = array('manage_events' => $manage_events, 'separator' => '', 'fullscreen' => $fullscreen,
'list' => $list, 'rss' => $rss, 'marquee' => $marquee, 'csv' => $csv, 'sound_event' => $sound_event) ;
}
else {
$onheader = array('fullscreen' => $fullscreen,
'list' => $list, 'rss' => $rss, 'marquee' => $marquee, 'csv' => $csv, 'sound_event' => $sound_event) ;
}
switch ($section){
case 'sound_event': $onheader['sound_event']['active'] = true;
break;
default: $onheader['list']['active'] = true;
break;
}
ui_print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $onheader);
?>
<script type="text/javascript">

View File

@ -35,6 +35,92 @@ if (! check_acl ($config["id_user"], 0, "IR")) {
return;
}
if (is_ajax()){
$get_filter_values = get_parameter('get_filter_values', 0);
$save_event_filter = get_parameter('save_event_filter', 0);
$update_event_filter = get_parameter('update_event_filter', 0);
$get_event_filters = get_parameter('get_event_filters', 0);
// Get db values of a single filter
if ($get_filter_values){
$id_filter = get_parameter('id');
$event_filter = events_get_event_filter($id_filter);
$event_filter['tag'] = io_safe_output($event_filter['tag']);
$event_filter['id_name'] = io_safe_output($event_filter['id_name']);
echo json_encode($event_filter);
}
// Saves an event filter
if ($save_event_filter){
$values = array();
$values['id_name'] = get_parameter('id_name');
$values['id_group'] = get_parameter('id_group');
$values['event_type'] = get_parameter('event_type');
$values['severity'] = get_parameter('severity');
$values['status'] = get_parameter('status');
$values['search'] = get_parameter('search');
$values['text_agent'] = get_parameter('text_agent');
$values['pagination'] = get_parameter('pagination');
$values['event_view_hr'] = get_parameter('event_view_hr');
$values['id_user_ack'] = get_parameter('id_user_ack');
$values['group_rep'] = get_parameter('group_rep');
$values['tag'] = get_parameter('tag');
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$result = db_process_sql_insert('tevent_filter', $values);
if ($result === false){
echo 'error';
}
else {
echo $result;
}
}
if ($update_event_filter){
$values = array();
$id = get_parameter('id');
$values['id_name'] = get_parameter('id_name');
$values['id_group'] = get_parameter('id_group');
$values['event_type'] = get_parameter('event_type');
$values['severity'] = get_parameter('severity');
$values['status'] = get_parameter('status');
$values['search'] = get_parameter('search');
$values['text_agent'] = get_parameter('text_agent');
$values['pagination'] = get_parameter('pagination');
$values['event_view_hr'] = get_parameter('event_view_hr');
$values['id_user_ack'] = get_parameter('id_user_ack');
$values['group_rep'] = get_parameter('group_rep');
$values['tag'] = get_parameter('tag');
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$result = db_process_sql_update('tevent_filter', $values, array('id_filter' => $id));
if ($result === false){
echo 'error';
}
else {
echo 'ok';
}
}
if ($get_event_filters){
$event_filter = events_get_event_filter_select();
echo json_encode($event_filter);
}
return;
}
// Error div for ajax messages
echo "<div id='show_filter_error'>";
echo "</div>";
$tag = get_parameter("tag", "");
if ($id_agent == -2) {
@ -166,7 +252,12 @@ echo '<div id="event_control" style="display:none">';
// Table for filter controls
echo '<form method="post" action="index.php?sec=eventos&amp;sec2=operation/events/events&amp;refr='.$config["refr"].'&amp;pure='.$config["pure"].'&amp;section=list">';
echo '<table style="float:left;" width="550" cellpadding="4" cellspacing="4" class="databox"><tr>';
echo '<table style="float:left;" width="550" cellpadding="4" cellspacing="4" class="databox"><tr id="row_name" style="visibility: hidden">';
// Group combo
echo "<td>".__('Filter name')."</td><td>";
html_print_input_text ('id_name', $id_name, '', 15);
echo "</td></tr>";
// Group combo
echo "<td>".__('Group')."</td><td>";
@ -190,12 +281,8 @@ echo '</td>';
// Status
echo "<td>".__('Event status')."</td><td>";
$fields = array ();
$fields[-1] = __('All event');
$fields[0] = __('Only new');
$fields[1] = __('Only validated');
$fields[2] = __('Only in process');
$fields[3] = __('Only not validated');
$fields = events_get_all_status();
html_print_select ($fields, 'status', $status, '', '', '');
@ -277,10 +364,22 @@ html_print_select (array('-1' => __('All'), '0' => __('Filter alert events'), '1
echo "</td></tr>";
echo '<tr><td>';
echo __("Load filter");
echo '</td><td>';
// Custom filters from user
$filters = events_get_event_filter_select();
html_print_select ($filters, "filter_id", $filter_id, '', __('none'), 0, false);
echo '</td></tr>';
echo '<tr><td colspan="4" style="text-align:right">';
//The buttons
html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd" style="visibility:hidden"');
html_print_submit_button (__('Save filter'), 'save_filter', false, 'class="sub upd"');
html_print_submit_button (__('Update'), '', false, 'class="sub upd"');
echo "</td></tr></table></form>"; //This is the filter div
@ -958,3 +1057,211 @@ echo '</div>';
unset ($table);
?>
<script language="javascript" type="text/javascript">
/*
<![CDATA[ */
$(document).ready( function() {
// If selected is not 'none' show filter name
if ( $("#filter_id").val() != 0 ) {
$("#row_name").css('visibility', '');
$("#submit-update_filter").css('visibility', '');
}
$("#filter_id").change(function () {
// If selected 'none' flush filter
if ( $("#filter_id").val() == 0 ){
$("#text-id_name").val('');
$("#ev_group").val(0);
$("#event_type").val('');
$("#severity").val(-1);
$("#status").val(3);
$("#text-search").val('');
$("#text_id_agent").val( <?php echo '"' . __('All') . '"' ?> );
$("#pagination").val(25);
$("#text-event_view_hr").val(8);
$("#id_user_ack").val(0);
$("#group_rep").val(1);
$("#tag").val('');
$("#filter_only_alert").val(-1);
$("#row_name").css('visibility', 'hidden');
$("#submit-update_filter").css('visibility', 'hidden');
}
// If filter selected then load filter
else {
$('#row_name').css('visibility', '');
$("#submit-update_filter").css('visibility', '');
jQuery.post ("ajax.php",
{"page" : "operation/events/events_list",
"get_filter_values" : 1,
"id" : $('#filter_id').val()
},
function (data) {
jQuery.each (data, function (i, val) {
if (i == 'id_name')
$("#text-id_name").val(val);
if (i == 'id_group')
$("#ev_group").val(val);
if (i == 'event_type')
$("#event_type").val(val);
if (i == 'severity')
$("#severity").val(val);
if (i == 'status')
$("#status").val(val);
if (i == 'search')
$("#text-search").val(val);
if (i == 'text_agent')
$("#text_id_agent").val(val);
if (i == 'pagination')
$("#pagination").val(val);
if (i == 'event_view_hr')
$("#text-event_view_hr").val(val);
if (i == 'id_user_ack')
$("#id_user_ack").val(val);
if (i == 'group_rep')
$("#group_rep").val(val);
if (i == 'tag')
$("#tag").val(val);
if (i == 'filter_only_alert')
$("#filter_only_alert").val(val);
});
},
"json"
);
}
});
// This saves an event filter
$("#submit-save_filter").click(function () {
// Checks if the filter has name or not
if ($('#row_name').css('visibility') == 'hidden') {
$('#row_name').css('visibility', '');
$('#show_filter_error').html('<h3 class="error">Define a name for the filter and click on Save filter again</h3>');
// If the filter has name insert in database
}else{
// If the filter name is blank show error
if ($('#text-id_name').val() == '') {
$('#show_filter_error').html('<h3 class="error">Filter name cannot be left blank</h3>');
return false;
}
var id_filter_save;
jQuery.post ("ajax.php",
{"page" : "operation/events/events_list",
"save_event_filter" : 1,
"id_name" : $("#text-id_name").val(),
"id_group" : $("#ev_group").val(),
"event_type" : $("#event_type").val(),
"severity" : $("#severity").val(),
"status" : $("#status").val(),
"search" : $("#text-search").val(),
"text_agent" : $("#text_id_agent").val(),
"pagination" : $("#pagination").val(),
"event_view_hr" : $("#text-event_view_hr").val(),
"id_user_ack" : $("#id_user_ack").val(),
"group_rep" : $("#group_rep").val(),
"tag" : $("#tag").val(),
"filter_only_alert" : $("#filter_only_alert").val()
},
function (data) {
if (data == 'error'){
$('#show_filter_error').html('<h3 class="error">Error creating filter</h3>');
}else{
id_filter_save = data;
$('#show_filter_error').html('<h3 class="suc">Filter created</h3>');
}
});
// First remove all options of filters select
$('#filter_id').find('option').remove().end();
// Add 'none' option the first
$('#filter_id').append ($('<option></option>').html ( <?php echo "'" . __('none') . "'" ?> ).attr ("value", 0));
// Reload filters select
jQuery.post ("ajax.php",
{"page" : "operation/events/events_list",
"get_event_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_save){
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
} else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
}
return false;
});
// This updates an event filter
$("#submit-update_filter").click(function () {
// If the filter name is blank show error
if ($('#text-id_name').val() == '') {
$('#show_filter_error').html('<h3 class="error">Filter name cannot be left blank</h3>');
return false;
}
var id_filter_update = $("#filter_id").val();
jQuery.post ("ajax.php",
{"page" : "operation/events/events_list",
"update_event_filter" : 1,
"id" : $("#filter_id").val(),
"id_name" : $("#text-id_name").val(),
"id_group" : $("#ev_group").val(),
"event_type" : $("#event_type").val(),
"severity" : $("#severity").val(),
"status" : $("#status").val(),
"search" : $("#text-search").val(),
"text_agent" : $("#text_id_agent").val(),
"pagination" : $("#pagination").val(),
"event_view_hr" : $("#text-event_view_hr").val(),
"id_user_ack" : $("#id_user_ack").val(),
"group_rep" : $("#group_rep").val(),
"tag" : $("#tag").val(),
"filter_only_alert" : $("#filter_only_alert").val()
},
function (data) {
if (data == 'ok'){
$('#show_filter_error').html('<h3 class="suc">Filter updated</h3>');
}else{
$('#show_filter_error').html('<h3 class="error">Error updating filter</h3>');
}
});
// First remove all options of filters select
$('#filter_id').find('option').remove().end();
// Add 'none' option the first
$('#filter_id').append ($('<option></option>').html ( <?php echo "'" . __('none') . "'" ?> ).attr ("value", 0));
// Reload filters select
jQuery.post ("ajax.php",
{"page" : "operation/events/events_list",
"get_event_filters" : 1
},
function (data) {
jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val);
if (i == id_filter_update){
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
} else {
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
}
});
},
"json"
);
return false;
});
});
/* ]]> */
</script>

View File

@ -1556,3 +1556,23 @@ show_graph VARCHAR2(60),
CREATE SEQUENCE tnetflow_report_content_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tnetflow_report_content_inc BEFORE INSERT ON tnetflow_report_content REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetflow_report_content_s.nextval INTO :NEW.ID_RC FROM dual; END tnetflow_report_content_inc;;
-- -----------------------------------------------------
-- Table `tevent_filter`
-- -----------------------------------------------------
CREATE TABLE tevent_filter (
id_filter NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_name VARCHAR2(600) NOT NULL,
id_group NUMBER(10, 0) default 0 NOT NULL,
event_type CLOB default '' NOT NULL,
severity NUMBER(10, 0) default -1 NOT NULL,
status NUMBER(10, 0) default -1 NOT NULL,
search CLOB default '',
text_agent CLOB default '',
pagination NUMBER(10, 0) default 25 NOT NULL,
event_view_hr NUMBER(10, 0) default 8 NOT NULL,
id_user_ack CLOB,
group_rep NUMBER(10, 0) default 0 NOT NULL,
tag VARCHAR2(600) default '' NOT NULL,
filter_only_alert NUMBER(10, 0) default -1 NOT NULL
);

View File

@ -1254,3 +1254,23 @@ CREATE TABLE "tnetflow_report_content" (
"show_graph" varchar(60),
"order" INTEGER NOT NULL default 0
);
-- -----------------------------------------------------
-- Table `tevent_filter`
-- -----------------------------------------------------
CREATE TABLE "tevent_filter" (
"id_filter" SERIAL NOT NULL PRIMARY KEY,
"id_name" varchar(600) NOT NULL,
"id_group" INTEGER NOT NULL default 0,
"event_type" TEXT NOT NULL default '',
"severity" INTEGER NOT NULL default -1,
"status" INTEGER NOT NULL default -1,
"search" TEXT default '',
"text_agent" TEXT default '',
"pagination" INTEGER NOT NULL default 25,
"event_view_hr" INTEGER NOT NULL default 8,
"id_user_ack" TEXT,
"group_rep" INTEGER NOT NULL default 0,
"tag" varchar(600) NOT NULL default '',
"filter_only_alert" INTEGER NOT NULL default -1
);

View File

@ -1356,3 +1356,25 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
FOREIGN KEY (`id_filter`) REFERENCES tnetflow_filter(`id_sg`)
ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tevent_filter`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tevent_filter` (
`id_filter` int(10) unsigned NOT NULL auto_increment,
`id_name` varchar(600) NOT NULL,
`id_group` int(10) NOT NULL default 0,
`event_type` text NOT NULL default '',
`severity` int(10) NOT NULL default -1,
`status` int(10) NOT NULL default -1,
`search` TEXT default '',
`text_agent` TEXT default '',
`pagination` int(10) NOT NULL default 25,
`event_view_hr` int(10) NOT NULL default 8,
`id_user_ack` TEXT,
`group_rep` int(10) NOT NULL default 0,
`tag` varchar(600) NOT NULL default '',
`filter_only_alert` int(10) NOT NULL default -1,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;