Merge branch 'ent-3295-revision-comportamiento-metaconsola-con-nodo-multi-servidor' into 'develop'

Ent 3295 revision comportamiento metaconsola con nodo multi servidor

See merge request artica/pandorafms!2440
This commit is contained in:
Daniel Rodriguez 2019-06-19 12:15:14 +02:00
commit cfaeaa3c9c
5 changed files with 30 additions and 8 deletions

View File

@ -19,8 +19,8 @@ if (isset($config['homedir'])) {
ui_require_css_file('login');
require_once $homedir.'include/functions_ui.php';
require_once $homedir.'include/functions.php';
require_once __DIR__.'/../include/functions_ui.php';
require_once __DIR__.'/../include/functions.php';
require_once __DIR__.'/../include/functions_html.php';

View File

@ -65,7 +65,7 @@ define('ERR_NODATA', -70000);
define('ERR_CONNECTION', -80000);
define('ERR_DISABLED', -90000);
define('ERR_WRONG', -100000);
define('ERR_WRONG_NAME', -100001);
define('ERR_WRONG_MR', -100001);
define('ERR_WRONG_PARAMETERS', -100002);
define('ERR_ACL', -110000);
define('ERR_AUTH', -120000);

View File

@ -1475,6 +1475,13 @@ function enterprise_include($filename)
}
/**
* Includes a file from enterprise section.
*
* @param string $filename Target file.
*
* @return mixed Result code.
*/
function enterprise_include_once($filename)
{
global $config;
@ -1585,6 +1592,11 @@ function safe_sql_string($string)
}
/**
* Verifies if current Pandora FMS installation is a Metaconsole.
*
* @return boolean True metaconsole installation, false if not.
*/
function is_metaconsole()
{
global $config;
@ -1592,6 +1604,18 @@ function is_metaconsole()
}
/**
* Check if current Pandora FMS installation has joined a Metaconsole env.
*
* @return boolean True joined, false if not.
*/
function has_metaconsole()
{
global $config;
return (bool) $config['node_metaconsole'] && (bool) $config['metaconsole_node_id'];
}
/**
* @brief Check if there is management operations are allowed in current context
* (node // meta)

View File

@ -4810,7 +4810,7 @@ sub pandora_process_event_replication ($) {
}
# Get server id on metaconsole
my $metaconsole_server_id = enterprise_hook('get_metaconsole_setup_server_id', [$dbh_metaconsole, safe_input($pa_config->{'servername'})]);
my $metaconsole_server_id = enterprise_hook('get_metaconsole_setup_server_id', [$dbh]);
# If the server name is not found in metaconsole setup: abort
if($metaconsole_server_id == -1) {

View File

@ -3801,9 +3801,8 @@ sub cli_get_agent_group() {
else {
my $id_group = get_agent_group ($dbh_metaconsole, $id_agent);
my $group_name = get_group_name ($dbh_metaconsole, $id_group);
my $metaconsole_name = enterprise_hook('get_metaconsole_setup_server_name',[$dbh, $server]);
$agent_name = safe_output($agent_name);
print "[INFO] Server: $metaconsole_name Agent: $agent_name Name Group: $group_name\n\n";
print "[INFO] Agent: $agent_name Name Group: $group_name\n\n";
}
}
}
@ -3843,7 +3842,6 @@ sub cli_get_agent_group_id() {
foreach my $server (@servers_id) {
my $dbh_metaconsole = enterprise_hook('get_node_dbh',[$conf, $server, $dbh]);
my $metaconsole_name = enterprise_hook('get_metaconsole_setup_server_name',[$dbh, $server]);
my $id_agent = get_agent_id($dbh_metaconsole,$agent_name);
if ($id_agent == -1) {
@ -3852,7 +3850,7 @@ sub cli_get_agent_group_id() {
else {
my $id_group = get_agent_group ($dbh_metaconsole, $id_agent);
$agent_name = safe_output($agent_name);
print "Server: $metaconsole_name Agent: $agent_name ID Group: $id_group\n\n";
print "Agent: $agent_name ID Group: $id_group\n\n";
}
}
}