1st approach simplifying MC management

This commit is contained in:
fbsanchez 2019-05-22 15:31:59 +02:00
parent c0f40a8d5f
commit bd88cbd42d
4 changed files with 32 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

@ -1469,11 +1469,20 @@ 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;
// Load enterprise extensions
defined('ENTERPRISE_DIR') || define('ENTERPRISE_DIR', 'enterprise');
// Load enterprise extensions.
$filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename);
if ($filepath === false) {
@ -1573,6 +1582,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;
@ -1580,6 +1594,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

@ -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";
}
}
}