mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
Autoconfiguration v1
This commit is contained in:
parent
9e028873be
commit
c800061bc2
@ -25,8 +25,8 @@ CREATE TABLE `tautoconfig_rules` (
|
|||||||
`order_by` int(11) NOT NULL DEFAULT '0',
|
`order_by` int(11) NOT NULL DEFAULT '0',
|
||||||
`operator` enum('AND','OR') DEFAULT 'OR',
|
`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') DEFAULT 'alias',
|
||||||
`value` varchar(100) NOT NULL DEFAULT '',
|
`value` text,
|
||||||
`custom` varchar(100) NOT NULL DEFAULT '',
|
`custom` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `id_autoconfig` (`id_autoconfig`),
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
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` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`id_autoconfig` int(10) unsigned NOT NULL,
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
`order` int(11) NOT NULL DEFAULT '0',
|
`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',
|
`action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event',
|
||||||
`value` varchar(100) NOT NULL DEFAULT '',
|
`value` text,
|
||||||
`custom` varchar(100) NOT NULL DEFAULT '',
|
`custom` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `id_autoconfig` (`id_autoconfig`),
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
@ -1688,8 +1688,8 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_rules` (
|
|||||||
`order_by` int(11) NOT NULL DEFAULT '0',
|
`order_by` int(11) NOT NULL DEFAULT '0',
|
||||||
`operator` enum('AND','OR') DEFAULT 'OR',
|
`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') DEFAULT 'alias',
|
||||||
`value` varchar(100) NOT NULL DEFAULT '',
|
`value` text,
|
||||||
`custom` varchar(100) NOT NULL DEFAULT '',
|
`custom` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `id_autoconfig` (`id_autoconfig`),
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
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` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`id_autoconfig` int(10) unsigned NOT NULL,
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
`order` int(11) NOT NULL DEFAULT '0',
|
`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',
|
`action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event',
|
||||||
`value` varchar(100) NOT NULL DEFAULT '',
|
`value` text,
|
||||||
`custom` varchar(100) NOT NULL DEFAULT '',
|
`custom` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `id_autoconfig` (`id_autoconfig`),
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
@ -3215,8 +3215,8 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_rules` (
|
|||||||
`order_by` int(11) NOT NULL DEFAULT '0',
|
`order_by` int(11) NOT NULL DEFAULT '0',
|
||||||
`operator` enum('AND','OR') DEFAULT 'OR',
|
`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') DEFAULT 'alias',
|
||||||
`value` varchar(100) NOT NULL DEFAULT '',
|
`value` text,
|
||||||
`custom` varchar(100) NOT NULL DEFAULT '',
|
`custom` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `id_autoconfig` (`id_autoconfig`),
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
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` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`id_autoconfig` int(10) unsigned NOT NULL,
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
`order` int(11) NOT NULL DEFAULT '0',
|
`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',
|
`action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event',
|
||||||
`value` varchar(100) NOT NULL DEFAULT '',
|
`value` text,
|
||||||
`custom` varchar(100) NOT NULL DEFAULT '',
|
`custom` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `id_autoconfig` (`id_autoconfig`),
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
@ -487,6 +487,8 @@ sub pandora_load_config {
|
|||||||
$pa_config->{"provisioningserver_threads"} = 1; # 7.0 720
|
$pa_config->{"provisioningserver_threads"} = 1; # 7.0 720
|
||||||
$pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720
|
$pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720
|
||||||
|
|
||||||
|
$pa_config->{"autoconfigure_agents"} = 1; # 7.0 725
|
||||||
|
|
||||||
# Check for UID0
|
# Check for UID0
|
||||||
if ($pa_config->{"quiet"} != 0){
|
if ($pa_config->{"quiet"} != 0){
|
||||||
if ($> == 0){
|
if ($> == 0){
|
||||||
@ -1113,6 +1115,9 @@ sub pandora_load_config {
|
|||||||
elsif ($parametro =~ m/^provisioning_cache_interval\s+([0-9]*)/i){
|
elsif ($parametro =~ m/^provisioning_cache_interval\s+([0-9]*)/i){
|
||||||
$pa_config->{'provisioning_cache_interval'}= clean_blank($1);
|
$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 #
|
} # end of loop for parameter #
|
||||||
|
|
||||||
# Set to RDBMS' standard port
|
# Set to RDBMS' standard port
|
||||||
|
@ -50,6 +50,7 @@ our @EXPORT = qw(
|
|||||||
db_text
|
db_text
|
||||||
db_update
|
db_update
|
||||||
db_update_get_values
|
db_update_get_values
|
||||||
|
set_update_agent
|
||||||
get_action_id
|
get_action_id
|
||||||
get_addr_id
|
get_addr_id
|
||||||
get_agent_addr_id
|
get_agent_addr_id
|
||||||
@ -801,6 +802,35 @@ sub get_db_rows_limit ($$$;@) {
|
|||||||
return @rows;
|
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.
|
## SQL delete with a LIMIT clause.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -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
|
# Get the data of the agent, if fail return
|
||||||
|
@ -990,6 +990,18 @@ sub init {
|
|||||||
return $conf;
|
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)
|
# initialize plugin (basic)
|
||||||
################################################################################
|
################################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user