Merge branch '1873-autoprovisionamiento-de-agentes' into 'develop'

1873 autoprovisionamiento de agentes

See merge request artica/pandorafms!1342
This commit is contained in:
vgilc 2018-03-14 09:12:07 +01:00
commit 387280e97f
9 changed files with 96 additions and 9 deletions

View File

@ -12,6 +12,27 @@ START TRANSACTION;
INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`) VALUES (21, 'Cluster', 'Cluster agent', 'so_cluster.png');
CREATE TABLE IF NOT EXISTS `tprovisioning`(
`id` int unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL,
`description` TEXT default '',
`order` int(11) NOT NULL default 0,
`config` TEXT default '',
PRIMARY KEY (`id`)
) engine=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tprovisioning_rules`(
`id` int unsigned NOT NULL auto_increment,
`id_provisioning` int unsigned NOT NULL,
`order` int(11) NOT NULL default 0,
`operator` enum('AND','OR') default 'OR',
`type` enum('alias','ip-range') default 'alias',
`value` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`),
FOREIGN KEY (`id_provisioning`) REFERENCES tprovisioning(`id`)
ON DELETE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
create table IF NOT EXISTS `tmigration_queue`(
`id` int unsigned not null auto_increment,
`id_source_agent` int unsigned not null,
@ -37,4 +58,4 @@ START TRANSACTION;
ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
COMMIT;
COMMIT;

View File

@ -1534,6 +1534,32 @@ create table IF NOT EXISTS `tcluster_agent`(
ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tprovisioning`
-- ---------------------------------------------------------------------
create table IF NOT EXISTS `tprovisioning`(
`id` int unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL,
`description` TEXT default '',
`order` int(11) NOT NULL default 0,
`config` TEXT default '',
PRIMARY KEY (`id`)
) engine=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tprovisioning_rules`
-- ---------------------------------------------------------------------
create table IF NOT EXISTS `tprovisioning_rules`(
`id` int unsigned NOT NULL auto_increment,
`id_provisioning` int unsigned NOT NULL,
`order` int(11) NOT NULL default 0,
`operator` enum('AND','OR') default 'OR',
`type` enum('alias','ip-range') default 'alias',
`value` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`),
FOREIGN KEY (`id_provisioning`) REFERENCES tprovisioning(`id`)
ON DELETE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tmigration_queue`
@ -1567,4 +1593,3 @@ create table IF NOT EXISTS `tmigration_module_queue`(
ON DELETE CASCADE
ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

View File

@ -1931,7 +1931,7 @@ CREATE TABLE IF NOT EXISTS `tupdate_journal` (
-- ---------------------------------------------------------------------
-- Table `talert_snmp_action`
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_snmp_action` (
CREATE TABLE IF NOT EXISTS `talert_snmp_action` (
`id` int(10) unsigned NOT NULL auto_increment,
`id_alert_snmp` int(10) unsigned NOT NULL default '0',
`alert_type` int(2) unsigned NOT NULL default '0',
@ -1956,7 +1956,7 @@ CREATE TABLE IF NOT EXISTS `talert_snmp_action` (
-- ---------------------------------------------------------------------
-- Table `tsessions_php`
-- ---------------------------------------------------------------------
CREATE TABLE tsessions_php (
CREATE TABLE IF NOT EXISTS `tsessions_php` (
`id_session` CHAR(52) NOT NULL,
`last_active` INTEGER NOT NULL,
`data` TEXT,
@ -3081,6 +3081,33 @@ create table IF NOT EXISTS `tcluster_agent`(
ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tprovisioning`
-- ---------------------------------------------------------------------
create table IF NOT EXISTS `tprovisioning`(
`id` int unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL,
`description` TEXT default '',
`order` int(11) NOT NULL default 0,
`config` TEXT default '',
PRIMARY KEY (`id`)
) engine=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tprovisioning_rules`
-- ---------------------------------------------------------------------
create table IF NOT EXISTS `tprovisioning_rules`(
`id` int unsigned NOT NULL auto_increment,
`id_provisioning` int unsigned NOT NULL,
`order` int(11) NOT NULL default 0,
`operator` enum('AND','OR') default 'OR',
`type` enum('alias','ip-range') default 'alias',
`value` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`),
FOREIGN KEY (`id_provisioning`) REFERENCES tprovisioning(`id`)
ON DELETE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tmigration_queue`
-- ---------------------------------------------------------------------
@ -3113,4 +3140,3 @@ create table IF NOT EXISTS `tmigration_module_queue`(
ON DELETE CASCADE
ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;

View File

@ -359,6 +359,7 @@ sub pandora_server_tasks ($) {
# Pandora self monitoring
if (defined($pa_config->{"self_monitoring"})
&& $pa_config->{"self_monitoring"} == 1
&& !is_metaconsole($pa_config)
&& $counter % $pa_config->{'self_monitoring_interval'} == 0) {
pandora_self_monitoring ($pa_config, $dbh);
}

View File

@ -171,6 +171,8 @@ sub pandora_get_sharedconfig ($$) {
# NOTE: This must be read when checking license limits!
#$pa_config->{"node_metaconsole"} = pandora_get_tconfig_token ($dbh, 'node_metaconsole', 0);
$pa_config->{"provisioning_mode"} = pandora_get_tconfig_token ($dbh, 'provisioning_mode', '');
if ($pa_config->{'include_agents'} eq '') {
$pa_config->{'include_agents'} = 0;
@ -473,6 +475,10 @@ sub pandora_load_config {
$pa_config->{"unknown_updates"} = 0; # 7.0.718
$pa_config->{"provisioningserver"} = 1; # 7.0 720
$pa_config->{"provisioningserver_threads"} = 1; # 7.0 720
$pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720
# Check for UID0
if ($pa_config->{"quiet"} != 0){
if ($> == 0){
@ -1090,6 +1096,15 @@ sub pandora_load_config {
elsif ($parametro =~ m/^unknown_updates\s+([0-1])/i) {
$pa_config->{'unknown_updates'} = clean_blank($1);
}
elsif ($parametro =~ m/^provisioningserver\s+([0-1])/i){
$pa_config->{'provisioningserver'}= clean_blank($1);
}
elsif ($parametro =~ m/^provisioningserver_threads\s+([0-9]*)/i){
$pa_config->{'provisioningserver_threads'}= clean_blank($1);
}
elsif ($parametro =~ m/^provisioning_cache_interval\s+([0-9]*)/i){
$pa_config->{'provisioning_cache_interval'}= clean_blank($1);
}
} # end of loop for parameter #
# Set to RDBMS' standard port

View File

@ -334,7 +334,6 @@ sub process_xml_data ($$$$$) {
if (defined ($data->{'group_id'}) && $data->{'group_id'} ne '') {
$group_id = $data->{'group_id'};
if (! defined (get_group_name ($dbh, $group_id))) {
print "UNABLE GROUP ID\n";
pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': group ID '" . $group_id . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
logger($pa_config, "Group ID " . $group_id . " does not exist.", 3);
return;
@ -342,13 +341,11 @@ sub process_xml_data ($$$$$) {
} elsif (defined ($data->{'group'}) && $data->{'group'} ne '') {
$group_id = get_group_id ($dbh, $data->{'group'});
if (! defined (get_group_name ($dbh, $group_id))) {
print "UNABLE GROUP\n";
pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': group '" . safe_output($data->{'group'}) . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
logger($pa_config, "Group " . $data->{'group'} . " does not exist.", 3);
return;
}
} else {
print "UNABLE AUTOCREATE\n";
pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': autocreate_group $group_id does not exist. Edit the pandora_server.conf file and change it.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
logger($pa_config, "Group id $group_id does not exist (check autocreate_group config token).", 3);
return;

View File

@ -64,6 +64,7 @@ our @EXPORT = qw(
SYNCSERVER
SYSLOGSERVER
WUXSERVER
PROVISIONINGSERVER
MIGRATIONSERVER
METACONSOLE_LICENSE
$DEVNULL
@ -136,7 +137,8 @@ use constant MFSERVER => 15;
use constant SYNCSERVER => 16;
use constant WUXSERVER => 17;
use constant SYSLOGSERVER => 18;
use constant MIGRATIONSERVER => 19;
use constant PROVISIONINGSERVER => 19;
use constant MIGRATIONSERVER => 20;
# Module status
use constant MODULE_NORMAL => 0;