2012-11-07 Miguel de Dios <miguel.dedios@artica.es>

* index.php: cleaned source code style.
	
	* pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
	extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
	extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
	extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql: added the field
	"tag_with" and "tag_without", and removed the field "tags" in the
	table "tevent_filter".
	* operation/events/events_list.php,
	godmode/events/event_edit_filter.php: added widgets for to filter
	the events by tags with the events or and tags without the
	events.
	
	* include/functions_tags.php: cleaned source code style, and
	clarifity the function "tags_search_tag".
	
	* include/functions_html.php: into the function
	"html_print_input_hidden" fixed when the value have double quotes or
	single quotes.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7135 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-11-07 17:49:31 +00:00
parent c7e071f853
commit 760271a0c0
12 changed files with 934 additions and 217 deletions

View File

@ -1,3 +1,25 @@
2012-11-07 Miguel de Dios <miguel.dedios@artica.es>
* index.php: cleaned source code style.
* pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql: added the field
"tag_with" and "tag_without", and removed the field "tags" in the
table "tevent_filter".
* operation/events/events_list.php,
godmode/events/event_edit_filter.php: added widgets for to filter
the events by tags with the events or and tags without the
events.
* include/functions_tags.php: cleaned source code style, and
clarifity the function "tags_search_tag".
* include/functions_html.php: into the function
"html_print_input_hidden" fixed when the value have double quotes or
single quotes.
2012-11-07 Miguel de Dios <miguel.dedios@artica.es>
* godmode/alerts/configure_alert_command.php, index.php: cleaned

View File

@ -198,7 +198,8 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
`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 '',
`tag_with` text NOT NULL,
`tag_without` text NOT NULL,
`filter_only_alert` int(10) NOT NULL default -1,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -140,9 +140,9 @@ CREATE TABLE tplanned_downtime_modules (
CREATE SEQUENCE tplanned_downtime_modules_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tplanned_downtime_modules_inc BEFORE INSERT ON tplanned_downtime_modules REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_modules_s.nextval INTO :NEW.ID FROM dual; END tplanned_downtime_modules_inc;;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table tevento
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
ALTER TABLE tevento ADD (source VARCHAR2(100) default '' NOT NULL);
ALTER TABLE tevento ADD (id_extra VARCHAR2(100) default '' NOT NULL);
ALTER TABLE tevento ADD (critical_instructions VARCHAR2(255) default '');
@ -152,16 +152,16 @@ ALTER TABLE tevento MODIFY CONSTRAINT tevento_event_type_cons CHECK (event_type
ALTER TABLE tevento ADD (owner_user VARCHAR2(100) NOT NULL default '0');
ALTER TABLE tevento ADD (ack_utimestamp NUMBER(19, 0) NOT NULL default 0);
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table tgrupo
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
ALTER TABLE tgrupo ADD (description CLOB);
ALTER TABLE tgrupo ADD (contact CLOB);
ALTER TABLE tgrupo ADD (other CLOB);
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table talert_snmp
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
ALTER TABLE talert_snmp ADD (_snmp_f1_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f2_ CLOB default '');
@ -172,25 +172,26 @@ 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_group_filter NUMBER(10, 0) default 0 NOT NULL,
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
id_filter NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_group_filter NUMBER(10, 0) default 0 NOT NULL,
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_with CLOB,
tag_without CLOB,
filter_only_alert NUMBER(10, 0) default -1 NOT NULL
);
-- -----------------------------------------------------

View File

@ -142,7 +142,7 @@ ALTER TABLE "tevento" ADD COLUMN "unknown_instructions" text default '';
ALTER TYPE type_tevento_event ADD VALUE 'going_unknown' BEFORE 'unknown';
ALTER TABLE "tevento" ADD COLUMN "owner_user" varchar(100) NOT NULL default '0';
ALTER TABLE "tevento" ADD COLUMN "ack_utimestamp" BIGINT NOT NULL default 0;
-- -----------------------------------------------------
-- Table "tgrupo"
-- -----------------------------------------------------
@ -187,21 +187,22 @@ UPDATE "tagente_modulo" SET max_retries=plugin_pass WHERE id_modulo=7;
-- Table "tevent_filter"
-- -----------------------------------------------------
CREATE TABLE "tevent_filter" (
"id_filter" SERIAL NOT NULL PRIMARY KEY,
"id_group_filter" INTEGER NOT NULL default 0,
"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
"id_filter" SERIAL NOT NULL PRIMARY KEY,
"id_group_filter" INTEGER NOT NULL default 0,
"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_with" text NOT NULL,
"tag_without" text NOT NULL,
"filter_only_alert" INTEGER NOT NULL default -1
);
-- -----------------------------------------------------

View File

@ -30,7 +30,7 @@ $id = (int) get_parameter ('id');
$update = (string)get_parameter('update', 0);
$create = (string)get_parameter('create', 0);
if ($id){
if ($id) {
$permission = events_check_event_filter_group ($id);
if (!$permission) { // User doesn't have permissions to see this filter
require ("general/noaccess.php");
@ -43,10 +43,10 @@ $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,
'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,
'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>'),
);
@ -57,7 +57,7 @@ if ($id) {
$filter = events_get_event_filter ($id);
$id_group_filter = $filter['id_group_filter'];
$id_group = $filter['id_group'];
$id_name = $filter['id_name'];
$id_name = $filter['id_name'];
$event_type = $filter['event_type'];
$severity = $filter['severity'];
$status = $filter['status'];
@ -67,7 +67,8 @@ if ($id) {
$event_view_hr = $filter['event_view_hr'];
$id_user_ack = $filter['id_user_ack'];
$group_rep = $filter['group_rep'];
$tag = $filter['tag'];
$tag_with = io_safe_output($filter['tag_with']);
$tag_without = io_safe_output($filter['tag_without']);
$filter_only_alert = $filter['filter_only_alert'];
}
else {
@ -83,7 +84,8 @@ else {
$event_view_hr = '';
$id_user_ack = '';
$group_rep = '';
$tag = '';
$tag_with = json_encode(array());
$tag_without = json_encode(array());
$filter_only_alert = '';
}
@ -100,7 +102,8 @@ if ($update) {
$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', '');
$tag_with = get_parameter('tag_with', json_encode(array()));
$tag_without = get_parameter('tag_without', json_encode(array()));
$filter_only_alert = get_parameter('filter_only_alert','');
if ($id_name == '') {
@ -120,7 +123,8 @@ if ($update) {
'event_view_hr' => $event_view_hr,
'id_user_ack' => $id_user_ack,
'group_rep' => $group_rep,
'tag' => $tag,
'tag_with' => $tag_with,
'tag_without' => $tag_without,
'filter_only_alert' => $filter_only_alert
);
@ -130,6 +134,9 @@ if ($update) {
__('Successfully updated'),
__('Not updated. Error updating data'));
}
$tag_with = io_safe_output($tag_with);
$tag_without = io_safe_output($tag_without);
}
if ($create) {
@ -145,25 +152,26 @@ if ($create) {
$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', '');
$tag_with = get_parameter('tag_with', json_encode(array()));
$tag_without = get_parameter('tag_without', json_encode(array()));
$filter_only_alert = get_parameter('filter_only_alert', '');
$values = array (
'id_name' => $id_name,
'id_group_filter' => $id_group_filter,
'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_name' => $id_name,
'id_group_filter' => $id_group_filter,
'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_with' => $tag_with,
'tag_without' => $tag_without,
'filter_only_alert' => $filter_only_alert);
$id = db_process_sql_insert('tevent_filter', $values);
@ -173,6 +181,9 @@ if ($create) {
else {
ui_print_success_message ('Filter created successfully');
}
$tag_with = io_safe_output($tag_with);
$tag_without = io_safe_output($tag_without);
}
$own_info = get_user_info ($config['id_user']);
@ -184,6 +195,8 @@ $table->cellpadding = 5;
$table->class = "databox_color";
$table->style[0] = 'vertical-align: top;';
$table->valign[1] = 'top';
$table->data = array ();
$table->data[0][0] = '<b>'.__('Filter name').'</b>';
$table->data[0][1] = html_print_input_text ('id_name', $id_name, false, 20, 80, true);
@ -243,26 +256,89 @@ $table->data[10][1] = html_print_select ($users, "id_user_ack", $id_user_ack, ''
$repeated_sel[0] = __("All events");
$repeated_sel[1] = __("Group events");
$table->data[11][0] = '<b>' . __('Repeated') . '</b>';
$table->data[11][1] = html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', '', true);
$table->data[11][1] = html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', '', true);
$tags = tags_search_tag();
if($tags === false) {
$tags = array();
$tag_with = json_decode($tag_with, true);
$tag_without = json_decode($tag_without, true);
$tags = tags_search_tag(false, false, true);
$tags_select_with = array();
$tags_select_without = array();
$tag_with_temp = array();
$tag_without_temp = array();
foreach ($tags as $id_tag => $tag) {
if (array_search($id_tag, $tag_with) === false) {
$tags_select_with[$id_tag] = $tag;
}
else {
$tag_with_temp[$id_tag] = $tag;
}
if (array_search($id_tag, $tag_without) === false) {
$tags_select_without[$id_tag] = $tag;
}
else {
$tag_without_temp[$id_tag] = $tag;
}
}
$add_with_tag_disabled = empty($tags_select_with);
$remove_with_tag_disabled = empty($tag_with_temp);
$add_without_tag_disabled = empty($tags_select_without);
$remove_without_tag_disabled = empty($tag_without_temp);
$tags_name = array();
foreach($tags as $t) {
$tags_name[$t['name']] = $t['name'];
}
$table->colspan[13][0] = '2';
$table->data[13][0] = '<b>' . __('Events with following tags') . '</b>';
$table->data[14][0] = html_print_select ($tags_select_with, 'select_with',
'', '', '', 0, true, false, true, '', false, 'width: 120px;');
$table->data[14][1] = html_print_button(__('Add'), 'add_whith', $add_with_tag_disabled,
'', 'class="add sub"', true);
$table->data[12][0] = '<b>' . __('Tag') . '</b>';
$table->data[12][1] = html_print_select ($tags_name, "tag", $tag, '', __('All'), "", true);
$table->data[15][0] = html_print_select ($tag_with_temp,
'tag_with_temp', array(), '', '', 0, true, true,
true, '', false, "width: 120px; height: 50px;");
$table->data[15][0] .= html_print_input_hidden('tag_with',
json_encode($tag_with), true);
$table->data[15][1] = html_print_button(__('Remove'),
'remove_whith', $remove_with_tag_disabled, '', 'class="delete sub"', true);
$table->data[13][0] = '<b>' . __('Alert events') . '</b>';
$table->data[13][1] = html_print_select (array('-1' => __('All'), '0' => __('Filter alert events'), '1' => __('Only alert events')), "filter_only_alert", $filter_only_alert, '', '', '', true);
$table->colspan[16][0] = '2';
$table->data[16][0] = '<b>' . __('Events without following tags') . '</b>';
$table->data[17][0] = html_print_select ($tags_select_without, 'select_without',
'', '', '', 0, true, false, true, '', false, 'width: 120px;');
$table->data[17][1] = html_print_button(__('Add'), 'add_whithout', $add_without_tag_disabled,
'', 'class="add sub"', true);
$table->data[18][0] = html_print_select ($tag_without_temp,
'tag_without_temp', array(), '', '', 0, true, true,
true, '', false, "width: 120px; height: 50px;");
$table->data[18][0] .= html_print_input_hidden('tag_without',
json_encode($tag_without), true);
$table->data[18][1] = html_print_button(__('Remove'), 'remove_whithout', $remove_without_tag_disabled,
'', 'class="delete sub"', true);
$table->data[19][0] = '<b>' . __('Alert events') . '</b>';
$table->data[19][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);
@ -277,4 +353,167 @@ echo '</div>';
echo '</form>';
ui_require_jquery_file ('bgiframe');
?>
ui_require_jquery_file('json');
?>
<script language="javascript" type="text/javascript">
/*<![CDATA[ */
var select_with_tag_empty = <?php echo (int)$remove_with_tag_disabled;?>;
var select_without_tag_empty = <?php echo (int)$remove_without_tag_disabled;?>;
var origin_select_with_tag_empty = <?php echo (int)$add_with_tag_disabled;?>;
var origin_select_without_tag_empty = <?php echo (int)$add_without_tag_disabled;?>;
$(document).ready( function() {
$("#button-add_whith").click(function() {
click_button_add_tag("with");
});
$("#button-add_whithout").click(function() {
click_button_add_tag("without");
});
$("#button-remove_whith").click(function() {
click_button_remove_tag("with");
});
$("#button-remove_whithout").click(function() {
click_button_remove_tag("without");
});
});
function click_button_remove_tag(what_button) {
if (what_button == "with") {
id_select_origin = "#select_with";
id_select_destiny = "#tag_with_temp";
id_button_remove = "#button-remove_whith";
id_button_add = "#button-add_whith";
select_origin_empty = origin_select_with_tag_empty;
}
else { //without
id_select_origin = "#select_without";
id_select_destiny = "#tag_without_temp";
id_button_remove = "#button-remove_whithout";
id_button_add = "#button-add_whithout";
select_origin_empty = origin_select_without_tag_empty;
}
if ($(id_select_destiny + " option:selected").length == 0) {
return; //Do nothing
}
if (select_origin_empty) {
$(id_select_origin + " option").remove();
if (what_button == "with") {
origin_select_with_tag_empty = false;
}
else { //without
origin_select_without_tag_empty = false;
}
$(id_button_add).removeAttr('disabled');
}
//Foreach because maybe the user select several items in
//the select.
jQuery.each($(id_select_destiny + " option:selected"), function(key, element) {
val = $(element).val();
text = $(element).text();
$(id_select_origin).append($("<option value='" + val + "'>" + text + "</option>"));
});
$(id_select_destiny + " option:selected").remove();
if ($(id_select_destiny + " option").length == 0) {
$(id_select_destiny).append($("<option value='" + val_none + "'>" + text_none + "</option>"));
$(id_button_remove).attr('disabled', 'true');
if (what_button == 'with') {
select_with_tag_empty = true;
}
else { //without
select_without_tag_empty = true;
}
}
replace_hidden_tags(what_button);
}
function click_button_add_tag(what_button) {
if (what_button == 'with') {
id_select_origin = "#select_with";
id_select_destiny = "#tag_with_temp";
id_button_remove = "#button-remove_whith";
id_button_add = "#button-add_whith";
select_destiny_empty = select_with_tag_empty;
}
else { //without
id_select_origin = "#select_without";
id_select_destiny = "#tag_without_temp";
id_button_remove = "#button-remove_whithout";
id_button_add = "#button-add_whithout";
select_destiny_empty = select_without_tag_empty;
}
without_val = $(id_select_origin).val();
without_text = $(id_select_origin + " option:selected").text();
if (select_destiny_empty) {
$(id_select_destiny).empty();
if (what_button == 'with') {
select_with_tag_empty = false;
}
else { //without
select_without_tag_empty = false;
}
}
$(id_select_destiny).append($("<option value='" + without_val + "'>" + without_text + "</option>"));
$(id_select_origin + " option:selected").remove();
$(id_button_remove).removeAttr('disabled');
if ($(id_select_origin + " option").length == 0) {
$(id_select_origin).append($("<option value='" + val_none + "'>" + text_none + "</option>"));
$(id_button_add).attr('disabled', 'true');
if (what_button == 'with') {
origin_select_with_tag_empty = true;
}
else { //without
origin_select_without_tag_empty = true;
}
}
replace_hidden_tags(what_button);
}
function replace_hidden_tags(what_button) {
if (what_button == 'with') {
id_select_destiny = "#tag_with_temp";
id_hidden = "#hidden-tag_with";
}
else { //without
id_select_destiny = "#tag_without_temp";
id_hidden = "#hidden-tag_without";
}
value_store = [];
jQuery.each($(id_select_destiny + " option"), function(key, element) {
val = $(element).val();
value_store.push(val);
});
$(id_hidden).val(jQuery.toJSON(value_store));
}
/* ]]> */
</script>

View File

@ -769,7 +769,16 @@ function html_print_input_hidden ($name, $value, $return = false, $class = false
$classText = '';
}
$output = '<input id="hidden-' . $name . '" name="' . $name . '" type="hidden" ' . $classText . ' value="' . $value . '" />';
$separator = '"';
if (strstr($value, '"')) {
$separator = "'";
}
$output = '<input id="hidden-' . $name . '" ' .
'name="' . $name . '" ' .
'type="hidden" ' .
$classText . ' ' .
'value=' . $separator . $value . $separator . ' />';
if ($return)
return $output;

View File

@ -229,7 +229,7 @@ function tags_agent_warning ($id_tag) {
if (empty($id_tag))
return false;
// Agent critical status
$agents_critical = "SELECT tagente.id_agente
FROM tagente_estado, tagente, tagente_modulo
@ -239,8 +239,8 @@ function tags_agent_warning ($id_tag) {
AND tagente_modulo.disabled = 0
AND estado = 1
AND tagente_estado.utimestamp != 0
group by tagente.id_agente";
group by tagente.id_agente";
// Agent warning status
$agents_warning = "SELECT tagente.id_agente
FROM tagente_estado, tagente, tagente_modulo
@ -250,18 +250,17 @@ function tags_agent_warning ($id_tag) {
AND tagente_modulo.disabled = 0
AND estado = 2
AND tagente_estado.utimestamp != 0
group by tagente.id_agente";
group by tagente.id_agente";
return db_get_sql ("SELECT COUNT(*) FROM ( SELECT DISTINCT tagente.id_agente
FROM tagente, tagente_modulo, tagente_estado, ttag_module
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo
AND ttag_module.id_tag = $id_tag
AND tagente.id_agente NOT IN ($agents_critical)
AND tagente.id_agente IN ($agents_warning)) AS t");
}
/**
@ -276,18 +275,24 @@ function tags_agent_warning ($id_tag) {
function tags_search_tag ($tag_name_description = false, $filter = false, $only_names = false) {
global $config;
if ($tag_name_description){
if ($tag_name_description) {
switch ($config["dbtype"]) {
case "mysql":
$sql = 'SELECT * FROM ttag WHERE ((name COLLATE utf8_general_ci LIKE "%'. $tag_name_description .'%") OR
(description COLLATE utf8_general_ci LIKE "%'. $tag_name_description .'%"))';
$sql = 'SELECT *
FROM ttag
WHERE ((name COLLATE utf8_general_ci LIKE "%'. $tag_name_description .'%") OR
(description COLLATE utf8_general_ci LIKE "%'. $tag_name_description .'%"))';
break;
case "postgresql":
$sql = 'SELECT * FROM ttag WHERE ((name COLLATE utf8_general_ci LIKE \'%'. $tag_name_description .'%\') OR
(description COLLATE utf8_general_ci LIKE \'%'. $tag_name_description .'%\'))';
$sql = 'SELECT *
FROM ttag
WHERE ((name COLLATE utf8_general_ci LIKE \'%'. $tag_name_description .'%\') OR
(description COLLATE utf8_general_ci LIKE \'%'. $tag_name_description .'%\'))';
break;
case "oracle":
$sql = 'SELECT * FROM ttag WHERE (UPPER(name) LIKE UPPER (\'%'. $tag_name_description .'%\') OR
$sql = 'SELECT *
FROM ttag
WHERE (UPPER(name) LIKE UPPER (\'%'. $tag_name_description .'%\') OR
UPPER(dbms_lob.substr(description, 4000, 1)) LIKE UPPER (\'%'. $tag_name_description .'%\'))';
break;
}
@ -295,7 +300,7 @@ function tags_search_tag ($tag_name_description = false, $filter = false, $only_
else{
$sql = 'SELECT * FROM ttag';
}
if ($filter !== false){
if ($filter !== false) {
switch ($config["dbtype"]) {
case "mysql":
$result = db_get_all_rows_sql ($sql . ' LIMIT ' . $filter['offset'] . ',' . $filter['limit']);
@ -307,8 +312,8 @@ function tags_search_tag ($tag_name_description = false, $filter = false, $only_
$result = oracle_recode_query ($sql, $filter, 'AND', false);
if ($components != false) {
for ($i=0; $i < count($components); $i++) {
unset($result[$i]['rnum']);
}
unset($result[$i]['rnum']);
}
}
break;
}
@ -316,19 +321,19 @@ function tags_search_tag ($tag_name_description = false, $filter = false, $only_
else {
$result = db_get_all_rows_sql ($sql);
}
if ($result === false)
$result = array();
$result_tags = array();
if ($only_names) {
foreach ($result as $tag){
$result_tags [$tag['id_tag']] = $tag['name'];
$result_tags = array();
foreach ($result as $tag) {
$result_tags[$tag['id_tag']] = $tag['name'];
}
$result = $result_tags;
}
if ($result === false)
return array (); //Return an empty array
else
return $result;
return $result;
}
/**
@ -338,9 +343,9 @@ function tags_search_tag ($tag_name_description = false, $filter = false, $only_
*
* @return mixed Tag id or false.
*/
function tags_create_tag($values){
function tags_create_tag($values) {
if (empty($values)){
return false;
return false;
}
return db_process_sql_insert('ttag',$values);
@ -353,7 +358,7 @@ function tags_create_tag($values){
*
* @return mixed Array with the seleted tag or false.
*/
function tags_search_tag_id($id){
function tags_search_tag_id($id) {
return db_get_row ('ttag', 'id_tag', $id);
}

View File

@ -311,7 +311,6 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) {
}
elseif (! isset ($config['id_user'])) {
// There is no user connected
require_once ('general/login_page.php');
while (@ob_end_flush ());
exit ("</html>");

View File

@ -48,8 +48,9 @@ if (is_ajax()) {
$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']);
$event_filter['tag_with'] = io_safe_output($event_filter['tag_with']);
$event_filter['tag_without'] = io_safe_output($event_filter['tag_without']);
echo json_encode($event_filter);
}
@ -68,7 +69,8 @@ if (is_ajax()) {
$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['tag_with'] = get_parameter('tag_with', json_encode(array()));
$values['tag_without'] = get_parameter('tag_without', json_encode(array()));
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['id_group_filter'] = get_parameter('id_group_filter');
@ -96,7 +98,8 @@ if (is_ajax()) {
$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['tag_with'] = get_parameter('tag_with', json_encode(array()));
$values['tag_without'] = get_parameter('tag_without', json_encode(array()));
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['id_group_filter'] = get_parameter('id_group_filter');
@ -120,11 +123,18 @@ if (is_ajax()) {
return;
}
$tags = tags_search_tag(false, false, true);
// Error div for ajax messages
echo "<div id='show_filter_error'>";
echo "</div>";
$tag = get_parameter("tag", "");
$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();
if ($id_agent == 0) {
$text_agent = (string) get_parameter("text_agent", __("All"));
@ -188,7 +198,7 @@ if ($event_type != "") {
}
if ($severity != -1)
$sql_post .= " AND criticity = ".$severity;
$sql_post .= " AND criticity = " . $severity;
switch ($id_agent) {
case 0:
@ -215,8 +225,25 @@ if ($event_view_hr > 0) {
}
//Search by tag
if ($tag != "") {
$sql_post .= " AND tags LIKE '%".io_safe_input($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
@ -228,13 +255,26 @@ if (isset($filter_only_alert)) {
}
$url = "index.php?sec=eventos&amp;sec2=operation/events/events&amp;search=" .
rawurlencode(io_safe_input($search)) . "&amp;event_type=" . $event_type .
"&amp;severity=" . $severity . "&amp;status=" . $status . "&amp;ev_group=" .
$ev_group . "&amp;refr=" . $config["refr"] . "&amp;id_agent=" .
$id_agent . "&amp;id_event=" . $id_event . "&amp;pagination=" .
$pagination . "&amp;group_rep=" . $group_rep . "&amp;event_view_hr=" .
$event_view_hr . "&amp;id_user_ack=" . $id_user_ack . "&amp;tag=" . $tag . "&amp;filter_only_alert=" . $filter_only_alert . "&amp;offset=" . $offset . "&amp;toogle_filter=no" .
"&amp;filter_id=" . $filter_id . "&amp;id_name=" . $id_name . "&amp;id_group=" . $id_group;
rawurlencode(io_safe_input($search)) .
"&amp;event_type=" . $event_type .
"&amp;severity=" . $severity .
"&amp;status=" . $status .
"&amp;ev_group=" . $ev_group .
"&amp;refr=" . $config["refr"] .
"&amp;id_agent=" . $id_agent .
"&amp;id_event=" . $id_event .
"&amp;pagination=" . $pagination .
"&amp;group_rep=" . $group_rep .
"&amp;event_view_hr=" . $event_view_hr .
"&amp;id_user_ack=" . $id_user_ack .
"&amp;tag_with=" . $tag_with .
"&amp;tag_without=" . $tag_without .
"&amp;filter_only_alert=" . $filter_only_alert .
"&amp;offset=" . $offset .
"&amp;toogle_filter=no" .
"&amp;filter_id=" . $filter_id .
"&amp;id_name=" . $id_name .
"&amp;id_group=" . $id_group;
echo "<br>";
//Link to toggle filter
@ -351,23 +391,88 @@ $repeated_sel[0] = __("All events");
$repeated_sel[1] = __("Group events");
html_print_select ($repeated_sel, "group_rep", $group_rep, '');
echo "</td></tr>";
echo "<tr><td>";
echo __("Tag") . "</td><td>";
//html_print_input_text ('tag', $tag_search, '', 15);
$tags = tags_search_tag();
if($tags === false) {
$tags = array();
echo "<tr>";
echo "<td colspan='2'>" . __('Events with following tags') . "</td>";
echo "<td colspan='2'>" . __('Events without following tags') . "</td>";
echo "</tr>";
echo "<tr>";
$tags_select_with = array();
$tags_select_without = array();
$tag_with_temp = array();
$tag_without_temp = array();
foreach ($tags as $id_tag => $tag) {
if (array_search($id_tag, $tag_with) === false) {
$tags_select_with[$id_tag] = $tag;
}
else {
$tag_with_temp[$id_tag] = $tag;
}
if (array_search($id_tag, $tag_without) === false) {
$tags_select_without[$id_tag] = $tag;
}
else {
$tag_without_temp[$id_tag] = $tag;
}
}
$tags_name = array();
foreach($tags as $t) {
$tags_name[$t['name']] = $t['name'];
}
html_print_select ($tags_name, "tag", $tag, '', __('All'), "");
$add_with_tag_disabled = empty($tags_select_with);
$remove_with_tag_disabled = empty($tag_with_temp);
$add_without_tag_disabled = empty($tags_select_without);
$remove_without_tag_disabled = empty($tag_without_temp);
echo "<td>";
html_print_select ($tags_select_with, 'select_with', '', '', '', 0,
false, false, true, '', false, 'width: 120px;');
echo "</td>";
echo "<td>";
html_print_button(__('Add'), 'add_whith', $add_with_tag_disabled,
'', 'class="add sub"');
echo "</td>";
echo "<td>";
html_print_select ($tags_select_without, 'select_without', '', '', '', 0,
false, false, true, '', false, 'width: 120px;');
echo "</td>";
echo "<td>";
html_print_button(__('Add'), 'add_whithout', $add_without_tag_disabled,
'', 'class="add sub"');
echo "</td>";
echo "</tr>";
echo "<tr>";
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));
echo "</td>";
echo "<td valign='top'>";
html_print_button(__('Remove'), 'remove_whith', $remove_with_tag_disabled,
'', 'class="delete sub"');
echo "</td>";
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));
echo "</td>";
echo "<td valign='top'>";
html_print_button(__('Remove'), 'remove_whithout', $remove_without_tag_disabled,
'', 'class="delete sub"');
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo __("Alert events") . "</td><td>";
@ -643,9 +748,9 @@ foreach ($result as $event) {
}
// Store group data to show in extended view
$data[$i] .= html_print_input_hidden('similar_ids_'.$event["id_evento"], $similar_ids, true);
$data[$i] .= html_print_input_hidden('timestamp_first_'.$event["id_evento"], $timestamp_first, true);
$data[$i] .= html_print_input_hidden('timestamp_last_'.$event["id_evento"], $timestamp_last, true);
$data[$i] .= html_print_input_hidden('similar_ids_' . $event["id_evento"], $similar_ids, true);
$data[$i] .= html_print_input_hidden('timestamp_first_' . $event["id_evento"], $timestamp_first, true);
$data[$i] .= html_print_input_hidden('timestamp_last_' . $event["id_evento"], $timestamp_last, true);
if (empty($event['event_rep'])) {
$event['event_rep'] = 0;
}
@ -919,10 +1024,19 @@ echo '</div>';
unset ($table);
ui_require_jquery_file('json');
?>
<script language="javascript" type="text/javascript">
/*<![CDATA[ */
var select_with_tag_empty = <?php echo (int)$remove_with_tag_disabled;?>;
var select_without_tag_empty = <?php echo (int)$remove_without_tag_disabled;?>;
var origin_select_with_tag_empty = <?php echo (int)$add_with_tag_disabled;?>;
var origin_select_without_tag_empty = <?php echo (int)$add_without_tag_disabled;?>;
var val_none = 0;
var text_none = "<?php echo __('None'); ?>";
$(document).ready( function() {
// Don't collapse filter if update button has been pushed
if ($("#hidden-toogle_filter").val() == 'false'){
@ -988,13 +1102,18 @@ $(document).ready( function() {
$("#id_user_ack").val(val);
if (i == 'group_rep')
$("#group_rep").val(val);
if (i == 'tag')
$("#tag").val(val);
if (i == 'tag_with') {
$("#hidden-tag_with").val(val);
}
if (i == 'tag_without') {
$("#hidden-tag_without").val(val);
}
if (i == 'filter_only_alert')
$("#filter_only_alert").val(val);
if (i == 'id_group_filter')
$("#id_group").val(val);
});
reorder_tags_inputs();
},
"json"
);
@ -1037,7 +1156,8 @@ $(document).ready( function() {
"event_view_hr" : $("#text-event_view_hr").val(),
"id_user_ack" : $("#id_user_ack").val(),
"group_rep" : $("#group_rep").val(),
"tag" : $("#tag").val(),
"tag_with": $("#hidden-tag_with").val(),
"tag_without": $("#hidden-tag_without").val(),
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group").val()
},
@ -1108,7 +1228,8 @@ $(document).ready( function() {
"event_view_hr" : $("#text-event_view_hr").val(),
"id_user_ack" : $("#id_user_ack").val(),
"group_rep" : $("#group_rep").val(),
"tag" : $("#tag").val(),
"tag_with" : $("#hidden-tag_with").val(),
"tag_without" : $("#hidden-tag_without").val(),
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group").val()
},
@ -1184,7 +1305,249 @@ $(document).ready( function() {
});
}
});
$("#button-add_whith").click(function() {
click_button_add_tag("with");
});
$("#button-add_whithout").click(function() {
click_button_add_tag("without");
});
$("#button-remove_whith").click(function() {
click_button_remove_tag("with");
});
$("#button-remove_whithout").click(function() {
click_button_remove_tag("without");
});
});
function click_button_remove_tag(what_button) {
if (what_button == "with") {
id_select_origin = "#select_with";
id_select_destiny = "#tag_with_temp";
id_button_remove = "#button-remove_whith";
id_button_add = "#button-add_whith";
select_origin_empty = origin_select_with_tag_empty;
}
else { //without
id_select_origin = "#select_without";
id_select_destiny = "#tag_without_temp";
id_button_remove = "#button-remove_whithout";
id_button_add = "#button-add_whithout";
select_origin_empty = origin_select_without_tag_empty;
}
if ($(id_select_destiny + " option:selected").length == 0) {
return; //Do nothing
}
if (select_origin_empty) {
$(id_select_origin + " option").remove();
if (what_button == "with") {
origin_select_with_tag_empty = false;
}
else { //without
origin_select_without_tag_empty = false;
}
$(id_button_add).removeAttr('disabled');
}
//Foreach because maybe the user select several items in
//the select.
jQuery.each($(id_select_destiny + " option:selected"), function(key, element) {
val = $(element).val();
text = $(element).text();
$(id_select_origin).append($("<option value='" + val + "'>" + text + "</option>"));
});
$(id_select_destiny + " option:selected").remove();
if ($(id_select_destiny + " option").length == 0) {
$(id_select_destiny).append($("<option value='" + val_none + "'>" + text_none + "</option>"));
$(id_button_remove).attr('disabled', 'true');
if (what_button == 'with') {
select_with_tag_empty = true;
}
else { //without
select_without_tag_empty = true;
}
}
replace_hidden_tags(what_button);
}
function click_button_add_tag(what_button) {
if (what_button == 'with') {
id_select_origin = "#select_with";
id_select_destiny = "#tag_with_temp";
id_button_remove = "#button-remove_whith";
id_button_add = "#button-add_whith";
select_destiny_empty = select_with_tag_empty;
}
else { //without
id_select_origin = "#select_without";
id_select_destiny = "#tag_without_temp";
id_button_remove = "#button-remove_whithout";
id_button_add = "#button-add_whithout";
select_destiny_empty = select_without_tag_empty;
}
without_val = $(id_select_origin).val();
without_text = $(id_select_origin + " option:selected").text();
if (select_destiny_empty) {
$(id_select_destiny).empty();
if (what_button == 'with') {
select_with_tag_empty = false;
}
else { //without
select_without_tag_empty = false;
}
}
$(id_select_destiny).append($("<option value='" + without_val + "'>" + without_text + "</option>"));
$(id_select_origin + " option:selected").remove();
$(id_button_remove).removeAttr('disabled');
if ($(id_select_origin + " option").length == 0) {
$(id_select_origin).append($("<option value='" + val_none + "'>" + text_none + "</option>"));
$(id_button_add).attr('disabled', 'true');
if (what_button == 'with') {
origin_select_with_tag_empty = true;
}
else { //without
origin_select_without_tag_empty = true;
}
}
replace_hidden_tags(what_button);
}
function replace_hidden_tags(what_button) {
if (what_button == 'with') {
id_select_destiny = "#tag_with_temp";
id_hidden = "#hidden-tag_with";
}
else { //without
id_select_destiny = "#tag_without_temp";
id_hidden = "#hidden-tag_without";
}
value_store = [];
jQuery.each($(id_select_destiny + " option"), function(key, element) {
val = $(element).val();
value_store.push(val);
});
$(id_hidden).val(jQuery.toJSON(value_store));
}
function reorder_tags_inputs() {
$('#select_with option[value="' + val_none + '"]').remove();
jQuery.each($("#tag_with_temp option"), function(key, element) {
val = $(element).val();
text = $(element).text();
if (val == val_none)
return;
$("#select_with").append($("<option value='" + val + "'>" + text + "</option>"));
});
$("#tag_with_temp option").remove();
$('#select_without option[value="' + val_none + '"]').remove();
jQuery.each($("#tag_without_temp option"), function(key, element) {
val = $(element).val();
text = $(element).text();
if (val == val_none)
return;
$("#select_without").append($("<option value='" + val + "'>" + text + "</option>"));
});
$("#tag_without_temp option").remove();
tags_json = $("#hidden-tag_with").val();
tags = jQuery.evalJSON(tags_json);
jQuery.each(tags, function(key, element) {
if ($("#select_with option[value='" + element + "']").length == 1) {
text = $("#select_with option[value='" + element + "']").text();
val = $("#select_with option[value='" + element + "']").val();
$("#tag_with_temp").append($("<option value='" + val + "'>" + text + "</option>"));
$("#select_with option[value='" + element + "']").remove();
}
});
if ($("#select_with option").length == 0) {
origin_select_with_tag_empty = true;
$("#button-add_whith").attr('disabled', 'true');
$("#select_with").append($("<option value='" + val_none + "'>" + text_none + "</option>"));
}
else {
origin_select_with_tag_empty = false;
$("#button-add_whith").removeAttr('disabled');
}
if ($("#tag_with_temp option").length == 0) {
select_with_tag_empty = true;
$("#button-remove_whith").attr('disabled', 'true');
$("#tag_with_temp").append($("<option value='" + val_none + "'>" + text_none + "</option>"));
}
else {
select_with_tag_empty = false;
$("#button-remove_whith").removeAttr('disabled');
}
tags_json = $("#hidden-tag_without").val();
tags = jQuery.evalJSON(tags_json);
jQuery.each(tags, function(key, element) {
if ($("#select_without option[value='" + element + "']").length == 1) {
text = $("#select_without option[value='" + element + "']").text();
val = $("#select_without option[value='" + element + "']").val();
$("#tag_without_temp").append($("<option value='" + val + "'>" + text + "</option>"));
$("#select_without option[value='" + element + "']").remove();
}
});
if ($("#select_without option").length == 0) {
origin_select_without_tag_empty = true;
$("#button-add_whithout").attr('disabled', 'true');
$("#select_without").append($("<option value='" + val_none + "'>" + text_none + "</option>"));
}
else {
origin_select_without_tag_empty = false;
$("#button-add_whithout").removeAttr('disabled');
}
if ($("#tag_without_temp option").length == 0) {
select_without_tag_empty = true;
$("#button-remove_whithout").attr('disabled', 'true');
$("#tag_without_temp").append($("<option value='" + val_none + "'>" + text_none + "</option>"));
}
else {
select_without_tag_empty = false;
$("#button-remove_whithout").removeAttr('disabled');
}
}
/* ]]> */
</script>

View File

@ -27,9 +27,9 @@
CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP (oracletime IN DATE DEFAULT SYSDATE) RETURN INTEGER AS unixtime INTEGER; BEGIN unixtime := (oracletime - to_date('19700101','YYYYMMDD')) * 86400; RETURN unixtime; END;;
CREATE OR REPLACE FUNCTION NOW RETURN TIMESTAMP AS t_now TIMESTAMP; BEGIN SELECT LOCALTIMESTAMP INTO t_now FROM dual; RETURN t_now; END;;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `taddress`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE taddress (
id_a NUMBER(10, 0) NOT NULL PRIMARY KEY,
ip VARCHAR(60) default '',
@ -51,9 +51,9 @@ CREATE TABLE taddress_agent (
CREATE SEQUENCE taddress_agent_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER taddress_agent_inc BEFORE INSERT ON taddress_agent REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT taddress_agent_s.nextval INTO :NEW.ID_AG FROM dual; END;;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tagente`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE tagente (
id_agente NUMBER(10, 0) NOT NULL PRIMARY KEY,
nombre VARCHAR2(600) default '',
@ -515,6 +515,9 @@ CREATE TABLE talert_special_days (
CREATE SEQUENCE talert_special_days_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER talert_special_days_inc BEFORE INSERT ON talert_special_days REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT talert_special_days_s.nextval INTO :NEW.ID FROM dual; END talert_special_days_inc;;
-- ---------------------------------------------------------------------
-- Table `tattachment`
-- ---------------------------------------------------------------------
-- Priority : 0 - Maintance (grey)
-- Priority : 1 - Low (green)
-- Priority : 2 - Normal (blue)
@ -530,19 +533,22 @@ CREATE TABLE tattachment (
);
CREATE SEQUENCE tattachment_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tattachment_inc BEFORE INSERT ON tattachment REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tattachment_s.nextval INTO :NEW.ID_ATTACHMENT FROM dual; END;;
-- ---------------------------------------------------------------------
-- Table `tconfig`
-- ---------------------------------------------------------------------
CREATE TABLE tconfig (
id_config NUMBER(10, 0) NOT NULL PRIMARY KEY,
token VARCHAR2(100) default '',
value VARCHAR2(255) default ''
);
CREATE SEQUENCE tconfig_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tconfig_inc BEFORE INSERT ON tconfig REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tconfig_s.nextval INTO :NEW.ID_CONFIG FROM dual; END;;
-- ---------------------------------------------------------------------
-- Table `tconfig_os`
-- ---------------------------------------------------------------------
CREATE TABLE tconfig_os (
id_os NUMBER(10, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(100) default '',
@ -550,6 +556,9 @@ CREATE TABLE tconfig_os (
icon_name VARCHAR2(100) default ''
);
-- ---------------------------------------------------------------------
-- Table `tevento`
-- ---------------------------------------------------------------------
-- use to_char(timestamp, 'hh24:mi:ss') function to retrieve timestamp field info
CREATE TABLE tevento (
id_evento NUMBER(19, 0) NOT NULL PRIMARY KEY,
@ -557,7 +566,7 @@ CREATE TABLE tevento (
id_usuario VARCHAR2(100) default '0' NOT NULL,
id_grupo NUMBER(10, 0) default 0 NOT NULL,
estado NUMBER(10, 0) default 0 NOT NULL,
timestamp TIMESTAMP default NULL,
timestamp TIMESTAMP default NULL,
evento CLOB default '',
utimestamp NUMBER(19, 0) default 0 NOT NULL,
event_type VARCHAR2(50) default 'unknown',
@ -583,6 +592,9 @@ CREATE SEQUENCE tevento_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tevento_inc BEFORE INSERT ON tevento REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tevento_s.nextval INTO :NEW.ID_EVENTO FROM dual; END;;
-- ---------------------------------------------------------------------
-- Table `tgrupo`
-- ---------------------------------------------------------------------
-- Criticity: 0 - Maintance (grey)
-- Criticity: 1 - Informational (blue)
-- Criticity: 2 - Normal (green) (status 0)
@ -606,6 +618,9 @@ CREATE SEQUENCE tgrupo_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tgrupo_inc BEFORE INSERT ON tgrupo REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tgrupo_s.nextval INTO :NEW.ID_GRUPO FROM dual; END;;
-- ---------------------------------------------------------------------
-- Table `tincidencia`
-- ---------------------------------------------------------------------
CREATE TABLE tincidencia (
id_incidencia NUMBER(19, 0) NOT NULL PRIMARY KEY,
inicio TIMESTAMP default NULL,
@ -634,11 +649,17 @@ CREATE SEQUENCE tincidencia_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tincidencia_inc BEFORE INSERT ON tincidencia REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tincidencia_s.nextval INTO :NEW.ID_INCIDENCIA FROM dual; END;;
-- ---------------------------------------------------------------------
-- Table `tlanguage`
-- ---------------------------------------------------------------------
CREATE TABLE tlanguage (
id_language VARCHAR2(6) default '',
name VARCHAR2(100) default ''
);
-- ---------------------------------------------------------------------
-- Table `tlink`
-- ---------------------------------------------------------------------
CREATE TABLE tlink (
id_link NUMBER(10, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(100) default '',
@ -649,6 +670,9 @@ CREATE SEQUENCE tlink_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tlink_inc BEFORE INSERT ON tlink REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tlink_s.nextval INTO :NEW.ID_LINK FROM dual; END;;
-- ---------------------------------------------------------------------
-- Table `tmensajes`
-- ---------------------------------------------------------------------
CREATE TABLE tmensajes (
id_mensaje NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_usuario_origen VARCHAR2(60) default '',
@ -663,6 +687,9 @@ CREATE SEQUENCE tmensajes_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tmensajes_inc BEFORE INSERT ON tmensajes REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tmensajes_s.nextval INTO :NEW.ID_MENSAJE FROM dual; END;;
-- ---------------------------------------------------------------------
-- Table `tmodule_group`
-- ---------------------------------------------------------------------
CREATE TABLE tmodule_group (
id_mg NUMBER(10, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(150) default ''
@ -1682,42 +1709,43 @@ 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_group_filter NUMBER(10, 0) default 0 NOT NULL,
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
id_filter NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_group_filter NUMBER(10, 0) default 0 NOT NULL,
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_with CLOB,
tag_without CLOB,
filter_only_alert NUMBER(10, 0) default -1 NOT NULL
);
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tpassword_history`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS tpassword_history (
id_pass NUMBER(10) NOT NULL PRIMARY KEY,
id_user varchar2(60) NOT NULL,
password varchar2(45) default '',
date_begin TIMESTAMP DEFAULT 0,
date_end TIMESTAMP DEFAULT 0
id_pass NUMBER(10) NOT NULL PRIMARY KEY,
id_user varchar2(60) NOT NULL,
password varchar2(45) default '',
date_begin TIMESTAMP DEFAULT 0,
date_end TIMESTAMP DEFAULT 0
);
CREATE SEQUENCE tpassword_history_s INCREMENT BY 1 START WITH 1;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tevent_response`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS tevent_response (
id NUMBER(10) NOT NULL PRIMARY KEY,
name varchar2(600) NOT NULL default '',

View File

@ -30,9 +30,9 @@ CREATE OR REPLACE LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION unix_timestamp(TIMESTAMP without time zone = CURRENT_TIMESTAMP) RETURNS double precision AS 'SELECT ceil(date_part(''epoch'', $1)); ' LANGUAGE SQL;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `taddress`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE "taddress" (
"id_a" SERIAL NOT NULL PRIMARY KEY,
"ip" VARCHAR(60) NOT NULL default '',
@ -40,9 +40,9 @@ CREATE TABLE "taddress" (
);
CREATE INDEX "taddress_ip_idx" ON "taddress"("ip");
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `taddress_agent`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE "taddress_agent" (
"id_ag" BIGSERIAL NOT NULL PRIMARY KEY,
"id_a" BIGINT NOT NULL default 0,
@ -130,9 +130,9 @@ CREATE TABLE "tagente_datos_log4x" (
);
CREATE INDEX "tagente_datos_log4x_id_agente_modulo_idx" ON "tagente_datos_log4x"("id_agente_modulo");
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tagente_estado`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE "tagente_estado" (
"id_agente_estado" SERIAL NOT NULL PRIMARY KEY,
"id_agente_modulo" INTEGER NOT NULL default 0,
@ -451,6 +451,9 @@ CREATE TABLE "tconfig_os" (
"icon_name" varchar(100) default ''
);
-- ---------------------------------------------------------------------
-- Table `tevento`
-- ---------------------------------------------------------------------
CREATE TYPE type_tevento_event AS ENUM ('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change');
CREATE TABLE "tevento" (
"id_evento" BIGSERIAL NOT NULL PRIMARY KEY,
@ -479,6 +482,9 @@ CREATE INDEX "tevento_id_1_idx" ON "tevento"("id_agente", "id_evento");
CREATE INDEX "tevento_id_2_idx" ON "tevento"("utimestamp", "id_evento");
CREATE INDEX "tevento_id_agentmodule_idx" ON "tevento"("id_agentmodule");
-- ---------------------------------------------------------------------
-- Table `tgrupo`
-- ---------------------------------------------------------------------
-- Criticity: 0 - Maintance (grey)
-- Criticity: 1 - Informational (blue)
-- Criticity: 2 - Normal (green) (status 0)
@ -498,6 +504,9 @@ CREATE TABLE "tgrupo" (
"other" text
);
-- ---------------------------------------------------------------------
-- Table `tincidencia`
-- ---------------------------------------------------------------------
CREATE TABLE "tincidencia" (
"id_incidencia" BIGSERIAL NOT NULL PRIMARY KEY,
"inicio" TIMESTAMP without time zone default '1970-01-01 00:00:00',
@ -523,17 +532,26 @@ CREATE INDEX "tincidencia_id_agente_modulo_idx" ON "tincidencia"("id_agente_modu
CREATE OR REPLACE FUNCTION update_tincidencia_actualizacion() RETURNS TRIGGER AS $$ BEGIN NEW.actualizacion = now(); RETURN NEW; END; $$ language 'plpgsql';
CREATE TRIGGER trigger_tincidencia_actualizacion BEFORE UPDATE ON tincidencia FOR EACH ROW EXECUTE PROCEDURE update_tincidencia_actualizacion();
-- ---------------------------------------------------------------------
-- Table `tlanguage`
-- ---------------------------------------------------------------------
CREATE TABLE "tlanguage" (
"id_language" varchar(6) NOT NULL default '',
"name" varchar(100) NOT NULL default ''
);
-- ---------------------------------------------------------------------
-- Table `tlink`
-- ---------------------------------------------------------------------
CREATE TABLE "tlink" (
"id_link" SERIAL NOT NULL PRIMARY KEY,
"name" varchar(100) NOT NULL default '',
"link" varchar(255) NOT NULL default ''
);
-- ---------------------------------------------------------------------
-- Table `tmensajes`
-- ---------------------------------------------------------------------
CREATE TABLE "tmensajes" (
"id_mensaje" SERIAL NOT NULL PRIMARY KEY,
"id_usuario_origen" varchar(60) NOT NULL default '',
@ -544,11 +562,17 @@ CREATE TABLE "tmensajes" (
"estado" INTEGER NOT NULL default 0
);
-- ---------------------------------------------------------------------
-- Table `tmodule_group`
-- ---------------------------------------------------------------------
CREATE TABLE "tmodule_group" (
"id_mg" SERIAL NOT NULL PRIMARY KEY,
"name" varchar(150) NOT NULL default ''
);
-- ---------------------------------------------------------------------
-- Table `tnetwork_component`
-- ---------------------------------------------------------------------
CREATE TYPE type_tlocal_component_wizard_level AS ENUM ('basic','advanced','custom','nowizard');
CREATE TABLE "tnetwork_component" (
"id_nc" SERIAL NOT NULL PRIMARY KEY,
@ -597,24 +621,36 @@ CREATE TABLE "tnetwork_component" (
"warning_inverse" SMALLINT NOT NULL default 0
);
-- ---------------------------------------------------------------------
-- Table `tnetwork_component_group`
-- ---------------------------------------------------------------------
CREATE TABLE "tnetwork_component_group" (
"id_sg" SERIAL NOT NULL PRIMARY KEY,
"name" varchar(200) NOT NULL default '',
"parent" BIGINT NOT NULL default 0
);
-- ---------------------------------------------------------------------
-- Table `tnetwork_profile`
-- ---------------------------------------------------------------------
CREATE TABLE "tnetwork_profile" (
"id_np" SERIAL NOT NULL PRIMARY KEY,
"name" varchar(100) NOT NULL default '',
"description" varchar(250) default ''
);
-- ---------------------------------------------------------------------
-- Table `tnetwork_profile_component`
-- ---------------------------------------------------------------------
CREATE TABLE "tnetwork_profile_component" (
"id_nc" BIGINT NOT NULL default 0,
"id_np" BIGINT NOT NULL default 0
);
CREATE INDEX "tnetwork_profile_id_np_idx" ON "tnetwork_profile_component"("id_np");
-- ---------------------------------------------------------------------
-- Table `tnota`
-- ---------------------------------------------------------------------
CREATE TABLE "tnota" (
"id_nota" BIGSERIAL NOT NULL PRIMARY KEY,
"id_incident" BIGINT NOT NULL,
@ -624,10 +660,16 @@ CREATE TABLE "tnota" (
);
CREATE INDEX "tnota_id_incident_idx" ON "tnota"("id_incident");
-- ---------------------------------------------------------------------
-- Table `torigen`
-- ---------------------------------------------------------------------
CREATE TABLE "torigen" (
"origen" varchar(100) NOT NULL default ''
);
-- ---------------------------------------------------------------------
-- Table `tperfil`
-- ---------------------------------------------------------------------
CREATE TABLE "tperfil" (
"id_perfil" SERIAL NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL default '',
@ -643,6 +685,9 @@ CREATE TABLE "tperfil" (
"pandora_management" SMALLINT NOT NULL default 0
);
-- ---------------------------------------------------------------------
-- Table `trecon_script`
-- ---------------------------------------------------------------------
CREATE TABLE "trecon_script" (
"id_recon_script" SERIAL NOT NULL PRIMARY KEY,
"name" varchar(100) default '',
@ -650,6 +695,9 @@ CREATE TABLE "trecon_script" (
"script" varchar(250) default ''
);
-- ---------------------------------------------------------------------
-- Table `trecon_task`
-- ---------------------------------------------------------------------
CREATE TABLE "trecon_task" (
"id_rt" SERIAL NOT NULL PRIMARY KEY,
"name" varchar(100) NOT NULL default '',
@ -1422,36 +1470,37 @@ CREATE TABLE "tnetflow_report_content" (
"order" INTEGER NOT NULL default 0
);
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tevent_filter`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE "tevent_filter" (
"id_filter" SERIAL NOT NULL PRIMARY KEY,
"id_group_filter" INTEGER NOT NULL default 0,
"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
"id_filter" SERIAL NOT NULL PRIMARY KEY,
"id_group_filter" INTEGER NOT NULL default 0,
"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_with" text NOT NULL,
"tag_without" text NOT NULL,
"filter_only_alert" INTEGER NOT NULL default -1
);
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tpassword_history`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE "tpassword_history" (
"id_pass" INTEGER NOT NULL PRIMARY KEY,
"id_user" varchar(60) NOT NULL,
"password" varchar(45) default NULL,
"date_begin" BIGINT NOT NULL default 0,
"date_end" BIGINT NOT NULL default 0,
"id_pass" INTEGER NOT NULL PRIMARY KEY,
"id_user" varchar(60) NOT NULL,
"password" varchar(45) default NULL,
"date_begin" BIGINT NOT NULL default 0,
"date_end" BIGINT NOT NULL default 0,
);
-- -----------------------------------------------------

View File

@ -527,9 +527,9 @@ CREATE TABLE IF NOT EXISTS `tconfig_os` (
PRIMARY KEY (`id_os`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tevento`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tevento` (
`id_evento` bigint(20) unsigned NOT NULL auto_increment,
`id_agente` int(10) NOT NULL default '0',
@ -564,9 +564,9 @@ CREATE TABLE IF NOT EXISTS `tevento` (
-- Criticity: 3 - Warning (yellow) (status 2)
-- Criticity: 4 - Critical (red) (status 1)
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tgrupo`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tgrupo` (
`id_grupo` mediumint(4) unsigned NOT NULL auto_increment,
`nombre` varchar(100) NOT NULL default '',
@ -582,9 +582,9 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
PRIMARY KEY (`id_grupo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tincidencia`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tincidencia` (
`id_incidencia` bigint(6) unsigned zerofill NOT NULL auto_increment,
`inicio` datetime NOT NULL default '1970-01-01 00:00:00',
@ -607,9 +607,9 @@ CREATE TABLE IF NOT EXISTS `tincidencia` (
KEY `id_agente_modulo` (`id_agente_modulo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tlanguage`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tlanguage` (
`id_language` varchar(6) NOT NULL default '',
`name` varchar(100) NOT NULL default '',
@ -1604,7 +1604,6 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
-- ---------------------------------------------------------------------
-- Table `tevent_filter`
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tevent_filter` (
`id_filter` int(10) unsigned NOT NULL auto_increment,
`id_group_filter` int(10) NOT NULL default 0,
@ -1619,14 +1618,15 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
`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 '',
`tag_with` text NOT NULL,
`tag_without` text NOT NULL,
`filter_only_alert` int(10) NOT NULL default -1,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
-- Table `tpassword_history`
-- -----------------------------------------------------
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tpassword_history` (
`id_pass` int(10) unsigned NOT NULL auto_increment,
`id_user` varchar(60) NOT NULL,