Merge remote-tracking branch 'origin/develop' into ent-2441-despliegue-de-agentes-desde-pandora

This commit is contained in:
fbsanchez 2019-07-26 21:56:45 +02:00
commit f7e2023253
29 changed files with 95 additions and 55 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.736-190725 Version: 7.0NG.736-190726
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.736-190725" pandora_version="7.0NG.736-190726"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -42,7 +42,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.736'; use constant AGENT_VERSION => '7.0NG.736';
use constant AGENT_BUILD => '190725'; use constant AGENT_BUILD => '190726';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.736 %define version 7.0NG.736
%define release 190725 %define release 190726
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.736 %define version 7.0NG.736
%define release 190725 %define release 190726
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.736" PI_VERSION="7.0NG.736"
PI_BUILD="190725" PI_BUILD="190726"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{190725} {190726}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.736(Build 190725)") #define PANDORA_VERSION ("7.0NG.736(Build 190726)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.736(Build 190725))" VALUE "ProductVersion", "(7.0NG.736(Build 190726))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.736-190725 Version: 7.0NG.736-190726
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.736-190725" pandora_version="7.0NG.736-190726"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC190725'; $build_version = 'PC190726';
$pandora_version = 'v7.0NG.736'; $pandora_version = 'v7.0NG.736';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.736'; $version = '7.0NG.736';
$build = '190725'; $build = '190726';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.736 %define version 7.0NG.736
%define release 190725 %define release 190726
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.736 %define version 7.0NG.736
%define release 190725 %define release 190726
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.736 %define version 7.0NG.736
%define release 190725 %define release 190726
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.736-190725 Version: 7.0NG.736-190726
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.736-190725" pandora_version="7.0NG.736-190726"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -304,6 +304,11 @@ fsnmp /usr/bin/pandorafsnmp
autocreate_group 10 autocreate_group 10
# If set to 1, new agents will be added to the group specified by autocreate_group (the group specified by the agent will be used as fallback).
# If set to 0, new agents will be added to the group specified by the agent (the group specified by autocreate_group will be used as fallback).
autocreate_group_force 1
# Set to 1 if want to autocreate agents with Pandora FMS Data Server, # Set to 1 if want to autocreate agents with Pandora FMS Data Server,
# set to 0 to disable (for security purposes, for example). # set to 0 to disable (for security purposes, for example).

View File

@ -261,6 +261,11 @@ dataserver_threads 2
autocreate_group 10 autocreate_group 10
# If set to 1, new agents will be added to the group specified by autocreate_group (the group specified by the agent will be used as fallback).
# If set to 0, new agents will be added to the group specified by the agent (the group specified by autocreate_group will be used as fallback).
autocreate_group_force 1
# Set to 1 if want to autocreate agents with Pandora FMS Data Server, # Set to 1 if want to autocreate agents with Pandora FMS Data Server,
# set to 0 to disable # set to 0 to disable

View File

@ -45,7 +45,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.736"; my $pandora_version = "7.0NG.736";
my $pandora_build = "190725"; my $pandora_build = "190726";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash
@ -333,6 +333,7 @@ sub pandora_load_config {
$pa_config->{"snmpget"} = "/usr/bin/snmpget"; $pa_config->{"snmpget"} = "/usr/bin/snmpget";
$pa_config->{'autocreate_group'} = -1; $pa_config->{'autocreate_group'} = -1;
$pa_config->{'autocreate_group_force'} = 1;
$pa_config->{'autocreate'} = 1; $pa_config->{'autocreate'} = 1;
# max log size (bytes) # max log size (bytes)
@ -811,6 +812,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^autocreate_group\s+([0-9*]*)/i) { elsif ($parametro =~ m/^autocreate_group\s+([0-9*]*)/i) {
$pa_config->{'autocreate_group'}= clean_blank($1); $pa_config->{'autocreate_group'}= clean_blank($1);
} }
elsif ($parametro =~ m/^autocreate_group_force\s+([0-1])/i) {
$pa_config->{'autocreate_group_force'}= clean_blank($1);
}
elsif ($parametro =~ m/^discovery_threads\s+([0-9]*)/i) { elsif ($parametro =~ m/^discovery_threads\s+([0-9]*)/i) {
$pa_config->{'discovery_threads'}= clean_blank($1); $pa_config->{'discovery_threads'}= clean_blank($1);
} }

View File

@ -184,6 +184,7 @@ our @EXPORT = qw(
pandora_execute_action pandora_execute_action
pandora_exec_forced_alerts pandora_exec_forced_alerts
pandora_generate_alerts pandora_generate_alerts
pandora_get_agent_group
pandora_get_config_value pandora_get_config_value
pandora_get_credential pandora_get_credential
pandora_get_module_tags pandora_get_module_tags
@ -3190,9 +3191,9 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$$) {
logger ($pa_config, "Server '$server_name' creating agent '$agent_name' address '$address'.", 10); logger ($pa_config, "Server '$server_name' creating agent '$agent_name' address '$address'.", 10);
if (!defined($group_id)) { if (!defined($group_id)) {
$group_id = $pa_config->{'autocreate_group'}; $group_id = pandora_get_agent_group($pa_config, $dbh, $agent_name);
if (! defined (get_group_name ($dbh, $group_id))) { if ($group_id <= 0) {
logger($pa_config, "Group id $group_id does not exist (check autocreate_group config token)", 3); logger($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': No valid group found.", 3);
return; return;
} }
} }
@ -3442,6 +3443,47 @@ sub pandora_extended_event($$$$) {
); );
} }
##########################################################################
# Returns a valid group ID to place an agent on success, -1 on error.
##########################################################################
sub pandora_get_agent_group {
my ($pa_config, $dbh, $agent_name, $agent_group, $agent_group_password) = @_;
my $group_id;
my @groups = $pa_config->{'autocreate_group_force'} == 1 ? ($pa_config->{'autocreate_group'}, $agent_group) : ($agent_group, $pa_config->{'autocreate_group'});
foreach my $group (@groups) {
next unless defined($group);
# Does the group exist?
if ($group eq $pa_config->{'autocreate_group'}) {
next if ($group <= 0);
$group_id = $group;
if (!defined(get_group_name ($dbh, $group_id))) {
logger($pa_config, "Group ID " . $group_id . " does not exist.", 10);
next;
}
} else {
next if ($group eq '');
$group_id = get_group_id ($dbh, $group);
if ($group_id <= 0) {
logger($pa_config, "Group " . $group . " does not exist.", 10);
next;
}
}
# Check the group password.
my $rc = enterprise_hook('check_group_password', [$dbh, $group_id, $agent_group_password]);
if (defined($rc) && $rc != 1) {
logger($pa_config, "Agent " . safe_output($agent_name) . " did not send a valid password for group ID $group_id.", 10);
next;
}
return $group_id;
}
return -1;
}
########################################################################## ##########################################################################
=head2 C<< pandora_update_module_on_error (I<$pa_config>, I<$id_agent_module>, I<$dbh>) >> =head2 C<< pandora_update_module_on_error (I<$pa_config>, I<$id_agent_module>, I<$dbh>) >>

View File

@ -83,6 +83,13 @@ sub new ($$;$) {
push(@XML::Parser::Expat::Encoding_Path, $config->{'enc_dir'}); push(@XML::Parser::Expat::Encoding_Path, $config->{'enc_dir'});
} }
if ($config->{'autocreate_group'} > 0 && !defined(get_group_name ($dbh, $config->{'autocreate_group'}))) {
my $msg = "Group id " . $config->{'autocreate_group'} . " does not exist (check autocreate_group config token).";
logger($config, $msg, 3);
print_message($config, $msg, 1);
pandora_event ($config, $msg, 0, 0, 0, 0, 0, 'error', 0, $dbh);
}
bless $self, $class; bless $self, $class;
return $self; return $self;
} }
@ -327,33 +334,10 @@ sub process_xml_data ($$$$$) {
# Get OS, group and description # Get OS, group and description
my $os = pandora_get_os ($dbh, $data->{'os_name'}); my $os = pandora_get_os ($dbh, $data->{'os_name'});
$group_id = $pa_config->{'autocreate_group'}; $group_id = pandora_get_agent_group($pa_config, $dbh, $agent_name, $data->{'group'}, $data->{'group_password'});
if (! defined (get_group_name ($dbh, $group_id))) { if ($group_id <= 0) {
if (defined ($data->{'group_id'}) && $data->{'group_id'} ne '') { pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': No valid group found.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
$group_id = $data->{'group_id'}; logger($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': No valid group found.", 3);
if (! defined (get_group_name ($dbh, $group_id))) {
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;
}
} elsif (defined ($data->{'group'}) && $data->{'group'} ne '') {
$group_id = get_group_id ($dbh, $data->{'group'});
if (! defined (get_group_name ($dbh, $group_id))) {
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 {
pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': autocreate_group $group_id does not exist. Edit the server configuration 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;
}
}
# Check the group password.
my $rc = enterprise_hook('check_group_password', [$dbh, $group_id, $data->{'group_password'}]);
if (defined($rc) && $rc != 1) {
logger($pa_config, "Agent $agent_name did not send a valid password for group id $group_id.", 10);
return; return;
} }

View File

@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.736"; my $pandora_version = "7.0NG.736";
my $pandora_build = "190725"; my $pandora_build = "190726";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.736 %define version 7.0NG.736
%define release 190725 %define release 190726
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.736 %define version 7.0NG.736
%define release 190725 %define release 190726
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.736" PI_VERSION="7.0NG.736"
PI_BUILD="190725" PI_BUILD="190726"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -34,7 +34,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.736 PS190725"; my $version = "7.0NG.736 PS190726";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.736 PS190725"; my $version = "7.0NG.736 PS190726";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);