1st approach simplifying MC management
This commit is contained in:
parent
c0f40a8d5f
commit
bd88cbd42d
|
@ -19,8 +19,8 @@ if (isset($config['homedir'])) {
|
||||||
|
|
||||||
ui_require_css_file('login');
|
ui_require_css_file('login');
|
||||||
|
|
||||||
require_once $homedir.'include/functions_ui.php';
|
require_once __DIR__.'/../include/functions_ui.php';
|
||||||
require_once $homedir.'include/functions.php';
|
require_once __DIR__.'/../include/functions.php';
|
||||||
require_once __DIR__.'/../include/functions_html.php';
|
require_once __DIR__.'/../include/functions_html.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ define('ERR_NODATA', -70000);
|
||||||
define('ERR_CONNECTION', -80000);
|
define('ERR_CONNECTION', -80000);
|
||||||
define('ERR_DISABLED', -90000);
|
define('ERR_DISABLED', -90000);
|
||||||
define('ERR_WRONG', -100000);
|
define('ERR_WRONG', -100000);
|
||||||
define('ERR_WRONG_NAME', -100001);
|
define('ERR_WRONG_MR', -100001);
|
||||||
define('ERR_WRONG_PARAMETERS', -100002);
|
define('ERR_WRONG_PARAMETERS', -100002);
|
||||||
define('ERR_ACL', -110000);
|
define('ERR_ACL', -110000);
|
||||||
define('ERR_AUTH', -120000);
|
define('ERR_AUTH', -120000);
|
||||||
|
|
|
@ -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)
|
function enterprise_include_once($filename)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// Load enterprise extensions
|
defined('ENTERPRISE_DIR') || define('ENTERPRISE_DIR', 'enterprise');
|
||||||
|
|
||||||
|
// Load enterprise extensions.
|
||||||
$filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename);
|
$filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename);
|
||||||
|
|
||||||
if ($filepath === false) {
|
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()
|
function is_metaconsole()
|
||||||
{
|
{
|
||||||
global $config;
|
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
|
* @brief Check if there is management operations are allowed in current context
|
||||||
* (node // meta)
|
* (node // meta)
|
||||||
|
|
|
@ -3801,9 +3801,8 @@ sub cli_get_agent_group() {
|
||||||
else {
|
else {
|
||||||
my $id_group = get_agent_group ($dbh_metaconsole, $id_agent);
|
my $id_group = get_agent_group ($dbh_metaconsole, $id_agent);
|
||||||
my $group_name = get_group_name ($dbh_metaconsole, $id_group);
|
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);
|
$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) {
|
foreach my $server (@servers_id) {
|
||||||
my $dbh_metaconsole = enterprise_hook('get_node_dbh',[$conf, $server, $dbh]);
|
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);
|
my $id_agent = get_agent_id($dbh_metaconsole,$agent_name);
|
||||||
|
|
||||||
if ($id_agent == -1) {
|
if ($id_agent == -1) {
|
||||||
|
@ -3852,7 +3850,7 @@ sub cli_get_agent_group_id() {
|
||||||
else {
|
else {
|
||||||
my $id_group = get_agent_group ($dbh_metaconsole, $id_agent);
|
my $id_group = get_agent_group ($dbh_metaconsole, $id_agent);
|
||||||
$agent_name = safe_output($agent_name);
|
$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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue