2012-08-20 Miguel de Dios <miguel.dedios@artica.es>

* godmode/reporting/reporting_builder.main.php,
	godmode/reporting/reporting_builder.php,
	include/functions_reports.php, pandoradb.sql,
	pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
	operation/reporting/reporting_xml.php,
	operation/reporting/reporting_viewer.php,
	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: now the reports
	can set the group can edit or private edition.
	
	* include/functions_users.php: cleaned source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6889 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-08-20 13:12:53 +00:00
parent 9c42aaad7d
commit 5c42c87962
13 changed files with 378 additions and 175 deletions

View File

@ -1,3 +1,18 @@
2012-08-20 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/reporting_builder.main.php,
godmode/reporting/reporting_builder.php,
include/functions_reports.php, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
operation/reporting/reporting_xml.php,
operation/reporting/reporting_viewer.php,
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: now the reports
can set the group can edit or private edition.
* include/functions_users.php: cleaned source code style.
2012-08-20 Sergio Martin <sergio.martin@artica.es> 2012-08-20 Sergio Martin <sergio.martin@artica.es>
* pandoradb_data.sql * pandoradb_data.sql

View File

@ -169,6 +169,7 @@ ALTER TABLE treport_content_item ADD FOREIGN KEY (`id_report_content`) REFERENCE
-- Table `treport` -- Table `treport`
-- ----------------------------------------------------- -- -----------------------------------------------------
ALTER TABLE treport ADD COLUMN `id_template` INTEGER UNSIGNED DEFAULT 0; ALTER TABLE treport ADD COLUMN `id_template` INTEGER UNSIGNED DEFAULT 0;
ALTER TABLE treport ADD COLUMN `id_group_edit` mediumint(8) unsigned NULL DEFAULT 0;
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `tgraph` -- Table `tgraph`

View File

@ -158,6 +158,7 @@ ALTER TABLE treport_content_item ADD FOREIGN KEY (id_report_content) REFERENCES
-- Table `treport` -- Table `treport`
-- ----------------------------------------------------- -- -----------------------------------------------------
ALTER TABLE treport ADD (id_template NUMBER(10, 0) default 0 NOT NULL); ALTER TABLE treport ADD (id_template NUMBER(10, 0) default 0 NOT NULL);
ALTER TABLE treport ADD (id_group_edit NUMBER(19, 0) default 0 NOT NULL);
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `tgraph` -- Table `tgraph`

View File

@ -150,6 +150,7 @@ INSERT INTO "tconfig" ("token", "value") VALUES ('event_fields', 'evento,id_agen
-- Table `treport` -- Table `treport`
-- ----------------------------------------------------- -- -----------------------------------------------------
ALTER TABLE "treport" ADD COLUMN "id_template" INTEGER NOT NULL default 0; ALTER TABLE "treport" ADD COLUMN "id_template" INTEGER NOT NULL default 0;
ALTER TABLE "treport" ADD COLUMN "id_group_edit" BIGINT NOT NULL default 0;
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `tgraph` -- Table `tgraph`

View File

@ -29,12 +29,14 @@ $groups = users_get_groups ();
switch ($action) { switch ($action) {
case 'new': case 'new':
$actionButtonHtml = html_print_submit_button(__('Save'), 'add', false, 'class="sub wand"', true); $actionButtonHtml = html_print_submit_button(__('Save'),
'add', false, 'class="sub wand"', true);
$hiddenFieldAction = 'save'; $hiddenFieldAction = 'save';
break; break;
case 'update': case 'update':
case 'edit': case 'edit':
$actionButtonHtml = html_print_submit_button(__('Update'), 'edit', false, 'class="sub upd"', true); $actionButtonHtml = html_print_submit_button(__('Update'),
'edit', false, 'class="sub upd"', true);
$hiddenFieldAction = 'update'; $hiddenFieldAction = 'update';
break; break;
} }
@ -46,12 +48,13 @@ $table->head = array ();
$table->data = array (); $table->data = array ();
$table->size = array (); $table->size = array ();
$table->size = array (); $table->size = array ();
$table->size[0] = '10%'; $table->size[0] = '15%';
$table->size[1] = '90%'; $table->size[1] = '90%';
$table->style[0] = 'font-weight: bold; vertical-align: top;'; $table->style[0] = 'font-weight: bold; vertical-align: top;';
$table->data['name'][0] = __('Name'); $table->data['name'][0] = __('Name');
$table->data['name'][1] = html_print_input_text('name', $reportName, __('Name'), 80, 100, true); $table->data['name'][1] = html_print_input_text('name', $reportName,
__('Name'), 80, 100, true);
$table->data['group'][0] = __('Group'); $table->data['group'][0] = __('Group');
$own_info = get_user_info ($config['id_user']); $own_info = get_user_info ($config['id_user']);
@ -61,6 +64,29 @@ else
$return_all_groups = false; $return_all_groups = false;
$table->data['group'][1] = html_print_select_groups(false, "AR", $return_all_groups, 'id_group', $idGroupReport, false, '', '', true); $table->data['group'][1] = html_print_select_groups(false, "AR", $return_all_groups, 'id_group', $idGroupReport, false, '', '', true);
if ($report_id_user == $config['id_user'] ||
is_user_admin ($config["id_user"])) {
//S/he is the creator of report (or admin) and s/he can change the access.
$type_access = array('group_view' => __('Only the group can view the report'),
'group_edit' => __('The next group can edit the report'),
'user_edit' => __('Only the user and admin user can edit the report')
);
$table->data['access'][0] = __('Write Access') .
ui_print_help_tip(__('For example, you want a report that the people of "All" groups can see but you want to edit only for you or your group.'), true);
$table->data['access'][1] = html_print_select ($type_access, 'type_access',
$type_access_selected, 'change_type_access(this)', '', 0, true);
$style = "display: none;";
if ($type_access_selected == 'group_edit')
$style = "";
$table->data['access'][1] .= '<span style="' . $style . '" class="access_subform" id="group_edit">
' .
html_print_select_groups(false, "AR", false,
'id_group_edit', $id_group_edit, false, '', '', true) . '
</span>';
}
$table->data['description'][0] = __('Description'); $table->data['description'][0] = __('Description');
$table->data['description'][1] = html_print_textarea('description', 5, 15, $description, '', true); $table->data['description'][1] = html_print_textarea('description', 5, 15, $description, '', true);
@ -73,3 +99,17 @@ html_print_input_hidden('action', $hiddenFieldAction);
html_print_input_hidden('id_report', $idReport); html_print_input_hidden('id_report', $idReport);
echo '</div></form>'; echo '</div></form>';
?> ?>
<script type="text/javascript">
function change_type_access(select_item) {
$(".access_subform").hide();
switch ($(select_item).val()) {
case 'group_view':
break;
case 'group_edit':
$("#group_edit").show();
break;
case 'user_edit':
break;
}
}
</script>

View File

@ -42,6 +42,32 @@ $idReport = get_parameter('id_report', 0);
$offset = get_parameter('offset', 0); $offset = get_parameter('offset', 0);
$idItem = get_parameter('id_item', 0); $idItem = get_parameter('id_item', 0);
//Other Checks for the edit the reports
if ($idReport != 0) {
$report = db_get_row_filter('treport', array('id_report' => $idReport));
$type_access_selected = reports_get_type_access($report);
$edit = false;
switch ($type_access_selected) {
case 'group_view':
$edit = check_acl($config['id_user'], $report['id_group'], "IW");
break;
case 'group_edit':
$edit = check_acl($config['id_user'], $report['id_group_edit'], "IW");
break;
case 'user_edit':
if ($config['id_user'] == $report['id_user'] ||
is_user_admin ($config["id_user"]))
$edit = true;
break;
}
if (! $edit) {
db_pandora_audit("ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
}
switch ($action) { switch ($action) {
case 'sort_items': case 'sort_items':
switch ($activeTab) { switch ($activeTab) {
@ -325,7 +351,6 @@ switch ($action) {
} }
foreach ($reports as $report) { foreach ($reports as $report) {
if (!is_user_admin ($config["id_user"])){ if (!is_user_admin ($config["id_user"])){
if ($report["private"] && $report["id_user"] != $config['id_user']) if ($report["private"] && $report["id_user"] != $config['id_user'])
if (!check_acl ($config["id_user"], $report["id_group"], "AR")) if (!check_acl ($config["id_user"], $report["id_group"], "AR"))
@ -371,17 +396,35 @@ switch ($action) {
$data[$next] = ui_print_group_icon($report['id_group'], true); $data[$next] = ui_print_group_icon($report['id_group'], true);
$next++; $next++;
$data[$next] = '<form method="post" action="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&action=edit" style="display:inline">'; $type_access_selected = reports_get_type_access($report);
$data[$next] .= html_print_input_hidden ('id_report', $report['id_report'], true); $edit = false;
$data[$next] .= html_print_input_image ('edit', 'images/config.png', 1, '', true, array ('title' => __('Edit'))); switch ($type_access_selected) {
$data[$next] .= '</form>'; case 'group_view':
$edit = check_acl($config['id_user'], $report['id_group'], "IW");
break;
case 'group_edit':
$edit = check_acl($config['id_user'], $report['id_group_edit'], "IW");
break;
case 'user_edit':
if ($config['id_user'] == $report['id_user'] ||
is_user_admin ($config["id_user"]))
$edit = true;
break;
}
$data[$next] .= '&nbsp;&nbsp;<form method="post" style="display:inline" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">'; if ($edit) {
$data[$next] .= html_print_input_hidden ('id_report', $report['id_report'], true); $data[$next] = '<form method="post" action="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&action=edit" style="display:inline">';
$data[$next] .= html_print_input_hidden ('action','delete_report', true); $data[$next] .= html_print_input_hidden ('id_report', $report['id_report'], true);
$data[$next] .= html_print_input_image ('delete', 'images/cross.png', 1, '', $data[$next] .= html_print_input_image ('edit', 'images/config.png', 1, '', true, array ('title' => __('Edit')));
true, array ('title' => __('Delete'))); $data[$next] .= '</form>';
$data[$next] .= '</form>';
$data[$next] .= '&nbsp;&nbsp;<form method="post" style="display:inline" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
$data[$next] .= html_print_input_hidden ('id_report', $report['id_report'], true);
$data[$next] .= html_print_input_hidden ('action','delete_report', true);
$data[$next] .= html_print_input_image ('delete', 'images/cross.png', 1, '',
true, array ('title' => __('Delete')));
$data[$next] .= '</form>';
}
} }
array_push ($table->data, $data); array_push ($table->data, $data);
@ -410,6 +453,9 @@ switch ($action) {
$idGroupReport = 0; //All groups $idGroupReport = 0; //All groups
$description = ''; $description = '';
$resultOperationDB = null; $resultOperationDB = null;
$report_id_user = 0;
$type_access_selected = reports_get_type_access(false);
$id_group_edit = 0;
break; break;
case 'item_editor': case 'item_editor':
$resultOperationDB = null; $resultOperationDB = null;
@ -428,10 +474,45 @@ switch ($action) {
$reportName = get_parameter('name'); $reportName = get_parameter('name');
$idGroupReport = get_parameter('id_group'); $idGroupReport = get_parameter('id_group');
$description = get_parameter('description'); $description = get_parameter('description');
$type_access_selected = get_parameter('type_access', 'group_view');
$id_group_edit_param = (int)get_parameter('id_group_edit', 0);
switch ($type_access_selected) {
case 'group_view':
$id_group_edit = 0;
$private = 0;
break;
case 'group_edit':
$id_group_edit = $id_group_edit_param;
$private = 0;
break;
case 'user_edit':
$id_group_edit = 0;
$private = 1;
break;
}
if ($action == 'update') { if ($action == 'update') {
if ($reportName != "" && $idGroupReport != ""){ if ($reportName != "" && $idGroupReport != "") {
$resultOperationDB = (bool)db_process_sql_update('treport', array('name' => $reportName, 'id_group' => $idGroupReport, 'description' => $description), array('id_report' => $idReport)); $new_values = array('name' => $reportName,
'id_group' => $idGroupReport,
'description' => $description,
'private' => $private,
'id_group_edit' => $id_group_edit);
$report = db_get_row_filter('treport',
array('id_report' => $idReport));
$report_id_user = $report['id_user'];
if ($report_id_user != $config['id_user'] &&
is_user_admin ($config["id_user"])) {
unset($new_values['private']);
unset($new_values['id_group_edit']);
}
$resultOperationDB = (bool)db_process_sql_update(
'treport', $new_values,
array('id_report' => $idReport));
if ($resultOperationDB !== false) if ($resultOperationDB !== false)
db_pandora_audit( "Report management", "Update report #$idReport"); db_pandora_audit( "Report management", "Update report #$idReport");
else else
@ -442,8 +523,14 @@ switch ($action) {
} }
} }
else if ($action == 'save') { else if ($action == 'save') {
if($reportName != "" && $idGroupReport != "") { if ($reportName != "" && $idGroupReport != "") {
$idOrResult = db_process_sql_insert('treport', array('name' => $reportName, 'id_group' => $idGroupReport, 'description' => $description)); $idOrResult = db_process_sql_insert('treport',
array('name' => $reportName,
'id_group' => $idGroupReport,
'description' => $description,
'private' => $private,
'id_group_edit' => $id_group_edit,
'id_user' => $config['id_user']));
if ($idOrResult !== false) if ($idOrResult !== false)
db_pandora_audit( "Report management", "Create report #$idOrResult"); db_pandora_audit( "Report management", "Create report #$idOrResult");
else else
@ -459,6 +546,7 @@ switch ($action) {
else { else {
$resultOperationDB = true; $resultOperationDB = true;
$idReport = $idOrResult; $idReport = $idOrResult;
$report_id_user = $config['id_user'];
} }
} }
$action = 'edit'; $action = 'edit';
@ -599,7 +687,6 @@ switch ($action) {
$agent_name = substr($agent_name_server, 0, $separator_pos); $agent_name = substr($agent_name_server, 0, $separator_pos);
} }
} }
} }
@ -780,11 +867,11 @@ switch ($action) {
$style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0);
$values['style'] = io_safe_input(json_encode($style)); $values['style'] = io_safe_input(json_encode($style));
if ($good_format){ if ($good_format) {
$result = db_process_sql_insert('treport_content', $values); $result = db_process_sql_insert('treport_content', $values);
if ($result === false) { if ($result === false) {
$resultOperationDB = false; $resultOperationDB = false;
} }
else { else {
$idItem = $result; $idItem = $result;
@ -835,11 +922,15 @@ switch ($action) {
case 'filter': case 'filter':
case 'edit': case 'edit':
$resultOperationDB = null; $resultOperationDB = null;
$report = db_get_row_filter('treport', array('id_report' => $idReport)); $report = db_get_row_filter('treport',
array('id_report' => $idReport));
$reportName = $report['name']; $reportName = $report['name'];
$idGroupReport = $report['id_group']; $idGroupReport = $report['id_group'];
$description = $report['description']; $description = $report['description'];
$type_access_selected = reports_get_type_access($report);
$id_group_edit = $report['id_group_edit'];
$report_id_user = $report['id_user'];
break; break;
case 'delete': case 'delete':
$idItem = get_parameter('id_item'); $idItem = get_parameter('id_item');

View File

@ -21,6 +21,20 @@
require_once ($config['homedir'].'/include/functions_users.php'); require_once ($config['homedir'].'/include/functions_users.php');
function reports_get_type_access($report) {
if (empty($report)) {
return 'group_view';
}
if ($report['private']) {
return 'user_edit';
}
else if ($report['id_group_edit'] != 0) {
return 'group_edit';
}
return 'group_view';
}
/** /**
* Get a custom user report. * Get a custom user report.
* *
@ -73,12 +87,15 @@ function reports_get_reports ($filter = false, $fields = false, $returnAllGroup
if (! is_array ($filter)) if (! is_array ($filter))
$filter = array (); $filter = array ();
/*
if (!is_user_admin ($config["id_user"])) if (!is_user_admin ($config["id_user"]))
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")', $filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")',
$config['id_user']); $config['id_user']);
*/
if (is_array ($fields)) { if (is_array ($fields)) {
$fields[] = 'id_group'; $fields[] = 'id_group';
$fields[] = 'id_user'; $fields[] = 'id_user';
$fields[] = 'id_group_edit';
} }
$reports = array (); $reports = array ();

View File

@ -43,8 +43,8 @@ require_once ('include/functions_groups.php');
enterprise_include("include/functions_reporting.php"); enterprise_include("include/functions_reporting.php");
// Check if the report is a private report. if ($report['id_group'] != 0 &&
if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! is_user_admin ($config['id_user']))) { !is_user_admin ($config['id_user'])) {
include ("general/noaccess.php"); include ("general/noaccess.php");
return; return;
} }

View File

@ -129,8 +129,9 @@ if (! check_acl ($config['id_user'], $report['id_group'], "AR")) {
exit; exit;
} }
/* Check if the user can see the graph */ if ($report['id_group'] != 0 &&
if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! is_user_admin($config['id_user']))) { !is_user_admin ($config['id_user'])) {
include ("general/noaccess.php");
return; return;
} }

View File

@ -960,7 +960,8 @@ CREATE TABLE treport (
first_page CLOB default NULL, first_page CLOB default NULL,
footer CLOB default NULL, footer CLOB default NULL,
custom_font VARCHAR2(200) default NULL, custom_font VARCHAR2(200) default NULL,
id_template NUMBER(10, 0) default 0 NOT NULL id_template NUMBER(10, 0) default 0 NOT NULL,
id_group_edit NUMBER(19, 0) default 0 NOT NULL
); );
CREATE SEQUENCE treport_s INCREMENT BY 1 START WITH 1; CREATE SEQUENCE treport_s INCREMENT BY 1 START WITH 1;

View File

@ -762,6 +762,9 @@ CREATE TABLE "tgraph_source" (
"weight" DOUBLE PRECISION default 0 "weight" DOUBLE PRECISION default 0
); );
-- -----------------------------------------------------
-- Table "treport"
-- -----------------------------------------------------
CREATE TABLE "treport" ( CREATE TABLE "treport" (
"id_report" SERIAL NOT NULL PRIMARY KEY, "id_report" SERIAL NOT NULL PRIMARY KEY,
"id_user" varchar(100) NOT NULL default '', "id_user" varchar(100) NOT NULL default '',
@ -774,7 +777,8 @@ CREATE TABLE "treport" (
"first_page" TEXT default NULL, "first_page" TEXT default NULL,
"footer" TEXT default NULL, "footer" TEXT default NULL,
"custom_font" varchar(200) default NULL, "custom_font" varchar(200) default NULL,
"id_template" BIGINT NOT NULL default 0 "id_template" BIGINT NOT NULL default 0,
"id_group_edit" BIGINT NOT NULL default 0
); );
-- ----------------------------------------------------- -- -----------------------------------------------------

View File

@ -149,6 +149,10 @@ CREATE TABLE `tagente_estado` (
-- Probably last_execution_try index is not useful and loads more than benefits -- Probably last_execution_try index is not useful and loads more than benefits
-- -----------------------------------------------------
-- Table `tagente_modulo`
-- -----------------------------------------------------
-- id_modulo now uses tmodule -- id_modulo now uses tmodule
-- --------------------------- -- ---------------------------
-- 1 - Data server modules (agent related modules) -- 1 - Data server modules (agent related modules)
@ -221,105 +225,122 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
KEY `nombre` (`nombre` (255)), KEY `nombre` (`nombre` (255)),
KEY `module_group` (`id_module_group`) using btree KEY `module_group` (`id_module_group`) using btree
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- snmp_oid is also used for WMI query -- snmp_oid is also used for WMI query
-- -----------------------------------------------------
-- Table `tagent_access`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tagent_access` ( CREATE TABLE IF NOT EXISTS `tagent_access` (
`id_agent` int(10) unsigned NOT NULL default '0', `id_agent` int(10) unsigned NOT NULL default '0',
`utimestamp` bigint(20) NOT NULL default '0', `utimestamp` bigint(20) NOT NULL default '0',
KEY `agent_index` (`id_agent`), KEY `agent_index` (`id_agent`),
KEY `idx_utimestamp` USING BTREE (`utimestamp`) KEY `idx_utimestamp` USING BTREE (`utimestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `talert_snmp`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_snmp` ( CREATE TABLE IF NOT EXISTS `talert_snmp` (
`id_as` int(10) unsigned NOT NULL auto_increment, `id_as` int(10) unsigned NOT NULL auto_increment,
`id_alert` int(10) unsigned NOT NULL default '0', `id_alert` int(10) unsigned NOT NULL default '0',
`al_field1` text NOT NULL, `al_field1` text NOT NULL,
`al_field2` text NOT NULL, `al_field2` text NOT NULL,
`al_field3` text NOT NULL, `al_field3` text NOT NULL,
`description` varchar(255) default '', `description` varchar(255) default '',
`alert_type` int(2) unsigned NOT NULL default '0', `alert_type` int(2) unsigned NOT NULL default '0',
`agent` varchar(100) default '', `agent` varchar(100) default '',
`custom_oid` text, `custom_oid` text,
`oid` varchar(255) NOT NULL default '', `oid` varchar(255) NOT NULL default '',
`time_threshold` int(11) NOT NULL default '0', `time_threshold` int(11) NOT NULL default '0',
`times_fired` int(2) unsigned NOT NULL default '0', `times_fired` int(2) unsigned NOT NULL default '0',
`last_fired` datetime NOT NULL default '1970-01-01 00:00:00', `last_fired` datetime NOT NULL default '1970-01-01 00:00:00',
`max_alerts` int(11) NOT NULL default '1', `max_alerts` int(11) NOT NULL default '1',
`min_alerts` int(11) NOT NULL default '1', `min_alerts` int(11) NOT NULL default '1',
`internal_counter` int(2) unsigned NOT NULL default '0', `internal_counter` int(2) unsigned NOT NULL default '0',
`priority` tinyint(4) default '0', `priority` tinyint(4) default '0',
`_snmp_f1_` text, `_snmp_f1_` text,
`_snmp_f2_` text, `_snmp_f2_` text,
`_snmp_f3_` text, `_snmp_f3_` text,
`_snmp_f4_` text, `_snmp_f4_` text,
`_snmp_f5_` text, `_snmp_f5_` text,
`_snmp_f6_` text, `_snmp_f6_` text,
`trap_type` int(11) NOT NULL default '-1', `trap_type` int(11) NOT NULL default '-1',
`single_value` varchar(255) default '', `single_value` varchar(255) default '',
PRIMARY KEY (`id_as`) PRIMARY KEY (`id_as`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `talert_commands`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_commands` ( CREATE TABLE IF NOT EXISTS `talert_commands` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
`command` text, `command` text,
`description` text, `description` text,
`internal` tinyint(1) default 0, `internal` tinyint(1) default 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `talert_actions`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_actions` ( CREATE TABLE IF NOT EXISTS `talert_actions` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`name` text, `name` text,
`id_alert_command` int(10) unsigned NULL default 0, `id_alert_command` int(10) unsigned NULL default 0,
`field1` text NOT NULL, `field1` text NOT NULL,
`field2` text, `field2` text,
`field3` text, `field3` text,
`id_group` mediumint(8) unsigned NULL default 0, `id_group` mediumint(8) unsigned NULL default 0,
`action_threshold` int(10) NOT NULL default '0', `action_threshold` int(10) NOT NULL default '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`) FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`)
ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `talert_templates`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_templates` ( CREATE TABLE IF NOT EXISTS `talert_templates` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`name` text, `name` text,
`description` mediumtext, `description` mediumtext,
`id_alert_action` int(10) unsigned NULL, `id_alert_action` int(10) unsigned NULL,
`field1` text, `field1` text,
`field2` text, `field2` text,
`field3` text NOT NULL, `field3` text NOT NULL,
`type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown', 'always'), `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown', 'always'),
`value` varchar(255) default '', `value` varchar(255) default '',
`matches_value` tinyint(1) default 0, `matches_value` tinyint(1) default 0,
`max_value` double(18,2) default NULL, `max_value` double(18,2) default NULL,
`min_value` double(18,2) default NULL, `min_value` double(18,2) default NULL,
`time_threshold` int(10) NOT NULL default '0', `time_threshold` int(10) NOT NULL default '0',
`max_alerts` int(4) unsigned NOT NULL default '1', `max_alerts` int(4) unsigned NOT NULL default '1',
`min_alerts` int(4) unsigned NOT NULL default '0', `min_alerts` int(4) unsigned NOT NULL default '0',
`time_from` time default '00:00:00', `time_from` time default '00:00:00',
`time_to` time default '00:00:00', `time_to` time default '00:00:00',
`monday` tinyint(1) default 1, `monday` tinyint(1) default 1,
`tuesday` tinyint(1) default 1, `tuesday` tinyint(1) default 1,
`wednesday` tinyint(1) default 1, `wednesday` tinyint(1) default 1,
`thursday` tinyint(1) default 1, `thursday` tinyint(1) default 1,
`friday` tinyint(1) default 1, `friday` tinyint(1) default 1,
`saturday` tinyint(1) default 1, `saturday` tinyint(1) default 1,
`sunday` tinyint(1) default 1, `sunday` tinyint(1) default 1,
`recovery_notify` tinyint(1) default '0', `recovery_notify` tinyint(1) default '0',
`field2_recovery` text NOT NULL, `field2_recovery` text NOT NULL,
`field3_recovery` text NOT NULL, `field3_recovery` text NOT NULL,
`priority` tinyint(4) default '0', `priority` tinyint(4) default '0',
`id_group` mediumint(8) unsigned NULL default 0, `id_group` mediumint(8) unsigned NULL default 0,
`special_day` tinyint(1) default 0, `special_day` tinyint(1) default 0,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `idx_template_action` (`id_alert_action`), KEY `idx_template_action` (`id_alert_action`),
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
ON DELETE SET NULL ON UPDATE CASCADE ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `talert_template_modules`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_template_modules` ( CREATE TABLE IF NOT EXISTS `talert_template_modules` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`id_agent_module` int(10) unsigned NOT NULL, `id_agent_module` int(10) unsigned NOT NULL,
@ -343,51 +364,57 @@ CREATE TABLE IF NOT EXISTS `talert_template_modules` (
INDEX force_execution (`force_execution`) INDEX force_execution (`force_execution`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `talert_template_module_actions`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_template_module_actions` ( CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`id_alert_template_module` int(10) unsigned NOT NULL, `id_alert_template_module` int(10) unsigned NOT NULL,
`id_alert_action` int(10) unsigned NOT NULL, `id_alert_action` int(10) unsigned NOT NULL,
`fires_min` int(3) unsigned default 0, `fires_min` int(3) unsigned default 0,
`fires_max` int(3) unsigned default 0, `fires_max` int(3) unsigned default 0,
`module_action_threshold` int(10) NOT NULL default '0', `module_action_threshold` int(10) NOT NULL default '0',
`last_execution` bigint(20) NOT NULL default '0', `last_execution` bigint(20) NOT NULL default '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`) FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`)
ON DELETE CASCADE ON UPDATE CASCADE, ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `talert_compound`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_compound` ( CREATE TABLE IF NOT EXISTS `talert_compound` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(255) default '', `name` varchar(255) default '',
`description` mediumtext, `description` mediumtext,
`id_agent` int(10) unsigned NOT NULL, `id_agent` int(10) unsigned NOT NULL,
`time_threshold` int(10) NOT NULL default '0', `time_threshold` int(10) NOT NULL default '0',
`max_alerts` int(4) unsigned NOT NULL default '1', `max_alerts` int(4) unsigned NOT NULL default '1',
`min_alerts` int(4) unsigned NOT NULL default '0', `min_alerts` int(4) unsigned NOT NULL default '0',
`time_from` time default '00:00:00', `time_from` time default '00:00:00',
`time_to` time default '00:00:00', `time_to` time default '00:00:00',
`monday` tinyint(1) default 1, `monday` tinyint(1) default 1,
`tuesday` tinyint(1) default 1, `tuesday` tinyint(1) default 1,
`wednesday` tinyint(1) default 1, `wednesday` tinyint(1) default 1,
`thursday` tinyint(1) default 1, `thursday` tinyint(1) default 1,
`friday` tinyint(1) default 1, `friday` tinyint(1) default 1,
`saturday` tinyint(1) default 1, `saturday` tinyint(1) default 1,
`sunday` tinyint(1) default 1, `sunday` tinyint(1) default 1,
`recovery_notify` tinyint(1) default '0', `recovery_notify` tinyint(1) default '0',
`field2_recovery` varchar(255) NOT NULL default '', `field2_recovery` varchar(255) NOT NULL default '',
`field3_recovery` mediumtext NOT NULL, `field3_recovery` mediumtext NOT NULL,
`internal_counter` int(4) default '0', `internal_counter` int(4) default '0',
`last_fired` bigint(20) NOT NULL default '0', `last_fired` bigint(20) NOT NULL default '0',
`last_reference` bigint(20) NOT NULL default '0', `last_reference` bigint(20) NOT NULL default '0',
`times_fired` int(3) NOT NULL default '0', `times_fired` int(3) NOT NULL default '0',
`disabled` tinyint(1) default '0', `disabled` tinyint(1) default '0',
`priority` tinyint(4) default '0', `priority` tinyint(4) default '0',
`special_day` tinyint(1) default 0, `special_day` tinyint(1) default 0,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`)
ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `talert_compound_elements` ( CREATE TABLE IF NOT EXISTS `talert_compound_elements` (
@ -858,20 +885,24 @@ CREATE TABLE IF NOT EXISTS `tgraph_source` (
PRIMARY KEY(`id_gs`) PRIMARY KEY(`id_gs`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8; ) ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `treport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `treport` ( CREATE TABLE IF NOT EXISTS `treport` (
`id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`id_user` varchar(100) NOT NULL default '', `id_user` varchar(100) NOT NULL default '',
`name` varchar(150) NOT NULL default '', `name` varchar(150) NOT NULL default '',
`description` TEXT NOT NULL, `description` TEXT NOT NULL,
`private` tinyint(1) UNSIGNED NOT NULL default 0, `private` tinyint(1) UNSIGNED NOT NULL default 0,
`id_group` mediumint(8) unsigned NULL default NULL, `id_group` mediumint(8) unsigned NULL default NULL,
`custom_logo` varchar(200) default NULL, `custom_logo` varchar(200) default NULL,
`header` MEDIUMTEXT, `header` MEDIUMTEXT,
`first_page` MEDIUMTEXT, `first_page` MEDIUMTEXT,
`footer` MEDIUMTEXT, `footer` MEDIUMTEXT,
`custom_font` varchar(200) default NULL, `custom_font` varchar(200) default NULL,
`id_template` INTEGER UNSIGNED DEFAULT 0, `id_template` INTEGER UNSIGNED DEFAULT 0,
PRIMARY KEY(`id_report`) `id_group_edit` mediumint(8) unsigned NULL DEFAULT 0,
PRIMARY KEY(`id_report`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8; ) ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------- -- -----------------------------------------------------