From f430b8998f6074c7338f2c8f0c271d829f40c2b0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 3 Jul 2018 12:01:37 +0200 Subject: [PATCH 1/8] Added DB changes to support ProvisioningServer 2 --- pandora_console/extras/mr/18.sql | 36 +++++++++++++++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 44 +++++++++++++++++++ pandora_console/pandoradb.sql | 43 ++++++++++++++++++ 3 files changed, 123 insertions(+) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index b7e4be33e0..e82f940bfb 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -10,4 +10,40 @@ ALTER TABLE `tmetaconsole_agent` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; +CREATE TABLE `tautoconfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `description` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `tautoconfig_rules` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order_by` int(11) NOT NULL DEFAULT '0', + `operator` enum('AND','OR') DEFAULT 'OR', + `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `tautoconfig_actions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 6752754a5c..19add1b91a 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1667,3 +1667,47 @@ create table IF NOT EXISTS `tmetaconsole_agent_secondary_group`( ALTER TABLE tagente ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0'; ALTER TABLE tmetaconsole_agent ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0'; ALTER TABLE tusuario_perfil ADD COLUMN `is_secondary` tinyint(1) NOT NULL default '0'; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `description` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_rules` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order_by` int(11) NOT NULL DEFAULT '0', + `operator` enum('AND','OR') DEFAULT 'OR', + `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_actions` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 5b77263b6a..a06099511b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3195,3 +3195,46 @@ create table IF NOT EXISTS `tmetaconsole_agent_secondary_group`( ON DELETE CASCADE ) engine=InnoDB DEFAULT CHARSET=utf8; +-- --------------------------------------------------------------------- +-- Table `tautoconfig` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `description` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_rules` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order_by` int(11) NOT NULL DEFAULT '0', + `operator` enum('AND','OR') DEFAULT 'OR', + `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_actions` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + From c800061bc23673dd285242b54f4170b9fa300ac3 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 4 Jul 2018 18:39:06 +0200 Subject: [PATCH 2/8] Autoconfiguration v1 --- pandora_console/extras/mr/18.sql | 10 +++---- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 10 +++---- pandora_console/pandoradb.sql | 10 +++---- pandora_server/lib/PandoraFMS/Config.pm | 5 ++++ pandora_server/lib/PandoraFMS/DB.pm | 30 +++++++++++++++++++ pandora_server/lib/PandoraFMS/DataServer.pm | 6 ++++ pandora_server/lib/PandoraFMS/PluginTools.pm | 12 ++++++++ 7 files changed, 68 insertions(+), 15 deletions(-) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index e82f940bfb..310e42c1c8 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -25,8 +25,8 @@ CREATE TABLE `tautoconfig_rules` ( `order_by` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE @@ -37,9 +37,9 @@ CREATE TABLE `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 19add1b91a..233f376410 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1688,8 +1688,8 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `order_by` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE @@ -1702,9 +1702,9 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index a06099511b..c3e6bdd9c7 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3215,8 +3215,8 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `order_by` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE @@ -3229,9 +3229,9 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index afe1c98dfd..88eafe660a 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -487,6 +487,8 @@ sub pandora_load_config { $pa_config->{"provisioningserver_threads"} = 1; # 7.0 720 $pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720 + $pa_config->{"autoconfigure_agents"} = 1; # 7.0 725 + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -1113,6 +1115,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^provisioning_cache_interval\s+([0-9]*)/i){ $pa_config->{'provisioning_cache_interval'}= clean_blank($1); } + elsif ($parametro =~ m/^autoconfigure_agents\s+([0-1])/i){ + $pa_config->{'autoconfigure_agents'}= clean_blank($1); + } } # end of loop for parameter # # Set to RDBMS' standard port diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 1fe1208d78..417fd9cf5d 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -50,6 +50,7 @@ our @EXPORT = qw( db_text db_update db_update_get_values + set_update_agent get_action_id get_addr_id get_agent_addr_id @@ -801,6 +802,35 @@ sub get_db_rows_limit ($$$;@) { return @rows; } +########################################################################## +## Updates agent fields using field => value +## Be careful, no filter is done. +########################################################################## +sub set_update_agent { + my ($dbh, $agent_id, $data) = @_; + + return undef unless (defined($agent_id) && $agent_id > 0); + return undef unless (ref($data) eq "HASH"); + + # Build update query + my $query = 'UPDATE tagente SET '; + + my @values; + foreach my $field (keys %{$data}) { + push @values, $data->{$field}; + + $query .= ' ' . $field . ' = ?,'; + } + + chop($query); + + $query .= ' WHERE id_agente = ? '; + push @values, $agent_id; + + return db_update($dbh, $query, @values); +} + + ########################################################################## ## SQL delete with a LIMIT clause. ########################################################################## diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index ef62bab200..f0c05da7a4 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -409,6 +409,12 @@ sub process_xml_data ($$$$$) { } } } + + if (defined($pa_config->{'autoconfigure_agents'}) && $pa_config->{'autoconfigure_agents'} == 1) { + # Update agent configuration once, before create agent - MetaConsole port to Node + enterprise_hook('autoconfigure_agent', [$pa_config, $agent_name, $agent_id, $data, $dbh]); + } + } # Get the data of the agent, if fail return diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 3afa5ff898..45ac0a6e93 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -990,6 +990,18 @@ sub init { return $conf; } +################################################################################ +# Update internal UA timeout +################################################################################ +sub ua_set_timeout { + my ($config, $timeout) = @_; + return unless looks_like_number($timeout) and $timeout > 0; + my $sys = get_sys_environment($config); + + return unless defined($sys->{'ua'}); + $sys->{'ua'}->timeout($timeout); +} + ################################################################################ # initialize plugin (basic) ################################################################################ From fb0800d37574fbc36e0b5a1e3583d30230a56924 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 4 Jul 2018 19:47:10 +0200 Subject: [PATCH 3/8] Minor fixes --- pandora_console/extras/mr/18.sql | 2 +- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- pandora_console/pandoradb.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index 310e42c1c8..26f97d8e21 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -22,7 +22,7 @@ CREATE TABLE `tautoconfig` ( CREATE TABLE `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 233f376410..203449fa1c 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1685,7 +1685,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig` ( CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index c3e6bdd9c7..350b7dac99 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3212,7 +3212,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig` ( CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, From 23a9cf7842afa7f52981b3ea111b355b842fcbed Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 4 Jul 2018 19:47:10 +0200 Subject: [PATCH 4/8] Minor fixes --- pandora_console/extras/mr/18.sql | 4 ++-- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 4 ++-- pandora_console/pandoradb.sql | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index 310e42c1c8..0c86b45170 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -22,7 +22,7 @@ CREATE TABLE `tautoconfig` ( CREATE TABLE `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, @@ -37,7 +37,7 @@ CREATE TABLE `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', `value` text, `custom` text, PRIMARY KEY (`id`), diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 233f376410..caaa95402d 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1685,7 +1685,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig` ( CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, @@ -1702,7 +1702,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', `value` text, `custom` text, PRIMARY KEY (`id`), diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index c3e6bdd9c7..e00ecfc28a 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3212,7 +3212,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig` ( CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, @@ -3229,7 +3229,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', `value` text, `custom` text, PRIMARY KEY (`id`), From c09a91b284b6660f20516e6f4cb6e9c322028ed5 Mon Sep 17 00:00:00 2001 From: danielmaya Date: Thu, 19 Jul 2018 08:35:33 +0200 Subject: [PATCH 5/8] Added server-name in tautoconfig_rules --- pandora_console/extras/mr/18.sql | 2 +- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- pandora_console/pandoradb.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index 0c86b45170..f0ebaddef2 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -24,7 +24,7 @@ CREATE TABLE `tautoconfig_rules` ( `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', - `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias', `value` text, `custom` text, PRIMARY KEY (`id`), diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index caaa95402d..70118e2407 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1687,7 +1687,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', - `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias', `value` text, `custom` text, PRIMARY KEY (`id`), diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index e00ecfc28a..7076c9349b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3214,7 +3214,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', - `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias', `value` text, `custom` text, PRIMARY KEY (`id`), From ba676e13e312808f723bc03fbe246a243807883e Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 23 Jul 2018 20:11:35 +0200 Subject: [PATCH 6/8] Added autoconfiguration menu --- pandora_console/godmode/menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index fdf4b71360..f9b6632c23 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -101,12 +101,12 @@ if (check_acl ($config['id_user'], 0, "PM")) { $sub["godmode/modules/manage_network_templates"]["text"] = __('Module templates'); $sub["godmode/modules/manage_network_templates"]["id"] = 'Module templates'; enterprise_hook ('inventory_submenu'); + enterprise_hook ('autoconfiguration_menu'); } if (check_acl ($config['id_user'], 0, "AW")) { enterprise_hook ('policies_menu'); enterprise_hook('agents_submenu'); } - if (check_acl ($config['id_user'], 0, "AW")) { $sub["gmassive"]["text"] = __('Bulk operations'); $sub["gmassive"]["id"] = 'Bulk operations'; From 581cf7c5a081c502e31afd918db8361cb1c9494a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 24 Jul 2018 17:55:33 +0200 Subject: [PATCH 7/8] Added management_allowed --- pandora_console/include/functions.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 4b9e8ef6da..d83dc42df5 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1363,6 +1363,19 @@ function is_metaconsole() { return (bool) $config['metaconsole']; } +/** + * @brief Check if there is management operations are allowed in current context + * (node // meta) + * + * @return bool + */ +function is_management_allowed() { + global $config; + return ( (is_metaconsole() && $config["centralized_management"]) + || (is_metaconsole() && !$config["centralized_management"]) + || (!is_metaconsole() && !$config["centralized_management"])); +} + /** * @brief Check if there is centralized management in metaconsole environment. * Usefull to display some policy features on metaconsole. From ae6d7139b4ed98d760d872e1f52c918ab2dc6ac1 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 24 Jul 2018 18:24:03 +0200 Subject: [PATCH 8/8] is_management_allowed fix --- pandora_console/include/functions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index d83dc42df5..7e93e52aa4 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1372,7 +1372,6 @@ function is_metaconsole() { function is_management_allowed() { global $config; return ( (is_metaconsole() && $config["centralized_management"]) - || (is_metaconsole() && !$config["centralized_management"]) || (!is_metaconsole() && !$config["centralized_management"])); }