From dd4869087701cdda0561d6bfa298bca81ee831fb Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 24 Sep 2012 11:59:05 +0000 Subject: [PATCH] 2012-09-24 Miguel de Dios * 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 fields "text_filter" and "dont_show_subgroups" for to new filters to generate the networkmap. * operation/agentes/networkmap.topology.php, operation/agentes/networkmap.groups.php, include/functions_networkmap.php, include/functions_servers.php: added the new filters for free text for agents and hidden the subgroups of any group in the group networkmap. * extensions/resource_registration.php, operation/agentes/networkmap.php, general/header.php, godmode/netflow/nf_report_form.php, godmode/agentes/module_manager.php, include/functions_groups.php, include/auth/ldap.php, operation/agentes/estado_ultimopaquete.php, include/functions.php, include/functions_db.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6995 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 23 + .../extensions/resource_registration.php | 3 +- .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql | 248 ++++--- .../pandoradb_migrate_4.0.x_to_5.0.oracle.sql | 5 + ...doradb_migrate_4.0.x_to_5.0.postgreSQL.sql | 59 +- pandora_console/general/header.php | 12 +- .../godmode/agentes/module_manager.php | 4 +- .../godmode/netflow/nf_report_form.php | 9 +- pandora_console/include/auth/ldap.php | 12 +- pandora_console/include/functions.php | 6 +- pandora_console/include/functions_db.php | 3 +- pandora_console/include/functions_groups.php | 214 +++--- .../include/functions_networkmap.php | 58 +- pandora_console/include/functions_servers.php | 112 ++-- .../agentes/estado_ultimopaquete.php | 28 +- .../operation/agentes/networkmap.groups.php | 2 +- .../operation/agentes/networkmap.php | 182 +++--- .../operation/agentes/networkmap.topology.php | 5 +- pandora_console/pandoradb.oracle.sql | 8 +- pandora_console/pandoradb.postgreSQL.sql | 20 +- pandora_console/pandoradb.sql | 608 +++++++++--------- 21 files changed, 857 insertions(+), 764 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c7030a3c77..7d326b7553 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,26 @@ +2012-09-24 Miguel de Dios + + * 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 fields + "text_filter" and "dont_show_subgroups" for to new filters to + generate the networkmap. + + * operation/agentes/networkmap.topology.php, + operation/agentes/networkmap.groups.php, + include/functions_networkmap.php, include/functions_servers.php: + added the new filters for free text for agents and hidden the + subgroups of any group in the group networkmap. + + * extensions/resource_registration.php, + operation/agentes/networkmap.php, general/header.php, + godmode/netflow/nf_report_form.php, + godmode/agentes/module_manager.php, include/functions_groups.php, + include/auth/ldap.php, operation/agentes/estado_ultimopaquete.php, + include/functions.php, include/functions_db.php: cleaned source code + style. + 2012-09-21 Ramon Novoa * include/functions_netflow.php, diff --git a/pandora_console/extensions/resource_registration.php b/pandora_console/extensions/resource_registration.php index ce87ff8514..b7fec3b5b1 100644 --- a/pandora_console/extensions/resource_registration.php +++ b/pandora_console/extensions/resource_registration.php @@ -120,7 +120,8 @@ function process_upload_xml_report($xml, $group_filter = 0) { $agents_item= array(); if (isset($item['agent'])) { - $agents = agents_get_agents(array('id_grupo' => $group_filter), array('id_agente', 'nombre')); + $agents = agents_get_agents(array('id_grupo' => $group_filter), + array('id_agente', 'nombre')); $agent_clean = str_replace(array('[', ']'), '', $item['agent']); $regular_expresion = ($agent_clean != $item['agent']); diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index 1d0095f216..0e0707d7e1 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -73,9 +73,9 @@ CREATE TABLE IF NOT EXISTS `talert_special_days` ( -- --------------------------------------------------------------------- ALTER TABLE `talert_templates` ADD COLUMN `special_day` tinyint(1) DEFAULT '0'; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tplanned_downtime` ADD COLUMN `monday` tinyint(1) default 0; ALTER TABLE `tplanned_downtime` ADD COLUMN `tuesday` tinyint(1) default 0; ALTER TABLE `tplanned_downtime` ADD COLUMN `wednesday` tinyint(1) default 0; @@ -91,22 +91,19 @@ ALTER TABLE `tplanned_downtime` ADD COLUMN `type_downtime` varchar(100) NOT NULL ALTER TABLE `tplanned_downtime` ADD COLUMN `type_execution` varchar(100) NOT NULL default 'once'; ALTER TABLE `tplanned_downtime` ADD COLUMN `type_periodicity` varchar(100) NOT NULL default 'weekly'; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime_agents` --- ----------------------------------------------------- +------------------------------------------------------------------------ DELETE FROM tplanned_downtime_agents WHERE id_downtime NOT IN (SELECT id FROM tplanned_downtime); - ALTER TABLE tplanned_downtime_agents ADD FOREIGN KEY(`id_downtime`) REFERENCES tplanned_downtime(`id`) ON DELETE CASCADE; - ALTER TABLE `tplanned_downtime_agents` ADD COLUMN `all_modules` tinyint(1) default 1; - --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime_modules` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` ( `id` int(20) unsigned NOT NULL auto_increment, `id_agent` mediumint(8) unsigned NOT NULL default '0', @@ -116,48 +113,60 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` ( FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- --- Table `tevento` --- ----------------------------------------------------- -ALTER TABLE `tevento` ADD COLUMN (`source` tinytext NOT NULL, - `id_extra` tinytext NOT NULL); -ALTER TABLE `tevento` MODIFY COLUMN `event_type` 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') CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'unknown'; --- ----------------------------------------------------- +------------------------------------------------------------------------ +-- Table `tevento` +------------------------------------------------------------------------ +ALTER TABLE `tevento` ADD COLUMN (`source` tinytext NOT NULL, `id_extra` tinytext NOT NULL); +ALTER TABLE `tevento` MODIFY COLUMN `event_type` 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') CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'unknown'; +ALTER TABLE `tevento` ADD COLUMN `critical_instructions` TEXT NOT NULL DEFAULT ''; +ALTER TABLE `tevento` ADD COLUMN `warning_instructions` TEXT NOT NULL DEFAULT ''; +ALTER TABLE `tevento` ADD COLUMN `unknown_instructions` TEXT NOT NULL DEFAULT ''; + +------------------------------------------------------------------------ -- Table `tgrupo` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tgrupo` ADD COLUMN `description` text; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `talert_snmp` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `talert_snmp` ADD COLUMN (`_snmp_f1_` text, `_snmp_f2_` text, `_snmp_f3_` text, `_snmp_f4_` text, `_snmp_f5_` text, `_snmp_f6_` text, `trap_type` int(11) NOT NULL default '-1', `single_value` varchar(255) DEFAULT ''); --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tagente_modulo` --- ----------------------------------------------------- -ALTER TABLE `tagente_modulo` ADD COLUMN `module_ff_interval` int(4) unsigned default '0'; -ALTER TABLE `tagente_modulo` CHANGE COLUMN `post_process` `post_process` double(18,5) default NULL; -ALTER TABLE `tagente_modulo` ADD COLUMN `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard'; +------------------------------------------------------------------------ +ALTER TABLE `tagente_modulo` ADD COLUMN `module_ff_interval` int(4) unsigned DEFAULT '0'; +ALTER TABLE `tagente_modulo` CHANGE COLUMN `post_process` `post_process` double(18,5) DEFAULT NULL; +ALTER TABLE `tagente_modulo` ADD COLUMN `wizard_level` enum('basic','advanced','custom','nowizard') DEFAULT 'nowizard'; ALTER TABLE `tagente_modulo` ADD COLUMN `macros` text; ALTER TABLE `tagente_modulo` ADD COLUMN `quiet` tinyint(1) NOT NULL DEFAULT '0'; +ALTER TABLE `tagente_modulo` ADD COLUMN `critical_instructions` TEXT NOT NULL DEFAULT ''; +ALTER TABLE `tagente_modulo` ADD COLUMN `warning_instructions` TEXT NOT NULL DEFAULT ''; +ALTER TABLE `tagente_modulo` ADD COLUMN `unknown_instructions` TEXT NOT NULL DEFAULT ''; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tnetwork_component` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tnetwork_component` CHANGE COLUMN `post_process` `post_process` double(18,5) default NULL; ALTER TABLE `tnetwork_component` ADD COLUMN `unit` TEXT NOT NULL AFTER `post_process`; +ALTER TABLE tnetwork_component ADD `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard'; +ALTER TABLE tnetwork_component ADD `only_metaconsole` tinyint(1) unsigned default '0'; +ALTER TABLE tnetwork_component ADD `macros` text; +ALTER TABLE tnetwork_component ADD `critical_instructions` TEXT NOT NULL default ''; +ALTER TABLE tnetwork_component ADD `warning_instructions` TEXT NOT NULL default ''; +ALTER TABLE tnetwork_component ADD `unknown_instructions` TEXT NOT NULL default ''; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tgraph_source` Alter table to allow negative values in weight --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tgraph_source MODIFY weight FLOAT(5,3) NOT NULL DEFAULT '0.000'; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tevent_filter` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tevent_filter` ( `id_filter` int(10) unsigned NOT NULL auto_increment, `id_group_filter` int(10) NOT NULL default 0, @@ -177,78 +186,14 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` ( PRIMARY KEY (`id_filter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tconfig` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tconfig MODIFY value TEXT NOT NULL; --Join the all ips of "list_ACL_IPs_for_API_%" in one row (now We have a field "value" with hudge size) INSERT INTO tconfig (token, `value`) SELECT 'list_ACL_IPs_for_API', GROUP_CONCAT(`value` SEPARATOR ';') AS `value` FROM tconfig WHERE token LIKE "list_ACL_IPs_for_API%"; INSERT INTO `tconfig` (`token`, `value`) VALUES ('event_fields', 'evento,id_agente,estado,timestamp'); DELETE FROM tconfig WHERE token LIKE "list_ACL_IPs_for_API_%"; - --- ----------------------------------------------------- --- Table `treport_content_item` --- ----------------------------------------------------- -ALTER TABLE treport_content_item ADD FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) ON UPDATE CASCADE ON DELETE CASCADE; - --- ----------------------------------------------------- --- Table `treport` --- ----------------------------------------------------- -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; -ALTER TABLE treport ADD COLUMN `metaconsole` tinyint(1) DEFAULT 0; - --- ----------------------------------------------------- --- Table `tgraph` --- ----------------------------------------------------- -ALTER TABLE `tgraph` ADD COLUMN `id_graph_template` int(11) NOT NULL DEFAULT 0; - --- ----------------------------------------------------- --- Table `ttipo_modulo` --- ----------------------------------------------------- -UPDATE ttipo_modulo SET descripcion='Generic data' WHERE id_tipo=1; -UPDATE ttipo_modulo SET descripcion='Generic data incremental' WHERE id_tipo=4; - --- ----------------------------------------------------- --- Table `tusuario` --- ----------------------------------------------------- -ALTER TABLE `tusuario` ADD COLUMN `section` TEXT NOT NULL; -INSERT INTO `tusuario` (`section`) VALUES ('Default'); -ALTER TABLE `tusuario` ADD COLUMN `data_section` TEXT NOT NULL; -ALTER TABLE `tusuario` ADD COLUMN `disabled` int(4) NOT NULL DEFAULT 0; -ALTER TABLE `tusuario` ADD COLUMN `shortcut` tinyint(1) DEFAULT 0; -ALTER TABLE `tusuario` ADD COLUMN `shortcut_data` text; -ALTER TABLE `tusuario` ADD COLUMN `not_login` tinyint(1) unsigned NOT NULL DEFAULT 0; -ALTER TABLE `tusuario` ADD COLUMN `force_change_pass` tinyint(1) DEFAULT 0; -ALTER TABLE `tusuario` ADD COLUMN `last_pass_change` DATETIME NOT NULL DEFAULT 0; -ALTER TABLE `tusuario` ADD COLUMN `last_failed_login` DATETIME NOT NULL DEFAULT 0; -ALTER TABLE `tusuario` ADD COLUMN `failed_attempt` int(4) NOT NULL DEFAULT 0; -ALTER TABLE `tusuario` ADD COLUMN `login_blocked` tinyint(1) DEFAULT 0; -ALTER TABLE `tusuario` ADD COLUMN `metaconsole_access` enum('basic','advanced','custom','all','only_console') DEFAULT 'only_console'; - --- ----------------------------------------------------- --- Table `treport_content_item` --- ----------------------------------------------------- -ALTER TABLE `treport_content_item` ADD COLUMN `operation` TEXT; - --- ----------------------------------------------------- --- Table `tmensajes` --- ----------------------------------------------------- -ALTER TABLE `tmensajes` MODIFY COLUMN `mensaje` TEXT NOT NULL; - --- ----------------------------------------------------- --- Table `talert_compound` --- ----------------------------------------------------- -ALTER TABLE `talert_compound` ADD COLUMN `special_day` tinyint(1) DEFAULT '0'; - --- ----------------------------------------------------- --- Table `talert_commands` --- ----------------------------------------------------- -INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`) VALUES ('Validate Event','Internal type','This alert validate the events matched with a module given the agent name (_field1_) and module name (_field2_)', 1); - --- ----------------------------------------------------- --- Table `tconfig` --- ----------------------------------------------------- INSERT INTO `tconfig` (`token`, `value`) VALUES ('enable_pass_policy', 0), ('pass_size', 4), @@ -263,10 +208,63 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('compare_pass', 3), ('meta_style', 'meta_pandora'), ('enable_refr', 0); +UPDATE tconfig SET `value`='comparation' WHERE `token`= 'prominent_time'; --- ----------------------------------------------------- +------------------------------------------------------------------------ +-- Table `treport_content_item` +------------------------------------------------------------------------ +ALTER TABLE treport_content_item ADD FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE `treport_content_item` ADD COLUMN `operation` TEXT; +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; +ALTER TABLE treport ADD COLUMN `metaconsole` tinyint(1) DEFAULT 0; + +------------------------------------------------------------------------ +-- Table `tgraph` +------------------------------------------------------------------------ +ALTER TABLE `tgraph` ADD COLUMN `id_graph_template` int(11) NOT NULL DEFAULT 0; + +------------------------------------------------------------------------ +-- Table `ttipo_modulo` +------------------------------------------------------------------------ +UPDATE ttipo_modulo SET descripcion='Generic data' WHERE id_tipo=1; +UPDATE ttipo_modulo SET descripcion='Generic data incremental' WHERE id_tipo=4; + +------------------------------------------------------------------------ +-- Table `tusuario` +------------------------------------------------------------------------ +ALTER TABLE `tusuario` ADD COLUMN `section` TEXT NOT NULL; +INSERT INTO `tusuario` (`section`) VALUES ('Default'); +ALTER TABLE `tusuario` ADD COLUMN `data_section` TEXT NOT NULL; +ALTER TABLE `tusuario` ADD COLUMN `disabled` int(4) NOT NULL DEFAULT 0; +ALTER TABLE `tusuario` ADD COLUMN `shortcut` tinyint(1) DEFAULT 0; +ALTER TABLE `tusuario` ADD COLUMN `shortcut_data` text; +ALTER TABLE `tusuario` ADD COLUMN `not_login` tinyint(1) unsigned NOT NULL DEFAULT 0; +ALTER TABLE `tusuario` ADD COLUMN `force_change_pass` tinyint(1) DEFAULT 0; +ALTER TABLE `tusuario` ADD COLUMN `last_pass_change` DATETIME NOT NULL DEFAULT 0; +ALTER TABLE `tusuario` ADD COLUMN `last_failed_login` DATETIME NOT NULL DEFAULT 0; +ALTER TABLE `tusuario` ADD COLUMN `failed_attempt` int(4) NOT NULL DEFAULT 0; +ALTER TABLE `tusuario` ADD COLUMN `login_blocked` tinyint(1) DEFAULT 0; +ALTER TABLE `tusuario` ADD COLUMN `metaconsole_access` enum('basic','advanced','custom','all','only_console') DEFAULT 'only_console'; + +------------------------------------------------------------------------ +-- Table `tmensajes` +------------------------------------------------------------------------ +ALTER TABLE `tmensajes` MODIFY COLUMN `mensaje` TEXT NOT NULL; + +------------------------------------------------------------------------ +-- Table `talert_compound` +------------------------------------------------------------------------ +ALTER TABLE `talert_compound` ADD COLUMN `special_day` tinyint(1) DEFAULT '0'; + +------------------------------------------------------------------------ +-- Table `talert_commands` +------------------------------------------------------------------------ +INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`) VALUES ('Validate Event','Internal type','This alert validate the events matched with a module given the agent name (_field1_) and module name (_field2_)', 1); + +------------------------------------------------------------------------ -- 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, @@ -276,60 +274,32 @@ CREATE TABLE IF NOT EXISTS `tpassword_history` ( PRIMARY KEY (`id_pass`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- --- Table `tconfig` --- ----------------------------------------------------- -UPDATE tconfig SET `value`='comparation' - WHERE `token`= 'prominent_time'; - --- ----------------------------------------------------- --- Table `tnetwork_component` --- ----------------------------------------------------- -ALTER TABLE tnetwork_component ADD `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard'; -ALTER TABLE tnetwork_component ADD `only_metaconsole` tinyint(1) unsigned default '0'; -ALTER TABLE tnetwork_component ADD `macros` text; - --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplugin` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tplugin ADD `macros` text; ALTER TABLE tplugin ADD `parameters` text; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `trecon_script` --- ----------------------------------------------------- +------------------------------------------------------------------------ UPDATE trecon_script SET `description`='This script is used to automatically detect SNMP Interfaces on devices, used as Recon Custom Script in the recon task. Parameters used are: * custom_field1 = network. i.e.: 192.168.100.0/24 * custom_field2 = several communities separated by comma. For example: snmp_community,public,private * custom_field3 = optative parameter to force process downed interfaces (use: '-a'). Only up interfaces are processed by default See documentation for more information.' WHERE id_recon_script = 1; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `trecon_task --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE trecon_task MODIFY subnet TEXT NOT NULL DEFAULT ''; ALTER TABLE trecon_task MODIFY field1 TEXT NOT NULL DEFAULT ''; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tlayout_data --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tlayout_data ADD COLUMN `enable_link` tinyint(1) UNSIGNED NOT NULL default 1; --- ----------------------------------------------------- --- Table `tagente_modulo` --- ----------------------------------------------------- -ALTER TABLE tagente_modulo ADD `critical_instructions` TEXT NOT NULL default ''; -ALTER TABLE tagente_modulo ADD `warning_instructions` TEXT NOT NULL default ''; -ALTER TABLE tagente_modulo ADD `unknown_instructions` TEXT NOT NULL default ''; - --- ----------------------------------------------------- --- Table `tevento` --- ----------------------------------------------------- -ALTER TABLE tevento ADD `critical_instructions` TEXT NOT NULL default ''; -ALTER TABLE tevento ADD `warning_instructions` TEXT NOT NULL default ''; -ALTER TABLE tevento ADD `unknown_instructions` TEXT NOT NULL default ''; - --- ----------------------------------------------------- --- Table `tnetwork_component` --- ----------------------------------------------------- -ALTER TABLE tnetwork_component ADD `critical_instructions` TEXT NOT NULL default ''; -ALTER TABLE tnetwork_component ADD `warning_instructions` TEXT NOT NULL default ''; -ALTER TABLE tnetwork_component ADD `unknown_instructions` TEXT NOT NULL default ''; +------------------------------------------------------------------------ +-- Table `tnetwork_map` +------------------------------------------------------------------------ +ALTER TABLE tnetwork_map ADD `text_filter` VARCHAR(100) NOT NULL DEFAULT ""; +ALTER TABLE tnetwork_map ADD `dont_show_subgroups` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql index 505bb2bfb0..98304d56ac 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql @@ -332,3 +332,8 @@ ALTER TABLE tnetwork_component ADD (critical_instructions VARCHAR2(255) default ALTER TABLE tnetwork_component ADD (warning_instructions VARCHAR2(255) default ''); ALTER TABLE tnetwork_component ADD (unknown_instructions VARCHAR2(255) default ''); +------------------------------------------------------------------------ +-- Table `tnetwork_map` +------------------------------------------------------------------------ +ALTER TABLE tnetwork_map ADD (text_filter VARCHAR(100) DEFAULT ''); +ALTER TABLE tnetwork_map ADD (dont_show_subgroups NUMBER(10, 0) default 0 NOT NULL); \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql index d80d8fee3d..094297bf7a 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql @@ -119,9 +119,9 @@ REFERENCES "tplanned_downtime"("id"); ALTER TABLE "tplanned_downtime_agents" ADD COLUMN "all_modules" SMALLINT default 1; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table "tplanned_downtime_modules" --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE "tplanned_downtime_modules" ( "id" BIGSERIAL NOT NULL PRIMARY KEY, "id_agent" BIGINT NOT NULL default 0, @@ -129,12 +129,15 @@ CREATE TABLE "tplanned_downtime_modules" ( "id_downtime" BIGINT NOT NULL REFERENCES tplanned_downtime("id") ON DELETE CASCADE ); --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tevento` --- ----------------------------------------------------- - +------------------------------------------------------------------------ ALTER TABLE "tevento" ADD COLUMN "source" text NULL default ''; ALTER TABLE "tevento" ADD COLUMN "id_extra" text NULL default ''; +ALTER TABLE "tevento" ADD COLUMN "critical_instructions" text default ''; +ALTER TABLE "tevento" ADD COLUMN "warning_instructions" text default ''; +ALTER TABLE "tevento" ADD COLUMN "unknown_instructions" text default ''; +ALTER TYPE type_tevento_event ADD VALUE 'going_unknown' BEFORE 'unknown'; -- ----------------------------------------------------- -- Table `tgrupo` @@ -160,6 +163,12 @@ ALTER TABLE "talert_snmp" ADD COLUMN "single_value" varchar(255) DEFAULT ''; -- ----------------------------------------------------- ALTER TABLE "tagente_modulo" ADD COLUMN "module_ff_interval" INTEGER NOT NULL default 0; ALTER TABLE "tagente_modulo" ADD COLUMN "quiet" SMALLINT NOT NULL default 0; +CREATE TYPE type_tagente_modulo_wizard_level AS ENUM ('basic','advanced','custom','nowizard'); +ALTER TABLE "tagente_modulo" ADD COLUMN "wizard_level" type_tagente_modulo_wizard_level default 'nowizard'; +ALTER TABLE "tagente_modulo" ADD COLUMN "macros" TEXT default ''; +ALTER TABLE "tagente_modulo" ADD COLUMN "critical_instructions" text default ''; +ALTER TABLE "tagente_modulo" ADD COLUMN "warning_instructions" text default ''; +ALTER TABLE "tagente_modulo" ADD COLUMN "unknown_instructions" text default ''; -- ----------------------------------------------------- -- Table `tevent_filter` @@ -286,14 +295,6 @@ ALTER TABLE "tnetwork_component" ADD COLUMN "wizard_level" type_tnetwork_compone ALTER TABLE "tnetwork_component" ADD COLUMN "only_metaconsole" INTEGER default '0'; ALTER TABLE "tnetwork_component" ADD COLUMN "macros" TEXT default ''; --- ----------------------------------------------------- --- Table `tagente_modulo` --- ----------------------------------------------------- - -CREATE TYPE type_tagente_modulo_wizard_level AS ENUM ('basic','advanced','custom','nowizard'); -ALTER TABLE "tagente_modulo" ADD COLUMN "wizard_level" type_tagente_modulo_wizard_level default 'nowizard'; -ALTER TABLE "tagente_modulo" ADD COLUMN "macros" TEXT default ''; - -- ----------------------------------------------------- -- Table `tplugin` -- ----------------------------------------------------- @@ -301,36 +302,26 @@ ALTER TABLE "tagente_modulo" ADD COLUMN "macros" TEXT default ''; ALTER TABLE "tplugin" ADD COLUMN "macros" TEXT default ''; ALTER TABLE "tplugin" ADD COLUMN "parameters" TEXT default ''; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `trecon_task` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE "trecon_task" ALTER COLUMN "subnet" TYPE TEXT; ALTER TABLE "trecon_task" ALTER COLUMN "field1" TYPE TEXT; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tlayout_data` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE "tlayout_data" ADD COLUMN "enable_link" SMALLINT NOT NULL default 1; --- ----------------------------------------------------- --- Table `tevento` --- ----------------------------------------------------- -ALTER TABLE "tevento" ADD COLUMN "critical_instructions" text default ''; -ALTER TABLE "tevento" ADD COLUMN "warning_instructions" text default ''; -ALTER TABLE "tevento" ADD COLUMN "unknown_instructions" text default ''; -ALTER TYPE type_tevento_event ADD VALUE 'going_unknown' BEFORE 'unknown'; - --- ----------------------------------------------------- --- Table `tagente_modulo` --- ----------------------------------------------------- -ALTER TABLE "tagente_modulo" ADD COLUMN "critical_instructions" text default ''; -ALTER TABLE "tagente_modulo" ADD COLUMN "warning_instructions" text default ''; -ALTER TABLE "tagente_modulo" ADD COLUMN "unknown_instructions" text default ''; - --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tnetwork_component` --- ----------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE "tnetwork_component" ADD COLUMN "critical_instructions" text default ''; ALTER TABLE "tnetwork_component" ADD COLUMN "warning_instructions" text default ''; ALTER TABLE "tnetwork_component" ADD COLUMN "unknown_instructions" text default ''; +------------------------------------------------------------------------ +-- Table `tnetwork_map` +------------------------------------------------------------------------ +ALTER TABLE "tnetwork_map" ADD COLUMN "text_filter" VARCHAR(100) DEFAULT ''; +ALTER TABLE "tnetwork_map" ADD COLUMN "dont_show_subgroups" INTEGER NOT NULL DEFAULT 0; \ No newline at end of file diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 9dc1c912ea..e74cbc9bca 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -135,19 +135,21 @@ config_check(); echo '' . html_print_image("images/page_refresh.png", true, array("class" => 'bot', "alt" => 'lightning')) . ' '. __('Autorefresh'); echo ' ('.date ("i:s", $config["refr"]).')'; echo ''; - } else { + } + else { if (!isset($_GET['sec2'])) $_GET['sec2'] = ''; - + if (($config['refr']) && (($_GET['sec2'] == 'operation/agentes/tactical') || ($_GET['sec2'] == 'operation/agentes/estado_agente') || ($_GET['sec2'] == 'operation/agentes/group_view') || ($_GET['sec2'] == 'operation/events/events') || ($_GET['sec2'] == 'enterprise/dashboard/main_dashboard'))) { - + echo '' . html_print_image("images/page_refresh.png", true, array("class" => 'bot', "alt" => 'lightning')) . ' '. __('Autorefresh'); echo ' ('.date ("i:s", $config["refr"]).')'; echo ''; - } else { + } + else { $ignored_params['refr'] = ''; echo '' . html_print_image("images/page_refresh.png", true, array("class" => 'bot', "alt" => 'lightning')) . ' '. __('Autorefresh').''; $values = array ( @@ -167,7 +169,7 @@ config_check(); echo ''; } } - + ?> diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 35aa3a7ce0..1637798301 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -16,8 +16,8 @@ /* You can redefine $url and unset $id_agente to reuse the form. Dirty (hope temporal) hack */ if (isset ($id_agente)) { $url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente; - -} else { +} +else { $url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module'; } diff --git a/pandora_console/godmode/netflow/nf_report_form.php b/pandora_console/godmode/netflow/nf_report_form.php index aa97b834d1..1ea269b00f 100644 --- a/pandora_console/godmode/netflow/nf_report_form.php +++ b/pandora_console/godmode/netflow/nf_report_form.php @@ -34,7 +34,7 @@ $result_ins = -1; $update = (string)get_parameter('update', 0); $create = (string)get_parameter('create', 0); -if ($create){ +if ($create) { $name = (string) get_parameter ('name'); $group = (int) get_parameter ('id_group'); $description = get_parameter('description',''); @@ -44,12 +44,13 @@ if ($create){ 'id_group' => $group, 'description' => $description, ); - + $result_ins = db_process_sql_insert('tnetflow_report', $values); $id = $result_ins; -} else { +} +else { $id = (int)get_parameter('id'); } @@ -78,7 +79,7 @@ if (($result_ins === false) && ($result_ins != -1)) { else if (($result_ins != false) && ($result_ins != -1)){ ui_print_success_message ('Report created successfully'); } - + if ($id) { $permission = netflow_check_report_group ($id, false); if (!$permission) { //no tiene permisos para acceder a un informe diff --git a/pandora_console/include/auth/ldap.php b/pandora_console/include/auth/ldap.php index b7ad76905d..ea307cd66b 100644 --- a/pandora_console/include/auth/ldap.php +++ b/pandora_console/include/auth/ldap.php @@ -419,7 +419,8 @@ function ldap_load_user ($login) { $ret["is_admin"] = is_user_admin ($info[0][$config["auth"]["ldap_user_attr"]["id_user"]][0]); if (isset ($info[0][$ldap_key])) { $ret[$internal_key] = $info[0][$ldap_key][0]; - } else { + } + else { $ret[$internal_key] = ''; } } @@ -431,7 +432,7 @@ function ldap_load_user ($login) { else { $ldap_cache["error"] .= 'Could not connect to LDAP server'; } - + return $ret; } @@ -506,7 +507,8 @@ function get_users ($order = false) { $sr = @ldap_search ($ldap_cache["ds"], $config["auth"]["ldap_base_dn"], $config["auth"]["ldap_user_filter"], array_values ($config["auth"]["ldap_user_attr"])); if (!$sr) { $ldap_cache["error"] .= 'Error searching LDAP server (get_users): ' . ldap_error( $ldap_cache["ds"] ); - } else { + } + else { ldap_sort ($ldap_cache["ds"], $sr, $config["auth"]["ldap_user_attr"]["fullname"]); $info = @ldap_get_entries( $ldap_cache["ds"], $sr ); for ( $i = 0; $i < $info['count']; $i++ ) { @@ -514,7 +516,8 @@ function get_users ($order = false) { $ret[$info[$i][$config["auth"]["ldap_user_attr"]["id_user"]][0]]["last_connect"] = $time; if (isset ($info[$i][$ldap_key])) { $ret[$info[$i][$config["auth"]["ldap_user_attr"]["id_user"]][0]][$internal_key] = $info[$i][$ldap_key][0]; - } else { + } + else { $ret[$info[$i][$config["auth"]["ldap_user_attr"]["id_user"]][0]][$internal_key] = ''; } $ret[$info[$i][$config["auth"]["ldap_user_attr"]["id_user"]][0]]["is_admin"] = is_user_admin ($info[$i][$config["auth"]["ldap_user_attr"]["id_user"]][0]); @@ -541,6 +544,7 @@ function get_users ($order = false) { function stripdn ($dn) { list ($uid, $trash) = explode (',', $dn, 2); list ($trash, $user) = explode ('=', $uid); + return ($user); } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 3c88eea200..ebb78f94f8 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -79,11 +79,13 @@ function safe_int ($value, $min = false, $max = false) { $check = safe_int ($check, $min, $max); if ($check !== false) { $value[$key] = $check; - } else { + } + else { unset ($value[$key]); } } - } else { + } + else { $value = (int) $value; //Cast as integer if (($min !== false && $value < $min) || ($max !== false && $value > $max)) { //If it's smaller than min or larger than max return false diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 1dc99170a0..6cbd35375b 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -66,7 +66,8 @@ function db_connect($host = null, $db = null, $user = null, $pass = null, $port if ($critical) { include ($config["homedir"]."/general/error_authconfig.php"); exit; - } else if ($error == 0) { + } + else if ($error == 0) { // Display the error once even if multiple connection attempts are made $error = 1; ui_print_error_message (__("Error connecting to database %s at %s.", $db, $host)); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index a1e5676781..579f82666e 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -430,12 +430,12 @@ function groups_get_all($groupWithAgents = false) { */ function groups_get_id_recursive($id_parent, $all = false) { $return = array(); - + $return = array_merge($return, array($id_parent)); - + //Check propagate $id = db_get_value_filter('id_grupo', 'tgrupo', array('id_grupo' => $id_parent, 'propagate' => 1)); - + if (($id !== false) || $all) { $children = db_get_all_rows_filter("tgrupo", array('parent' => $id_parent, 'disabled' => 0), array('id_grupo')); if ($children === false) { @@ -448,12 +448,12 @@ function groups_get_id_recursive($id_parent, $all = false) { } $children = $temp; } - + foreach ($children as $id_children) { $return = array_merge($return, groups_get_id_recursive($id_children, $all)); } } - + return $return; } @@ -468,7 +468,7 @@ function groups_get_id_recursive($id_parent, $all = false) { */ function groups_get_groups_tree_recursive($groups, $parent = 0, $deep = 0) { $return = array(); - + foreach ($groups as $key => $group) { if (($key === 0 || $key === __('All')) && ($parent === 0 || $parent === __('All'))) { //When the groups is the all group $group['deep'] = $deep; @@ -488,7 +488,7 @@ function groups_get_groups_tree_recursive($groups, $parent = 0, $deep = 0) { $return = $return + array($key => $group) + $branch; } } - + return $return; } @@ -501,44 +501,44 @@ function groups_get_groups_tree_recursive($groups, $parent = 0, $deep = 0) { */ function groups_get_status ($id_group = 0) { $agents = agents_get_group_agents($id_group); - + $agents_status = array(); - foreach($agents as $key => $agent){ + foreach ($agents as $key => $agent) { $agents_status[] = agents_get_status($key); } - + $childrens = groups_get_childrens($id_group); - - foreach($childrens as $key => $child){ + + foreach ($childrens as $key => $child) { $agents_status[] = groups_get_status($key); } - + // Status is 0 for normal, 1 for critical, 2 for warning and 3/-1 for unknown. 4 for fired alerts - + // Checking if any agent has fired alert (4) - if(is_int(array_search(4,$agents_status))){ + if (is_int(array_search(4,$agents_status))) { return 4; } // Checking if any agent has critical status (1) - elseif(is_int(array_search(1,$agents_status))){ + elseif (is_int(array_search(1,$agents_status))) { return 1; } // Checking if any agent has warning status (2) - elseif(is_int(array_search(2,$agents_status))){ + elseif (is_int(array_search(2,$agents_status))) { return 2; } // Checking if any agent has unknown status (-1) - elseif(is_int(array_search(-1,$agents_status))){ + elseif (is_int(array_search(-1,$agents_status))) { return -1; } // Checking if any agents module has unknown status (3) - elseif(is_int(array_search(3,$agents_status))){ + elseif (is_int(array_search(3,$agents_status))) { return 3; } else { return 0; } - + return $status; } @@ -551,7 +551,7 @@ function groups_get_status ($id_group = 0) { * @return string The group name */ function groups_get_name ($id_group, $returnAllGroup = false) { - if($id_group > 0) + if ($id_group > 0) return (string) db_get_value ('nombre', 'tgrupo', 'id_grupo', (int) $id_group); elseif($returnAllGroup) return "All"; @@ -574,23 +574,23 @@ function groups_get_users ($id_group, $filter = false) { $resulta = array(); $resulta = db_get_all_rows_filter ("tusuario_perfil", $filter); - + // The users of the group All (0) will be also returned $filter['id_grupo'] = 0; $resultb = array(); $resultb = db_get_all_rows_filter ("tusuario_perfil", $filter); - - if($resulta == false && $resultb == false) + + if ($resulta == false && $resultb == false) $result = false; - elseif($resulta == false) + elseif ($resulta == false) $result = $resultb; - elseif($resultb == false) + elseif ($resultb == false) $result = $resulta; else $result = array_merge($resulta,$resultb); - + if ($result === false) - return array (); + return array (); //This removes stale users from the list. This can happen if switched to another auth scheme //(internal users still exist) or external auth has users removed/inactivated from the list (eg. LDAP) @@ -603,7 +603,7 @@ function groups_get_users ($id_group, $filter = false) { array_push ($retval, get_user_info ($user)); } } - + return $retval; } @@ -628,15 +628,15 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { if ($id_group < 0) return; - + // Get stats for this group $data = reporting_get_group_stats($id_group); - + if ($data["total_agents"] == 0) return; // Skip empty groups - + // Calculate entire row color - if ($data["monitor_alerts_fired"] > 0){ + if ($data["monitor_alerts_fired"] > 0) { echo ""; } elseif ($data["monitor_critical"] > 0) { @@ -674,7 +674,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { if ($data["total_agents"] > 0) echo ""; - + //Total agent field given by function reporting_get_group_stats return the number of agents //of this groups and its children. It was done to print empty fathers of children groups. //We need to recalculate the total agents for this group here to get only the total agents @@ -693,7 +693,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { echo $data["total_agents"]; echo ""; - + // Agents unknown if ($data["agents_unknown"] > 0) { echo ""; @@ -706,9 +706,9 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { else { echo ""; } - + // Monitors Unknown - if ($data["monitor_unknown"] > 0){ + if ($data["monitor_unknown"] > 0) { echo ""; echo ""; @@ -719,13 +719,13 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { else { echo ""; } - - + + // Monitors Not Init - if ($data["monitor_not_init"] > 0){ + if ($data["monitor_not_init"] > 0) { echo ""; - echo ""; + echo ""; echo $data["monitor_not_init"]; echo ""; echo ""; @@ -738,7 +738,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { // Monitors OK echo ""; if ($data["monitor_ok"] > 0) { - echo ""; + echo ""; echo $data["monitor_ok"]; echo ""; } @@ -746,12 +746,12 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { echo " "; } echo ""; - + // Monitors Warning - if ($data["monitor_warning"] > 0){ + if ($data["monitor_warning"] > 0) { echo ""; - echo ""; + echo ""; echo $data["monitor_warning"]; echo ""; echo ""; @@ -759,12 +759,12 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { else { echo ""; } - + // Monitors Critical - if ($data["monitor_critical"] > 0){ + if ($data["monitor_critical"] > 0) { echo ""; - echo ""; + echo ""; echo $data["monitor_critical"]; echo ""; echo ""; @@ -773,7 +773,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { echo ""; } // Alerts fired - if ($data["monitor_alerts_fired"] > 0){ + if ($data["monitor_alerts_fired"] > 0) { echo ""; echo ""; @@ -784,8 +784,8 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { else { echo ""; } - - + + echo ""; echo " "; @@ -804,7 +804,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { */ function groups_get_group_by_id($id_group) { $result_group = db_get_row('tgrupo', 'id_grupo', $id_group); - + return $result_group; } @@ -819,19 +819,20 @@ function groups_get_group_by_id($id_group) { */ function groups_create_group($group_name, $rest_values){ - if ($group_name == ""){ + if ($group_name == "") { return false; } $array_tmp = array('nombre' => $group_name); $values = array_merge($rest_values, $array_tmp); - + $check = db_get_value('nombre', 'tgrupo', 'nombre', $group_name); if (!$check){ $result = db_process_sql_insert('tgrupo', $values); - } else { + } + else { $result = false; } @@ -845,60 +846,58 @@ function groups_agent_unknown ($group_array) { if (empty ($group_array)) { return 0; - - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; // Agent of module group X and critical status $agents_critical = "SELECT tagente.id_agente - FROM tagente_estado, tagente, tagente_modulo - WHERE tagente_estado.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - AND estado = 1 - AND tagente_estado.utimestamp != 0 - AND tagente.id_grupo IN $group_clause - group by tagente.id_agente"; - - // Agent of module group X and warning status - $agents_warning = "SELECT tagente.id_agente - FROM tagente_estado, tagente, tagente_modulo - WHERE tagente_estado.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - AND estado = 2 - AND tagente_estado.utimestamp != 0 - AND tagente.id_grupo IN $group_clause - group by tagente.id_agente"; - - // Agent of module group X and unknown status - $agents_unknown = "SELECT tagente.id_agente - FROM tagente_estado, tagente, tagente_modulo - WHERE tagente_estado.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - AND estado = 3 - AND tagente_estado.utimestamp != 0 - AND tagente.id_grupo IN $group_clause - group by tagente.id_agente"; - - return db_get_sql ("SELECT COUNT(*) FROM ( SELECT DISTINCT tagente.id_agente - FROM tagente, tagente_modulo, tagente_estado - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - - AND tagente.id_grupo IN $group_clause - AND tagente.id_agente NOT IN ($agents_critical) - AND tagente.id_agente NOT IN ($agents_warning) - AND tagente.id_agente IN ($agents_unknown) ) AS t"); + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente_estado.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente.disabled = 0 + AND tagente_modulo.disabled = 0 + AND estado = 1 + AND tagente_estado.utimestamp != 0 + AND tagente.id_grupo IN $group_clause + GROUP by tagente.id_agente"; + // Agent of module group X and warning status + $agents_warning = "SELECT tagente.id_agente + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente_estado.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente.disabled = 0 + AND tagente_modulo.disabled = 0 + AND estado = 2 + AND tagente_estado.utimestamp != 0 + AND tagente.id_grupo IN $group_clause + GROUP by tagente.id_agente"; + + // Agent of module group X and unknown status + $agents_unknown = "SELECT tagente.id_agente + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente_estado.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente.disabled = 0 + AND tagente_modulo.disabled = 0 + AND estado = 3 + AND tagente_estado.utimestamp != 0 + AND tagente.id_grupo IN $group_clause + GROUP by tagente.id_agente"; + + return db_get_sql ("SELECT COUNT(*) FROM ( SELECT DISTINCT tagente.id_agente + FROM tagente, tagente_modulo, tagente_estado + WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente.id_grupo IN $group_clause + AND tagente.id_agente NOT IN ($agents_critical) + AND tagente.id_agente NOT IN ($agents_warning) + AND tagente.id_agente IN ($agents_unknown) ) AS t"); } // Get ok agents by using the status code in modules. @@ -908,10 +907,11 @@ function groups_agent_ok ($group_array) { if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)){ $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; @@ -925,7 +925,7 @@ function groups_agent_ok ($group_array) { AND estado = 1 AND tagente_estado.utimestamp != 0 AND tagente.id_grupo IN $group_clause - group by tagente.id_agente"; + group by tagente.id_agente"; // Agent of module group X and warning status $agents_warning = "SELECT tagente.id_agente diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 496a4ea704..17a5974d3e 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -46,13 +46,30 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, - $relative = false) { + $relative = false, $text_filter = '') { + + global $config; $parents = array(); $orphans = array(); $filter = array (); $filter['disabled'] = 0; + + if (!empty($text_filter)) { + switch ($config['dbtype']) { + case "mysql": + case "postgresql": + $filter[] = + '(nombre COLLATE utf8_general_ci LIKE "%' . $text_filter . '%")'; + break; + case "oracle": + $filter[] = + '(upper(nombre) LIKE upper("%' . $text_filter . '%"))'; + break; + } + } + if ($group >= 1) { $filter['id_grupo'] = $group; @@ -128,6 +145,8 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $node_count++; } + $stats = array(); + // Create nodes foreach ($nodes as $node_id => $node) { if ($center > 0 && ! networkmap_is_descendant ($node_id, $center, $parents)) { @@ -177,7 +196,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, } // Generate a dot graph definition for graphviz with groups -function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, $depth = 'all', $id_networkmap = 0) { +function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, $depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0) { global $config; $parents = array(); @@ -192,7 +211,12 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $id_groups = groups_get_id_recursive($group, true); foreach($id_groups as $id_group) { - if(check_acl($config["id_user"], $id_group, 'AR')) { + $add = false; + if (check_acl($config["id_user"], $id_group, 'AR')) { + $add = true; + } + + if ($add) { $groups[] = db_get_row ('tgrupo', 'id_grupo', $id_group); } } @@ -225,13 +249,19 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $node_count = 0; + $groups_hiden = array(); foreach ($nodes_groups as $node_group) { - $node_count++; // Save node parent information to define edges later if ($node_group['parent'] != "0" && $node_group['id_grupo'] != $group) { - $parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node']; + if ((!$dont_show_subgroups) || ($group == 0)) { + $parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node']; + } + else { + $groups_hiden[$node_group['id_grupo']] = 1; + continue; + } } else { $orphans[$node_count] = 1; @@ -251,6 +281,12 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, // Parse agents $nodes_agents = array(); foreach ($agents as $agent) { + if ($dont_show_subgroups) { + if (!empty($groups_hiden[$agent['id_grupo']])) { + continue; + } + } + $node_count ++; // Save node parent information to define edges later $parents[$node_count] = $agent['parent'] = $nodes_groups[$agent['id_grupo']]['id_node']; @@ -270,7 +306,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, foreach ($modules as $key => $module) { $node_count ++; $agent_module = modules_get_agentmodule($key); - $alerts_module = db_get_sql('SELECT count(*) as num + $alerts_module = db_get_sql('SELECT count(*) AS num FROM talert_template_modules WHERE id_agent_module = ' . $key); @@ -635,7 +671,7 @@ function networkmap_get_filter ($layout) { * * @return mixed New networkmap id if created. False if it could not be created. */ -function networkmap_create_networkmap ($name, $type = 'topology', $layout = 'radial', $nooverlap = true, $simple = false, $regenerate = true, $font_size = 12, $id_group = 0, $id_module_group = 0, $depth = 'all', $only_modules_with_alerts = false, $hide_policy_modules = false, $zoom = 1, $distance_nodes = 2.5, $center = 0) { +function networkmap_create_networkmap ($name, $type = 'topology', $layout = 'radial', $nooverlap = true, $simple = false, $regenerate = true, $font_size = 12, $id_group = 0, $id_module_group = 0, $depth = 'all', $only_modules_with_alerts = false, $hide_policy_modules = false, $zoom = 1, $distance_nodes = 2.5, $center = 0, $text_filter = '', $dont_show_subgroups = 0) { global $config; @@ -657,6 +693,8 @@ function networkmap_create_networkmap ($name, $type = 'topology', $layout = 'rad $values['distance_nodes'] = $distance_nodes; $values['center'] = $center; $values['id_user'] = $config['id_user']; + $values['text_filter'] = $text_filter; + $values['dont_show_subgroups'] = $dont_show_subgroups; return @db_process_sql_insert ('tnetwork_map', $values); } @@ -679,20 +717,20 @@ function networkmap_get_networkmap ($id_networkmap, $filter = false, $fields = f return false; if (! is_array ($filter)) $filter = array (); - + $filter['id_networkmap'] = $id_networkmap; if($check_user) { //If hte user has admin flag don't filter by user $user_info = users_get_user_by_id($config['id_user']); - + if (!$user_info['is_admin']) { $filter['id_user'] = $config['id_user']; } } $networkmap = db_get_row_filter ('tnetwork_map', $filter, $fields); - + return $networkmap; } diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index fd7ec9fe65..178380d6b1 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -59,8 +59,8 @@ function servers_get_names () { * This function forces a recon task to be queued by the server asap */ function servers_force_recon_task($id_recon_task) { - $values = array('utimestamp' => 0, 'status' => 1); - db_process_sql_update('trecon_task', $values, array('id_rt' => $id_recon_task)); + $values = array('utimestamp' => 0, 'status' => 1); + db_process_sql_update('trecon_task', $values, array('id_rt' => $id_recon_task)); } /** @@ -68,14 +68,14 @@ function servers_force_recon_task($id_recon_task) { * @return array with several data */ function servers_get_performance () { - + global $config; - + $data = array(); - + // For remote modules: // Get total modules running - + if ($config["realtimestats"] == 1){ $data["total_remote_modules"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente_modulo, tagente_estado, tagente @@ -86,18 +86,18 @@ function servers_get_performance () { else { $data["total_remote_modules"] = db_get_sql ("SELECT SUM(my_modules) FROM tserver WHERE server_type != 0"); } - + $data["avg_interval_remote_modules"] = db_get_sql ("SELECT AVG(module_interval) FROM tagente_modulo, tagente_estado, tagente WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND id_modulo != 1 AND module_interval > 0 AND utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente"); - + if ($data["avg_interval_remote_modules"] == 0) $data["remote_modules_rate"] = 0; else $data["remote_modules_rate"] = $data["total_remote_modules"] / $data["avg_interval_remote_modules"]; - + // For local modules (ignoring local modules with custom invervals for simplicity). if ($config["realtimestats"] == 1){ $data["total_local_modules"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) @@ -109,18 +109,18 @@ function servers_get_performance () { else { $data["total_local_modules"] = db_get_sql ("SELECT SUM(my_modules) FROM tserver WHERE server_type = 0"); } - + $data["avg_interval_local_modules"] = db_get_sql ("SELECT AVG(tagente.intervalo) FROM tagente WHERE disabled = 0 AND intervalo > 0"); - + if ($data["avg_interval_local_modules"] > 0){ $data["local_modules_rate"] = $data["total_local_modules"] / $data["avg_interval_local_modules"]; } else { $data["local_modules_rate"] = 0; } - + $data["total_modules"] = $data["total_local_modules"] + $data["total_remote_modules"]; - + return ($data); } @@ -233,38 +233,38 @@ function servers_get_info ($id_server = -1) { $id_modulo = 0; break; } - - if ($config["realtimestats"] == 0){ + + if ($config["realtimestats"] == 0) { // --------------------------------------------------------------- // Take data from database if not realtime stats // --------------------------------------------------------------- - + $server["lag"] = db_get_sql ("SELECT lag_time FROM tserver WHERE id_server = ".$server["id_server"]); $server["modulelag"] = db_get_sql ("SELECT lag_modules FROM tserver WHERE id_server = ".$server["id_server"]); $server["modules"] = db_get_sql ("SELECT my_modules FROM tserver WHERE id_server = ".$server["id_server"]); $server["modules_total"] = db_get_sql ("SELECT total_modules_running FROM tserver WHERE id_server = ".$server["id_server"]); - + } else { - + // --------------------------------------------------------------- // Take data in realtime // --------------------------------------------------------------- - - + + $server["module_lag"] = 0; $server["lag"] = 0; - + // Export server if ($server["server_type"] == 8) { - + // Get modules exported by this server $server["modules"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente AND tagente.server_name = '" . $server["name"] . "'"); - + // Get total exported modules $server["modules_total"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente"); - + // Get the module lag $server["module_lag"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) AS module_lag FROM tagente, tagent_module_inventory @@ -274,7 +274,7 @@ function servers_get_info ($id_server = -1) { AND tagente.server_name = '" . $server["name"] . "' AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.interval * 10) AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.interval"); - + // Get the lag $server["lag"] = db_get_sql ("SELECT AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory.interval) FROM tagente, tagent_module_inventory @@ -284,58 +284,59 @@ function servers_get_info ($id_server = -1) { AND tagente.server_name = '" . $server["name"] . "' AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.interval * 10) AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.interval"); - // Export server - } else if ($server["server_type"] == 7) { + } + else if ($server["server_type"] == 7) { // Get modules exported by this server $server["modules"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tserver_export WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export = tserver_export.id AND tserver_export.id_export_server = " . $server["id_server"]); - + // Get total exported modules $server["modules_total"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export != 0"); - + $server["lag"] = 0; $server["module_lag"] = 0; } // Recon server else if ($server["server_type"] == 3) { - + $server["name"] = ''.$server["name"].''; - + //Total jobs running on this recon server $server["modules"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE id_recon_server = ".$server["id_server"]); - + //Total recon jobs (all servers) $server["modules_total"] = db_get_sql ("SELECT COUNT(status) FROM trecon_task"); - + //Lag (take average active time of all active tasks) $server["module_lag"] = 0; - + switch ($config["dbtype"]) { case "mysql": $server["lag"] = db_get_sql ("SELECT UNIX_TIMESTAMP() - utimestamp from trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - + $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); break; case "postgresql": $server["lag"] = db_get_sql ("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - + $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); break; case "oracle": $server["lag"] = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - + $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); break; } - } else { - + } + else { + // --------------------------------------------------------------- // Data, Plugin, WMI, Network and Others - + $server["modules"] = db_get_sql ("SELECT count(tagente_estado.id_agente_modulo) FROM tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = ".$server["id_server"]); - + $server["modules_total"] = db_get_sql ("SELECT count(tagente_estado.id_agente_modulo) FROM tserver, tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = tserver.id_server AND tserver.server_type = ".$server["server_type"]); // Remote servers LAG Calculation (server_type != 0) @@ -423,34 +424,35 @@ function servers_get_info ($id_server = -1) { break; } } - + // Lag over current_interval * 2 is not lag, it's a timed out module - + if (!empty ($result["lag"])) { $server["lag"] = $result["lag"]; } - + if (!empty ($result["module_lag"])) { $server["module_lag"] = $result["module_lag"]; } } } // Take data for realtime mode - + if (isset($server["module_lag"])) $server["lag_txt"] = ($server["lag"] == 0 ? '-' : human_time_description_raw ($server["lag"])) . " / ". $server["module_lag"]; else $server["lag_txt"] = ""; - + if ($server["modules_total"] > 0) { $server["load"] = round ($server["modules"] / $server["modules_total"] * 100); - } else { + } + else { $server["load"] = 0; } - + //Push the raw data on the return stack $return[$server["id_server"]] = $server; } // Main foreach - + return $return; } @@ -477,7 +479,7 @@ function servers_get_name ($id_server) { */ function servers_show_type ($id) { global $config; - + switch ($id) { case 1: return html_print_image("images/database.png", true, array("title" => "Pandora FMS Data server")); @@ -512,7 +514,7 @@ function servers_show_type ($id) { */ function servers_check_status () { global $config; - + switch ($config["dbtype"]) { case "mysql": $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > NOW() - INTERVAL 15 MINUTE"; @@ -520,10 +522,9 @@ function servers_check_status () { case "postgresql": $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > NOW() - INTERVAL '15 MINUTE'"; break; - case "oracle": - $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > systimestamp - INTERVAL '15' MINUTE"; - break; + $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > systimestamp - INTERVAL '15' MINUTE"; + break; } $status = (int) db_get_sql ($sql); //Cast as int will assure a number value // This function should just ack of server down, not set it down. @@ -542,5 +543,4 @@ function servers_get_status ($id_server) { $serverinfo = servers_get_info ($id_server); return $serverinfo[$id_server]; } - -?> +?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index 16795c3e85..9931fd0470 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -432,15 +432,27 @@ foreach ($modules as $module) { echo " "; echo " x"; - switch($module["datos"]){ - case 10: echo "".__('TRACE').""; break; - case 20: echo "".__('DEBUG').""; break; - case 30: echo "".__('INFO').""; break; - case 40: echo "".__('WARN').""; break; - case 50: echo "".__('ERROR').""; break; - case 60: echo "".__('FATAL').""; break; + switch ($module["datos"]) { + case 10: + echo "".__('TRACE').""; + break; + case 20: + echo "".__('DEBUG').""; + break; + case 30: + echo "".__('INFO').""; + break; + case 40: + echo "".__('WARN').""; + break; + case 50: + echo "".__('ERROR').""; + break; + case 60: + echo "".__('FATAL').""; + break; } - + } else if (($module["id_tipo_modulo"] == 100) OR ($module['history_data'] == 0)) { echo ""; diff --git a/pandora_console/operation/agentes/networkmap.groups.php b/pandora_console/operation/agentes/networkmap.groups.php index ff36a97dc4..e925e7f58f 100644 --- a/pandora_console/operation/agentes/networkmap.groups.php +++ b/pandora_console/operation/agentes/networkmap.groups.php @@ -32,7 +32,7 @@ require_once ('include/functions_networkmap.php'); $filter = networkmap_get_filter ($layout); // Generate dot file -$graph = networkmap_generate_dot_groups (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $modwithalerts, $module_group, $hidepolicymodules, $depth, $id_networkmap); +$graph = networkmap_generate_dot_groups (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $modwithalerts, $module_group, $hidepolicymodules, $depth, $id_networkmap, $dont_show_subgroups); if ($graph === false) { ui_print_error_message (__('Map could not be generated')); diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index ac8b606f15..41728e1acb 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -62,6 +62,8 @@ if ($add_networkmap) { $simple = 0; $regen = 1; $font_size = 12; + $text_filter = ''; + $dont_show_subgroups = false; $group = 0; $module_group = 0; $center = 0; @@ -70,13 +72,20 @@ if ($add_networkmap) { $sql = db_get_value_filter('COUNT(name)', 'tnetwork_map', array('name' => "%$name")); if ($check) { - $id_networkmap = networkmap_create_networkmap("($sql) ".$name, $activeTab, $layout, $nooverlap, $simple, $regen, $font_size, $group, $module_group, $depth, $modwithalerts, $hidepolicymodules, $zoom, $ranksep, $center); + $id_networkmap = networkmap_create_networkmap("($sql) ".$name, + $activeTab, $layout, $nooverlap, $simple, $regen, + $font_size, $group, $module_group, $depth, $modwithalerts, + $hidepolicymodules, $zoom, $ranksep, $center, $text_filter, + $dont_show_subgroups); $message = ui_print_result_message ($id_networkmap, __('Network map created successfully'), __('Could not create network map'), '', true); } else { - $id_networkmap = networkmap_create_networkmap($name, $activeTab, $layout, $nooverlap, $simple, $regen, $font_size, $group, $module_group, $depth, $modwithalerts, $hidepolicymodules, $zoom, $ranksep, $center); + $id_networkmap = networkmap_create_networkmap($name, $activeTab, + $layout, $nooverlap, $simple, $regen, $font_size, $group, + $module_group, $depth, $modwithalerts, $hidepolicymodules, + $zoom, $ranksep, $center, $text_filter, $dont_show_subgroups); $message = ui_print_result_message ($id_networkmap, __('Network map created successfully'), __('Could not create network map'), '', true); @@ -96,6 +105,8 @@ if($save_networkmap || $update_networkmap) { $regen = (int) get_parameter ('regen', 0); $show_snmp_modules = (int) get_parameter ('show_snmp_modules', 0); $font_size = (int) get_parameter ('font_size', 12); + $text_filter = get_parameter ('text_filter', ''); + $dont_show_subgroups = (bool)get_parameter ('dont_show_subgroups', 0); $group = (int) get_parameter ('group', 0); $module_group = (int) get_parameter ('module_group', 0); $center = (int) get_parameter ('center', 0); @@ -105,11 +116,25 @@ if($save_networkmap || $update_networkmap) { if($save_networkmap) { if (!$check || $subcheck == $name) { - $result = networkmap_update_networkmap($id_networkmap, array('name' => $name, 'type' => $activeTab, 'layout' => $layout, - 'nooverlap' => $nooverlap, 'simple' => $simple, 'regenerate' => $regen, 'font_size' => $font_size, - 'id_group' => $group, 'id_module_group' => $module_group, 'depth' => $depth, 'only_modules_with_alerts' => $modwithalerts, - 'hide_policy_modules' => $hidepolicymodules, 'zoom' => $zoom, 'distance_nodes' => $ranksep, 'center' => $center, - 'show_snmp_modules' => (int)$show_snmp_modules)); + $result = networkmap_update_networkmap($id_networkmap, + array('name' => $name, + 'type' => $activeTab, + 'layout' => $layout, + 'nooverlap' => $nooverlap, + 'simple' => $simple, + 'regenerate' => $regen, + 'font_size' => $font_size, + 'id_group' => $group, + 'id_module_group' => $module_group, + 'depth' => $depth, + 'only_modules_with_alerts' => $modwithalerts, + 'hide_policy_modules' => $hidepolicymodules, + 'zoom' => $zoom, + 'distance_nodes' => $ranksep, + 'text_filter' => $text_filter, + 'dont_show_subgroups' => $dont_show_subgroups, + 'center' => $center, + 'show_snmp_modules' => (int)$show_snmp_modules)); $message = ui_print_result_message ($result, __('Network map saved successfully'), @@ -133,14 +158,14 @@ if($nomaps && $id_networkmap == 0) { }*/ // If the map id is not defined, we set the first id of the active type -if(!$nomaps && $id_networkmap == 0) { - $networkmaps_of_type = networkmap_get_networkmaps('', $activeTab); - if($networkmaps_of_type !== false){ - $id_networkmap = reset(array_keys($networkmaps_of_type)); - } +if (!$nomaps && $id_networkmap == 0) { + $networkmaps_of_type = networkmap_get_networkmaps('', $activeTab); + if ($networkmaps_of_type !== false) { + $id_networkmap = reset(array_keys($networkmaps_of_type)); + } } -if(!$update_networkmap && !$save_networkmap && $id_networkmap != 0) { +if (!$update_networkmap && !$save_networkmap && $id_networkmap != 0) { $networkmap_data = networkmap_get_networkmap($id_networkmap); $layout = $networkmap_data['layout']; @@ -154,6 +179,8 @@ if(!$update_networkmap && !$save_networkmap && $id_networkmap != 0) { $regen = $networkmap_data['regenerate']; $show_snmp_modules = $networkmap_data['show_snmp_modules']; $font_size = $networkmap_data['font_size']; + $text_filter = $networkmap_data['text_filter']; + $dont_show_subgroups = $networkmap_data['dont_show_subgroups']; $group = $networkmap_data['id_group']; $module_group = $networkmap_data['id_module_group']; $center = $networkmap_data['center']; @@ -161,7 +188,7 @@ if(!$update_networkmap && !$save_networkmap && $id_networkmap != 0) { $activeTab = $networkmap_data['type']; } -if($recenter_networkmap) { +if ($recenter_networkmap) { $center = (int) get_parameter ('center', 0); } @@ -216,7 +243,8 @@ if (!$nomaps && $id_networkmap != 0) { &tab='.$activeTab.'&save_networkmap=1&name='.$name.'&group='.$group.' &layout='.$layout.'&nooverlap='.$nooverlap.'&simple='.$simple.'&regen='.$regen.' &zoom='.$zoom.'&ranksep='.$ranksep.'&fontsize='.$font_size.'&depth='.$depth.' - &modwithalerts='.$modwithalerts.'&hidepolicymodules='.$hidepolicymodules.' + &modwithalerts='.$modwithalerts.'&text_filter='.$text_filter. + '&dont_show_subgroups='.$dont_show_subgroups.'&hidepolicymodules='.$hidepolicymodules.' &module_group='.$module_group.'&pure='.$pure.'&hidden_options='.(int)$hidden_options.' &show_snmp_modules='.(int)$show_snmp_modules.'">' . html_print_image("images/file.png", true, array ("title" => __('Save map'))) .''); @@ -263,77 +291,57 @@ $layout_array = array ( 'flat' => 'flat'); $options_form = '
'; -$options_form .= ''; -$options_form .= '
'; -$options_form .= ''; -$options_form .= ''; -$options_form .= ''; -$options_form .= ''; + + + +unset($table); +$table->width = '95%'; +$table->class = 'databox'; +$table->data = array(); +$table->data[0][] = __('Name:') . ' ' . + html_print_input_text ('name', $name, '', 10, 25, true); +$table->data[0][] = __('Group:') . ' ' . + html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true); if ($activeTab == 'groups' || $activeTab == 'policies') { - $options_form .= ''; + $table->data[0][] = __('Module group') . ' ' . + html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); } - if ($activeTab == 'topology') { - $options_form .= ''; + $table->data[0][] = __('Show interfaces') . ' ' . + html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true); } - -$options_form .= ''; - +$table->data[0][] = __('Layout') . ' ' . + html_print_select ($layout_array, 'layout', $layout, '', '', '', true); if ($activeTab == 'groups') { - $options_form .= ''; + $table->data[0][] = __('Depth') . ' ' . + html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); } if ($activeTab == 'policies') { - $options_form .= ''; + $table->data[0][] = __('Depth') . ' ' . + html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); } - -$options_form .= '
'; -$options_form .= __('Name') . '
'; -$options_form .= html_print_input_text ('name', $name, '', 10, 25, true); -$options_form .= '
' . __('Group') . '
'; -$options_form .= html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true); -$options_form .= '
' . __('Module group') . '
'; - $options_form .= html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); - $options_form .= '
' . __('Show interfaces') . '
'; - $options_form .= html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true); - $options_form .= '
' . __('Layout') . '
'; -$options_form .= html_print_select ($layout_array, 'layout', $layout, '', '', '', true); -$options_form .= '
' . __('Depth') . '
'; $depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'group' => __('Groups')); - $options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); - $options_form .= '
' . __('Depth') . '
'; $depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'policy' => __('Policies')); - $options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); - $options_form .= '
'; -$options_form .= '
'; -$options_form .= ''; -$options_form .= ''; - +$table->data[1][] = __('No Overlap') . ' ' . + html_print_checkbox ('nooverlap', '1', $nooverlap, true); if (($activeTab == 'groups' || $activeTab == 'policies') && $depth == 'all') { - $options_form .= ''; + $table->data[1][] = __('Only modules with alerts') . ' ' . + html_print_checkbox ('modwithalerts', '1', $modwithalerts, true); if ($activeTab == 'groups') { if($config['enterprise_installed']) { - $options_form .= ''; + $table->data[1][] = __('Hide policy modules') . ' ' . + html_print_checkbox ('hidepolicymodules', '1', $hidepolicymodules, true); } } } +$table->data[1][] = __('Simple') . ' ' . + html_print_checkbox ('simple', '1', $simple, true); -$options_form .= ''; - -$options_form .= ''; - +$table->data[1][] = __('Regenerate') . ' ' . + html_print_checkbox ('regen', '1', $regen, true); if ($pure == "1") { // Zoom $zoom_array = array ( @@ -345,29 +353,31 @@ if ($pure == "1") { '5' => 'x10', ); - $options_form .= ''; + $table->data[1][] = __('Zoom') . ' ' . + html_print_select ($zoom_array, 'zoom', $zoom, '', '', '', true, false, false, false); } - if ($nooverlap == 1) { - $options_form .= ""; + $table->data[1][] = __('Distance between nodes') . ' ' . + html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true); +} +$table->data[1][] = __('Font') . ' ' . + html_print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 2, 4, true); +$table->data[2][] = __('Free text for search (*):') . ' ' . + html_print_input_text('text_filter', $text_filter, '', 30, 100, true); +if ($activeTab == 'groups') { + $table->data[2][] = __('Don\'t show subgroups:') . + ui_print_help_tip(__('Only run with it is filter for any group'), true) . + ' ' . + html_print_checkbox ('dont_show_subgroups', '1', $dont_show_subgroups, true); } -$options_form .= ""; - -$options_form .= ''; -$options_form .= '
' . __('No Overlap') . '
'; -$options_form .= html_print_checkbox ('nooverlap', '1', $nooverlap, true); -$options_form .= '
' . __('Only modules with alerts') . '
'; - $options_form .= html_print_checkbox ('modwithalerts', '1', $modwithalerts, true); - $options_form .= '
' . __('Hide policy modules') . '
'; - $options_form .= html_print_checkbox ('hidepolicymodules', '1', $hidepolicymodules, true); - $options_form .= '
' . __('Simple') . '
'; -$options_form .= html_print_checkbox ('simple', '1', $simple, true); -$options_form .= '
' . __('Regenerate') . '
'; -$options_form .= html_print_checkbox ('regen', '1', $regen, true); -$options_form .= '
' . __('Zoom') . '
'; - $options_form .= html_print_select ($zoom_array, 'zoom', $zoom, '', '', '', true, false, false, false); - $options_form .= '
"; - $options_form .= __('Distance between nodes') . '
'; - $options_form .= html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true); - $options_form .= "
"; -$options_form .= __('Font') . '
'; -$options_form .= html_print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 2, 4, true); -$options_form .= "
'; -$options_form .= html_print_input_hidden('update_networkmap',1, true); -$options_form .= html_print_input_hidden('hidden_options',0, true); -$options_form .= html_print_submit_button (__('Apply'), "updbutton", false, 'class="sub next"', true); -$options_form .= '
'; +$options_form .= html_print_input_hidden('update_networkmap',1, true) . + html_print_input_hidden('hidden_options',0, true); +$options_form .= html_print_table ($table, true); +$options_form .= "
" . + html_print_submit_button (__('Apply'), "updbutton", false, 'class="sub next"', true) . + "
"; +$options_form .= ''; ui_toggle($options_form, __('Map options'), '', $hidden_options); @@ -377,7 +387,7 @@ if($id_networkmap != 0) { require_once('operation/agentes/networkmap.groups.php'); break; case 'policies': - require_once(''.ENTERPRISE_DIR.'/operation/policies/networkmap.policies.php'); + require_once(ENTERPRISE_DIR . '/operation/policies/networkmap.policies.php'); break; default: case 'topology': diff --git a/pandora_console/operation/agentes/networkmap.topology.php b/pandora_console/operation/agentes/networkmap.topology.php index ce5e01076a..65f7a7893b 100644 --- a/pandora_console/operation/agentes/networkmap.topology.php +++ b/pandora_console/operation/agentes/networkmap.topology.php @@ -32,7 +32,7 @@ require_once ('include/functions_networkmap.php'); $filter = networkmap_get_filter ($layout); // Generate dot file -$graph = networkmap_generate_dot (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $id_networkmap, $show_snmp_modules, true, true); +$graph = networkmap_generate_dot (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $id_networkmap, $show_snmp_modules, true, true, $text_filter); if ($graph === false) { ui_print_error_message (__('Map could not be generated')); @@ -101,5 +101,4 @@ else { return; } - -?> +?> \ No newline at end of file diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 7a23969b13..bddbd4f83d 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -1474,9 +1474,9 @@ CREATE TABLE tgroup_stat ( utimestamp NUMBER(10, 0) default 0 NOT NULL ); --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table "tnetwork_map" --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE tnetwork_map ( id_networkmap NUMBER(10, 0) NOT NULL PRIMARY KEY, id_user VARCHAR2(60) NOT NULL, @@ -1497,7 +1497,9 @@ CREATE TABLE tnetwork_map ( distance_nodes BINARY_DOUBLE default 2.5, center NUMBER(10, 0) default 0 NOT NULL, contracted_nodes CLOB, - show_snmp_modules NUMBER(5, 0) default 0 NOT NULL + show_snmp_modules NUMBER(5, 0) default 0 NOT NULL, + text_filter VARCHAR(100) DEFAULT '', + dont_show_subgroups NUMBER(10, 0) default 0 NOT NULL ); CREATE SEQUENCE tnetwork_map_s INCREMENT BY 1 START WITH 1; diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 6f00710646..458e33c808 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -1233,9 +1233,9 @@ CREATE TABLE "tgis_map_layer_has_tagente" ( CREATE INDEX "tgis_map_layer_has_tagente_tgis_map_layer_id_tmap_layer_idx" ON "tgis_map_layer_has_tagente"("tgis_map_layer_id_tmap_layer"); CREATE INDEX "tgis_map_layer_has_tagente_tagente_id_agente_idx" ON "tgis_map_layer_has_tagente"("tagente_id_agente"); --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table "tgroup_stat" --- ----------------------------------------------------- +------------------------------------------------------------------------ --Table to store global system stats per group CREATE TABLE "tgroup_stat" ( "id_group" INTEGER NOT NULL default 0 PRIMARY KEY, @@ -1252,9 +1252,9 @@ CREATE TABLE "tgroup_stat" ( "utimestamp" INTEGER NOT NULL default 0 ); --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table "tnetwork_map" --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE "tnetwork_map" ( "id_networkmap" SERIAL NOT NULL PRIMARY KEY, "id_user" VARCHAR(60) NOT NULL, @@ -1275,21 +1275,23 @@ CREATE TABLE "tnetwork_map" ( "distance_nodes" DOUBLE PRECISION default 2.5, "center" INTEGER NOT NULL default 0, "contracted_nodes" TEXT, - "show_snmp_modules" SMALLINT NOT NULL default 0 + "show_snmp_modules" SMALLINT NOT NULL default 0, + "text_filter" VARCHAR(100) DEFAULT '', + "dont_show_subgroups" INTEGER NOT NULL default 0 ); --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table "tsnmp_filter" --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE "tsnmp_filter" ( "id_snmp_filter" SERIAL NOT NULL PRIMARY KEY, "description" varchar(255) default '', "filter" varchar(255) default '' ); --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table "tagent_custom_fields" --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE "tagent_custom_fields" ( "id_field" SERIAL NOT NULL PRIMARY KEY, "name" varchar(45) NOT NULL default '', diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f1c0779418..bcffed8f06 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -24,9 +24,9 @@ -- Priority : 3 - Warning (yellow) -- Priority : 4 - Critical (red) --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `taddress` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `taddress` ( `id_a` int(10) unsigned NOT NULL auto_increment, `ip` varchar(60) NOT NULL default '', @@ -35,9 +35,9 @@ CREATE TABLE IF NOT EXISTS `taddress` ( KEY `ip` (`ip`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `taddress_agent` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `taddress_agent` ( `id_ag` bigint(20) unsigned NOT NULL auto_increment, `id_a` bigint(20) unsigned NOT NULL default '0', @@ -45,9 +45,9 @@ CREATE TABLE IF NOT EXISTS `taddress_agent` ( PRIMARY KEY (`id_ag`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tagente` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tagente` ( `id_agente` int(10) unsigned NOT NULL auto_increment, `nombre` varchar(600) BINARY NOT NULL default '', @@ -610,106 +610,117 @@ CREATE TABLE IF NOT EXISTS `tmensajes` ( PRIMARY KEY (`id_mensaje`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tmodule_group` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tmodule_group` ( `id_mg` tinyint(4) unsigned NOT NULL auto_increment, `name` varchar(150) NOT NULL default '', PRIMARY KEY (`id_mg`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +------------------------------------------------------------------------ +-- Table `tnetwork_component` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tnetwork_component` ( - `id_nc` int(10) unsigned NOT NULL auto_increment, - `name` varchar(80) NOT NULL, - `description` varchar(250) default NULL, - `id_group` int(6) NOT NULL default '1', - `type` smallint(6) NOT NULL default '6', - `max` bigint(20) NOT NULL default '0', - `min` bigint(20) NOT NULL default '0', - `module_interval` mediumint(8) unsigned NOT NULL default '0', - `tcp_port` int(10) unsigned NOT NULL default '0', - `tcp_send` text NOT NULL, - `tcp_rcv` text NOT NULL, - `snmp_community` varchar(255) NOT NULL default 'NULL', - `snmp_oid` varchar(400) NOT NULL, - `id_module_group` tinyint(4) unsigned NOT NULL default '0', - `id_modulo` int(10) unsigned default '0', - `id_plugin` INTEGER unsigned default '0', - `plugin_user` text, - `plugin_pass` text, - `plugin_parameter` text, - `max_timeout` tinyint(3) unsigned default '0', - `history_data` tinyint(1) unsigned default '1', - `min_warning` double(18,2) default 0, - `max_warning` double(18,2) default 0, - `str_warning` text, - `min_critical` double(18,2) default 0, - `max_critical` double(18,2) default 0, - `str_critical` text, - `min_ff_event` int(4) unsigned default '0', - `custom_string_1` text, - `custom_string_2` text, - `custom_string_3` text, - `custom_integer_1` int(10) default 0, - `custom_integer_2` int(10) default 0, - `post_process` double(18,5) default 0, - `unit` text, - `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard', - `only_metaconsole` tinyint(1) unsigned default '0', - `macros` text, - `critical_instructions` text NOT NULL default '', - `warning_instructions` text NOT NULL default '', - `unknown_instructions` text NOT NULL default '', - `critical_inverse` tinyint(1) unsigned default '0', - `warning_inverse` tinyint(1) unsigned default '0', - PRIMARY KEY (`id_nc`) + `id_nc` int(10) unsigned NOT NULL auto_increment, + `name` varchar(80) NOT NULL, + `description` varchar(250) default NULL, + `id_group` int(6) NOT NULL default '1', + `type` smallint(6) NOT NULL default '6', + `max` bigint(20) NOT NULL default '0', + `min` bigint(20) NOT NULL default '0', + `module_interval` mediumint(8) unsigned NOT NULL default '0', + `tcp_port` int(10) unsigned NOT NULL default '0', + `tcp_send` text NOT NULL, + `tcp_rcv` text NOT NULL, + `snmp_community` varchar(255) NOT NULL default 'NULL', + `snmp_oid` varchar(400) NOT NULL, + `id_module_group` tinyint(4) unsigned NOT NULL default '0', + `id_modulo` int(10) unsigned default '0', + `id_plugin` INTEGER unsigned default '0', + `plugin_user` text, + `plugin_pass` text, + `plugin_parameter` text, + `max_timeout` tinyint(3) unsigned default '0', + `history_data` tinyint(1) unsigned default '1', + `min_warning` double(18,2) default 0, + `max_warning` double(18,2) default 0, + `str_warning` text, + `min_critical` double(18,2) default 0, + `max_critical` double(18,2) default 0, + `str_critical` text, + `min_ff_event` int(4) unsigned default '0', + `custom_string_1` text, + `custom_string_2` text, + `custom_string_3` text, + `custom_integer_1` int(10) default 0, + `custom_integer_2` int(10) default 0, + `post_process` double(18,5) default 0, + `unit` text, + `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard', + `only_metaconsole` tinyint(1) unsigned default '0', + `macros` text, + `critical_instructions` text NOT NULL default '', + `warning_instructions` text NOT NULL default '', + `unknown_instructions` text NOT NULL default '', + `critical_inverse` tinyint(1) unsigned default '0', + `warning_inverse` tinyint(1) unsigned default '0', + PRIMARY KEY (`id_nc`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +------------------------------------------------------------------------ +-- Table `tnetwork_component_group` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tnetwork_component_group` ( - `id_sg` int(10) unsigned NOT NULL auto_increment, - `name` varchar(200) NOT NULL default '', - `parent` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`id_sg`) + `id_sg` int(10) unsigned NOT NULL auto_increment, + `name` varchar(200) NOT NULL default '', + `parent` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`id_sg`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +------------------------------------------------------------------------ +-- Table `tnetwork_profile` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tnetwork_profile` ( - `id_np` int(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `description` varchar(250) default '', - PRIMARY KEY (`id_np`) + `id_np` int(10) unsigned NOT NULL auto_increment, + `name` varchar(100) NOT NULL default '', + `description` varchar(250) default '', + PRIMARY KEY (`id_np`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +------------------------------------------------------------------------ +-- Table `tnetwork_profile_component` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tnetwork_profile_component` ( - `id_nc` mediumint(8) unsigned NOT NULL default '0', - `id_np` mediumint(8) unsigned NOT NULL default '0', - KEY `id_np` (`id_np`) + `id_nc` mediumint(8) unsigned NOT NULL default '0', + `id_np` mediumint(8) unsigned NOT NULL default '0', + KEY `id_np` (`id_np`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +------------------------------------------------------------------------ +-- Table `tnota` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tnota` ( - `id_nota` bigint(6) unsigned zerofill NOT NULL auto_increment, - `id_incident` bigint(6) unsigned zerofill NOT NULL, - `id_usuario` varchar(100) NOT NULL default '0', - `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, - `nota` mediumtext NOT NULL, - PRIMARY KEY (`id_nota`), - KEY `id_incident` (`id_incident`) + `id_nota` bigint(6) unsigned zerofill NOT NULL auto_increment, + `id_incident` bigint(6) unsigned zerofill NOT NULL, + `id_usuario` varchar(100) NOT NULL default '0', + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, + `nota` mediumtext NOT NULL, + PRIMARY KEY (`id_nota`), + KEY `id_incident` (`id_incident`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `torigen` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `torigen` ( `origen` varchar(100) NOT NULL default '' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tperfil` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tperfil` ( `id_perfil` int(10) unsigned NOT NULL auto_increment, `name` TEXT NOT NULL, @@ -726,9 +737,9 @@ CREATE TABLE IF NOT EXISTS `tperfil` ( PRIMARY KEY (`id_perfil`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `trecon_script` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `trecon_script` ( `id_recon_script` int(10) NOT NULL auto_increment, `name` varchar(100) default '', @@ -737,9 +748,9 @@ CREATE TABLE IF NOT EXISTS `trecon_script` ( PRIMARY KEY (`id_recon_script`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `trecon_task` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `trecon_task` ( `id_rt` int(10) unsigned NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', @@ -769,9 +780,9 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tserver` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tserver` ( `id_server` int(10) unsigned NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', @@ -817,9 +828,9 @@ CREATE TABLE IF NOT EXISTS `tserver` ( -- 9 web -- TODO: drop 2.x xxxx_server fields, unused since server_type exists. --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tsesion` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tsesion` ( `id_sesion` bigint(20) unsigned NOT NULL auto_increment, `id_usuario` varchar(60) NOT NULL default '0', @@ -833,9 +844,9 @@ CREATE TABLE IF NOT EXISTS `tsesion` ( KEY `idx_user` (`id_usuario`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `ttipo_modulo` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `ttipo_modulo` ( `id_tipo` smallint(5) unsigned NOT NULL auto_increment, `nombre` varchar(100) NOT NULL default '', @@ -845,9 +856,9 @@ CREATE TABLE IF NOT EXISTS `ttipo_modulo` ( PRIMARY KEY (`id_tipo`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `ttrap` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `ttrap` ( `id_trap` bigint(20) unsigned NOT NULL auto_increment, `source` varchar(50) NOT NULL default '', @@ -870,9 +881,9 @@ CREATE TABLE IF NOT EXISTS `ttrap` ( INDEX status (`status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tusuario` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tusuario` ( `id_user` varchar(60) NOT NULL default '0', `fullname` varchar(255) NOT NULL, @@ -906,53 +917,64 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( UNIQUE KEY `id_user` (`id_user`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +------------------------------------------------------------------------ +-- Table `tusuario_perfil` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tusuario_perfil` ( - `id_up` bigint(10) unsigned NOT NULL auto_increment, - `id_usuario` varchar(100) NOT NULL default '', - `id_perfil` int(10) unsigned NOT NULL default '0', - `id_grupo` int(10) NOT NULL default '0', - `assigned_by` varchar(100) NOT NULL default '', - `id_policy` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id_up`) + `id_up` bigint(10) unsigned NOT NULL auto_increment, + `id_usuario` varchar(100) NOT NULL default '', + `id_perfil` int(10) unsigned NOT NULL default '0', + `id_grupo` int(10) NOT NULL default '0', + `assigned_by` varchar(100) NOT NULL default '', + `id_policy` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`id_up`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +------------------------------------------------------------------------ +-- Table `tnews` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tnews` ( - `id_news` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `author` varchar(255) NOT NULL DEFAULT '', - `subject` varchar(255) NOT NULL DEFAULT '', - `text` TEXT NOT NULL, - `timestamp` DATETIME NOT NULL DEFAULT 0, - PRIMARY KEY(`id_news`) + `id_news` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `author` varchar(255) NOT NULL DEFAULT '', + `subject` varchar(255) NOT NULL DEFAULT '', + `text` TEXT NOT NULL, + `timestamp` DATETIME NOT NULL DEFAULT 0, + PRIMARY KEY(`id_news`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +------------------------------------------------------------------------ +-- Table `tgraph` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tgraph` ( - `id_graph` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_user` varchar(100) NOT NULL default '', - `name` varchar(150) NOT NULL default '', - `description` TEXT NOT NULL, - `period` int(11) NOT NULL default '0', - `width` smallint(5) UNSIGNED NOT NULL DEFAULT 0, - `height` smallint(5) UNSIGNED NOT NULL DEFAULT 0, - `private` tinyint(1) UNSIGNED NOT NULL default 0, - `events` tinyint(1) UNSIGNED NOT NULL default 0, - `stacked` tinyint(1) UNSIGNED NOT NULL default 0, - `id_group` mediumint(8) unsigned NULL default 0, - `id_graph_template` int(11) NOT NULL default 0, - PRIMARY KEY(`id_graph`) + `id_graph` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` varchar(100) NOT NULL default '', + `name` varchar(150) NOT NULL default '', + `description` TEXT NOT NULL, + `period` int(11) NOT NULL default '0', + `width` smallint(5) UNSIGNED NOT NULL DEFAULT 0, + `height` smallint(5) UNSIGNED NOT NULL DEFAULT 0, + `private` tinyint(1) UNSIGNED NOT NULL default 0, + `events` tinyint(1) UNSIGNED NOT NULL default 0, + `stacked` tinyint(1) UNSIGNED NOT NULL default 0, + `id_group` mediumint(8) unsigned NULL default 0, + `id_graph_template` int(11) NOT NULL default 0, + PRIMARY KEY(`id_graph`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +------------------------------------------------------------------------ +-- Table `tgraph_source` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tgraph_source` ( - `id_gs` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_graph` int(11) NOT NULL default 0, - `id_agent_module` int(11) NOT NULL default 0, - `weight` float(5,3) NOT NULL DEFAULT 0, - PRIMARY KEY(`id_gs`) + `id_gs` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_graph` int(11) NOT NULL default 0, + `id_agent_module` int(11) NOT NULL default 0, + `weight` float(5,3) NOT NULL DEFAULT 0, + PRIMARY KEY(`id_gs`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `treport` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `treport` ( `id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `id_user` varchar(100) NOT NULL default '', @@ -971,9 +993,9 @@ CREATE TABLE IF NOT EXISTS `treport` ( PRIMARY KEY(`id_report`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `treport_content` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `treport_content` ( `id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `id_report` INTEGER UNSIGNED NOT NULL default 0, @@ -1017,51 +1039,63 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +------------------------------------------------------------------------ +-- Table `treport_content_sla_combined` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` ( - `id` INTEGER UNSIGNED NOT NULL auto_increment, - `id_report_content` INTEGER UNSIGNED NOT NULL, - `id_agent_module` int(10) unsigned NOT NULL, - `sla_max` double(18,2) NOT NULL default 0, - `sla_min` double(18,2) NOT NULL default 0, - `sla_limit` double(18,2) NOT NULL default 0, - `server_name` text, - PRIMARY KEY(`id`), - FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) - ON UPDATE CASCADE ON DELETE CASCADE + `id` INTEGER UNSIGNED NOT NULL auto_increment, + `id_report_content` INTEGER UNSIGNED NOT NULL, + `id_agent_module` int(10) unsigned NOT NULL, + `sla_max` double(18,2) NOT NULL default 0, + `sla_min` double(18,2) NOT NULL default 0, + `sla_limit` double(18,2) NOT NULL default 0, + `server_name` text, + PRIMARY KEY(`id`), + FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) + ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +------------------------------------------------------------------------ +-- Table `treport_content_item` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `treport_content_item` ( - `id` INTEGER UNSIGNED NOT NULL auto_increment, - `id_report_content` INTEGER UNSIGNED NOT NULL, - `id_agent_module` int(10) unsigned NOT NULL, - `server_name` text, - `operation` text, - PRIMARY KEY(`id`), - FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) - ON UPDATE CASCADE ON DELETE CASCADE + `id` INTEGER UNSIGNED NOT NULL auto_increment, + `id_report_content` INTEGER UNSIGNED NOT NULL, + `id_agent_module` int(10) unsigned NOT NULL, + `server_name` text, + `operation` text, + PRIMARY KEY(`id`), + FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) + ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +------------------------------------------------------------------------ +-- Table `treport_custom_sql` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `treport_custom_sql` ( - `id` INTEGER UNSIGNED NOT NULL auto_increment, - `name` varchar(150) NOT NULL default '', - `sql` TEXT, - PRIMARY KEY(`id`) + `id` INTEGER UNSIGNED NOT NULL auto_increment, + `name` varchar(150) NOT NULL default '', + `sql` TEXT, + PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; +------------------------------------------------------------------------ +-- Table `tlayout` +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tlayout` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL, - `id_group` INTEGER UNSIGNED NOT NULL, - `background` varchar(200) NOT NULL, - `fullscreen` tinyint(1) UNSIGNED NOT NULL default 0, - `height` INTEGER UNSIGNED NOT NULL default 0, - `width` INTEGER UNSIGNED NOT NULL default 0, - PRIMARY KEY(`id`) + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `id_group` INTEGER UNSIGNED NOT NULL, + `background` varchar(200) NOT NULL, + `fullscreen` tinyint(1) UNSIGNED NOT NULL default 0, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tlayout_data` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tlayout_data` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `id_layout` INTEGER UNSIGNED NOT NULL default 0, @@ -1083,9 +1117,9 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` ( PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplugin` --- ----------------------------------------------------- +------------------------------------------------------------------------ -- The fields "net_dst_opt", "net_port_opt", "user_opt" and -- "pass_opt" are deprecated for the 5.1. CREATE TABLE IF NOT EXISTS `tplugin` ( @@ -1104,18 +1138,18 @@ CREATE TABLE IF NOT EXISTS `tplugin` ( PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tmodule` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tmodule` ( `id_module` int(11) unsigned NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', PRIMARY KEY (`id_module`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tserver_export` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tserver_export` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', @@ -1134,9 +1168,9 @@ CREATE TABLE IF NOT EXISTS `tserver_export` ( INDEX id_export_server (`id_export_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tserver_export_data` --- ----------------------------------------------------- +------------------------------------------------------------------------ -- id_export_server is real pandora fms export server process that manages this server -- id is the "destination" server to export CREATE TABLE IF NOT EXISTS `tserver_export_data` ( @@ -1150,9 +1184,9 @@ CREATE TABLE IF NOT EXISTS `tserver_export_data` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tplanned_downtime` ( `id` MEDIUMINT( 8 ) NOT NULL AUTO_INCREMENT, `name` VARCHAR( 100 ) NOT NULL, @@ -1179,9 +1213,9 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime` ( PRIMARY KEY ( `id` ) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime_agents` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tplanned_downtime_agents` ( `id` int(20) unsigned NOT NULL auto_increment, `id_agent` mediumint(8) unsigned NOT NULL default '0', @@ -1192,9 +1226,9 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime_agents` ( ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime_modules` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` ( `id` int(20) unsigned NOT NULL auto_increment, `id_agent` mediumint(8) unsigned NOT NULL default '0', @@ -1206,9 +1240,9 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- GIS extension Tables --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tgis_data_history` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tgis_data_history` ( `id_tgis_data` INT NOT NULL AUTO_INCREMENT COMMENT 'key of the table' , `longitude` DOUBLE NOT NULL , @@ -1227,50 +1261,50 @@ ENGINE = InnoDB COMMENT = 'Table to store historical GIS information of the agents'; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tgis_data_status` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tgis_data_status` ( - `tagente_id_agente` INT(10) UNSIGNED NOT NULL COMMENT 'Reference to the agent' , - `current_longitude` DOUBLE NOT NULL COMMENT 'Last received longitude', - `current_latitude` DOUBLE NOT NULL COMMENT 'Last received latitude', - `current_altitude` DOUBLE NULL COMMENT 'Last received altitude', - `stored_longitude` DOUBLE NOT NULL COMMENT 'Reference longitude to see if the agent has moved', - `stored_latitude` DOUBLE NOT NULL COMMENT 'Reference latitude to see if the agent has moved', - `stored_altitude` DOUBLE NULL COMMENT 'Reference altitude to see if the agent has moved', - `number_of_packages` INT NOT NULL DEFAULT 1 COMMENT 'Number of data packages received with this position since start_timestampa' , - `start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp on wich the agente started to be in this position' , - `manual_placement` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '0 to show that the position cames from the agent, 1 to show that the position was established manualy' , - `description` TEXT NULL COMMENT 'description of the region correoponding to this placemnt' , - PRIMARY KEY (`tagente_id_agente`) , - INDEX `start_timestamp_index` USING BTREE (`start_timestamp` ASC), - INDEX `fk_tgisdata_tagente1` (`tagente_id_agente` ASC) , - CONSTRAINT `fk_tgisdata_tagente1` - FOREIGN KEY (`tagente_id_agente` ) - REFERENCES `tagente` (`id_agente` ) - ON DELETE CASCADE - ON UPDATE NO ACTION) + `tagente_id_agente` INT(10) UNSIGNED NOT NULL COMMENT 'Reference to the agent' , + `current_longitude` DOUBLE NOT NULL COMMENT 'Last received longitude', + `current_latitude` DOUBLE NOT NULL COMMENT 'Last received latitude', + `current_altitude` DOUBLE NULL COMMENT 'Last received altitude', + `stored_longitude` DOUBLE NOT NULL COMMENT 'Reference longitude to see if the agent has moved', + `stored_latitude` DOUBLE NOT NULL COMMENT 'Reference latitude to see if the agent has moved', + `stored_altitude` DOUBLE NULL COMMENT 'Reference altitude to see if the agent has moved', + `number_of_packages` INT NOT NULL DEFAULT 1 COMMENT 'Number of data packages received with this position since start_timestampa' , + `start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp on wich the agente started to be in this position' , + `manual_placement` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '0 to show that the position cames from the agent, 1 to show that the position was established manualy' , + `description` TEXT NULL COMMENT 'description of the region correoponding to this placemnt' , + PRIMARY KEY (`tagente_id_agente`) , + INDEX `start_timestamp_index` USING BTREE (`start_timestamp` ASC), + INDEX `fk_tgisdata_tagente1` (`tagente_id_agente` ASC) , + CONSTRAINT `fk_tgisdata_tagente1` + FOREIGN KEY (`tagente_id_agente` ) + REFERENCES `tagente` (`id_agente` ) + ON DELETE CASCADE + ON UPDATE NO ACTION) ENGINE = InnoDB COMMENT = 'Table to store last GIS information of the agents'; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tgis_map` --- ----------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tgis_map` ( - `id_tgis_map` INT NOT NULL AUTO_INCREMENT COMMENT 'table identifier' , - `map_name` VARCHAR(63) NOT NULL COMMENT 'Name of the map' , - `initial_longitude` DOUBLE NULL COMMENT 'longitude of the center of the map when it\'s loaded' , - `initial_latitude` DOUBLE NULL COMMENT 'latitude of the center of the map when it\'s loaded' , - `initial_altitude` DOUBLE NULL COMMENT 'altitude of the center of the map when it\'s loaded' , - `zoom_level` TINYINT(2) NULL DEFAULT '1' COMMENT 'Zoom level to show when the map is loaded.' , - `map_background` VARCHAR(127) NULL COMMENT 'path on the server to the background image of the map' , - `default_longitude` DOUBLE NULL COMMENT 'default longitude for the agents placed on the map' , - `default_latitude` DOUBLE NULL COMMENT 'default latitude for the agents placed on the map' , - `default_altitude` DOUBLE NULL COMMENT 'default altitude for the agents placed on the map' , - `group_id` INT(10) NOT NULL DEFAULT 0 COMMENT 'Group that owns the map' , - `default_map` TINYINT(1) NULL DEFAULT 0 COMMENT '1 if this is the default map, 0 in other case', - PRIMARY KEY (`id_tgis_map`), - INDEX `map_name_index` (`map_name` ASC) + `id_tgis_map` INT NOT NULL AUTO_INCREMENT COMMENT 'table identifier' , + `map_name` VARCHAR(63) NOT NULL COMMENT 'Name of the map' , + `initial_longitude` DOUBLE NULL COMMENT "longitude of the center of the map when it\'s loaded" , + `initial_latitude` DOUBLE NULL COMMENT "latitude of the center of the map when it\'s loaded" , + `initial_altitude` DOUBLE NULL COMMENT "altitude of the center of the map when it\'s loaded" , + `zoom_level` TINYINT(2) NULL DEFAULT '1' COMMENT 'Zoom level to show when the map is loaded.' , + `map_background` VARCHAR(127) NULL COMMENT 'path on the server to the background image of the map' , + `default_longitude` DOUBLE NULL COMMENT 'default longitude for the agents placed on the map' , + `default_latitude` DOUBLE NULL COMMENT 'default latitude for the agents placed on the map' , + `default_altitude` DOUBLE NULL COMMENT 'default altitude for the agents placed on the map' , + `group_id` INT(10) NOT NULL DEFAULT 0 COMMENT 'Group that owns the map' , + `default_map` TINYINT(1) NULL DEFAULT 0 COMMENT '1 if this is the default map, 0 in other case', + PRIMARY KEY (`id_tgis_map`), + INDEX `map_name_index` (`map_name` ASC) ) ENGINE = InnoDB COMMENT = 'Table containing information about a gis map'; @@ -1288,9 +1322,9 @@ CREATE TABLE IF NOT EXISTS `tgis_map_connection` ( `default_longitude` DOUBLE NULL COMMENT 'default longitude for the agents placed on the map' , `default_latitude` DOUBLE NULL COMMENT 'default latitude for the agents placed on the map' , `default_altitude` DOUBLE NULL COMMENT 'default altitude for the agents placed on the map' , - `initial_longitude` DOUBLE NULL COMMENT 'longitude of the center of the map when it\'s loaded' , - `initial_latitude` DOUBLE NULL COMMENT 'latitude of the center of the map when it\'s loaded' , - `initial_altitude` DOUBLE NULL COMMENT 'altitude of the center of the map when it\'s loaded' , + `initial_longitude` DOUBLE NULL COMMENT "longitude of the center of the map when it\'s loaded" , + `initial_latitude` DOUBLE NULL COMMENT "latitude of the center of the map when it\'s loaded" , + `initial_altitude` DOUBLE NULL COMMENT "altitude of the center of the map when it\'s loaded" , `group_id` INT(10) NOT NULL DEFAULT 0 COMMENT 'Group that owns the map', PRIMARY KEY (`id_tmap_connection`) ) ENGINE = InnoDB @@ -1362,103 +1396,99 @@ CREATE TABLE IF NOT EXISTS `tgis_map_layer_has_tagente` ( ENGINE = InnoDB COMMENT = 'Table to define wich agents are shown in a layer'; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tgroup_stat` --- ----------------------------------------------------- - +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tgroup_stat` ( - `id_group` int(10) unsigned NOT NULL default '0', - `modules` int(10) unsigned NOT NULL default '0', - `normal` int(10) unsigned NOT NULL default '0', - `critical` int(10) unsigned NOT NULL default '0', - `warning` int(10) unsigned NOT NULL default '0', - `unknown` int(10) unsigned NOT NULL default '0', - `non-init` int(10) unsigned NOT NULL default '0', - `alerts` int(10) unsigned NOT NULL default '0', - `alerts_fired` int(10) unsigned NOT NULL default '0', - `agents` int(10) unsigned NOT NULL default '0', - `agents_unknown` int(10) unsigned NOT NULL default '0', - `utimestamp` int(20) unsigned NOT NULL default 0, - PRIMARY KEY (`id_group`) + `id_group` int(10) unsigned NOT NULL default '0', + `modules` int(10) unsigned NOT NULL default '0', + `normal` int(10) unsigned NOT NULL default '0', + `critical` int(10) unsigned NOT NULL default '0', + `warning` int(10) unsigned NOT NULL default '0', + `unknown` int(10) unsigned NOT NULL default '0', + `non-init` int(10) unsigned NOT NULL default '0', + `alerts` int(10) unsigned NOT NULL default '0', + `alerts_fired` int(10) unsigned NOT NULL default '0', + `agents` int(10) unsigned NOT NULL default '0', + `agents_unknown` int(10) unsigned NOT NULL default '0', + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id_group`) ) ENGINE=InnoDB COMMENT = 'Table to store global system stats per group' DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tnetwork_map` --- ----------------------------------------------------- - +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tnetwork_map` ( - `id_networkmap` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_user` VARCHAR(60) NOT NULL, - `name` VARCHAR(100) NOT NULL, - `type` VARCHAR(20) NOT NULL, - `layout` VARCHAR(20) NOT NULL, - `nooverlap` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `simple` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `regenerate` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, - `font_size` INT UNSIGNED NOT NULL DEFAULT 12, - `id_group` INT NOT NULL DEFAULT 0, - `id_module_group` INT NOT NULL DEFAULT 0, - `id_policy` INT NOT NULL DEFAULT 0, - `depth` VARCHAR(20) NOT NULL, - `only_modules_with_alerts` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `hide_policy_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `zoom` FLOAT UNSIGNED NOT NULL DEFAULT 1, - `distance_nodes` FLOAT UNSIGNED NOT NULL DEFAULT 2.5, - `center` INT UNSIGNED NOT NULL DEFAULT 0, - `contracted_nodes` TEXT, - `show_snmp_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - PRIMARY KEY (`id_networkmap`) + `id_networkmap` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(60) NOT NULL, + `name` VARCHAR(100) NOT NULL, + `type` VARCHAR(20) NOT NULL, + `layout` VARCHAR(20) NOT NULL, + `nooverlap` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, + `simple` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, + `regenerate` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, + `font_size` INT UNSIGNED NOT NULL DEFAULT 12, + `id_group` INT NOT NULL DEFAULT 0, + `id_module_group` INT NOT NULL DEFAULT 0, + `id_policy` INT NOT NULL DEFAULT 0, + `depth` VARCHAR(20) NOT NULL, + `only_modules_with_alerts` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, + `hide_policy_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, + `zoom` FLOAT UNSIGNED NOT NULL DEFAULT 1, + `distance_nodes` FLOAT UNSIGNED NOT NULL DEFAULT 2.5, + `center` INT UNSIGNED NOT NULL DEFAULT 0, + `contracted_nodes` TEXT, + `show_snmp_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, + `text_filter` VARCHAR(100) NOT NULL DEFAULT "", + `dont_show_subgroups` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_networkmap`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tsnmp_filter` --- ----------------------------------------------------- - +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tsnmp_filter` ( - `id_snmp_filter` int(10) unsigned NOT NULL auto_increment, - `description` varchar(255) default '', - `filter` varchar(255) default '', - PRIMARY KEY (`id_snmp_filter`) + `id_snmp_filter` int(10) unsigned NOT NULL auto_increment, + `description` varchar(255) default '', + `filter` varchar(255) default '', + PRIMARY KEY (`id_snmp_filter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tagent_custom_fields` --- ----------------------------------------------------- - +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tagent_custom_fields` ( - `id_field` int(10) unsigned NOT NULL auto_increment, - `name` varchar(45) NOT NULL default '', - `display_on_front` tinyint(1) NOT NULL default 0, - PRIMARY KEY (`id_field`) + `id_field` int(10) unsigned NOT NULL auto_increment, + `name` varchar(45) NOT NULL default '', + `display_on_front` tinyint(1) NOT NULL default 0, + PRIMARY KEY (`id_field`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `tagent_custom_data` --- ----------------------------------------------------- - +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tagent_custom_data` ( - `id_field` int(10) unsigned NOT NULL, - `id_agent` int(10) unsigned NOT NULL, - `description` text, - FOREIGN KEY (`id_field`) REFERENCES tagent_custom_fields(`id_field`) - ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) - ON UPDATE CASCADE ON DELETE CASCADE, - PRIMARY KEY (`id_field`, `id_agent`) + `id_field` int(10) unsigned NOT NULL, + `id_agent` int(10) unsigned NOT NULL, + `description` text, + FOREIGN KEY (`id_field`) REFERENCES tagent_custom_fields(`id_field`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) + ON UPDATE CASCADE ON DELETE CASCADE, + PRIMARY KEY (`id_field`, `id_agent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- +------------------------------------------------------------------------ -- Table `ttag` --- ----------------------------------------------------- - +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `ttag` ( - `id_tag` integer(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `description` text NOT NULL, - `url` mediumtext NOT NULL, - PRIMARY KEY (`id_tag`) + `id_tag` integer(10) unsigned NOT NULL auto_increment, + `name` varchar(100) NOT NULL default '', + `description` text NOT NULL, + `url` mediumtext NOT NULL, + PRIMARY KEY (`id_tag`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -----------------------------------------------------