mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-25 19:09:08 +02:00
synch cli with nodes pandora_enterprise#9500
This commit is contained in:
parent
38af75ccc1
commit
c6783f9a10
@ -113,6 +113,7 @@ our @EXPORT = qw(
|
|||||||
get_agentmodule_status_str
|
get_agentmodule_status_str
|
||||||
get_agentmodule_data
|
get_agentmodule_data
|
||||||
set_ssl_opts
|
set_ssl_opts
|
||||||
|
db_synch_insert
|
||||||
$RDBMS
|
$RDBMS
|
||||||
$RDBMS_QUOTE
|
$RDBMS_QUOTE
|
||||||
$RDBMS_QUOTE_STRING
|
$RDBMS_QUOTE_STRING
|
||||||
@ -1672,6 +1673,40 @@ sub set_ssl_opts($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
## Synch insert query with nodes.
|
||||||
|
########################################################################
|
||||||
|
sub db_synch_insert ($$$$$@) {
|
||||||
|
my ($dbh, $pa_config, $table, $query, $result, @values) = @_;
|
||||||
|
|
||||||
|
my $substr = "\"\%s\"";
|
||||||
|
$query =~ s/\?/$substr/g;
|
||||||
|
my $query_string = sprintf($query, @values);
|
||||||
|
|
||||||
|
my @nodes = get_db_rows($dbh, 'SELECT * FROM tmetaconsole_setup');
|
||||||
|
foreach my $node (@nodes) {
|
||||||
|
eval {
|
||||||
|
local $SIG{__DIE__};
|
||||||
|
my @values_queue = (
|
||||||
|
safe_input($query_string),
|
||||||
|
$node->{'id'},
|
||||||
|
time(),
|
||||||
|
'INSERT INTO',
|
||||||
|
$table,
|
||||||
|
'',
|
||||||
|
$result
|
||||||
|
);
|
||||||
|
|
||||||
|
my $query_queue = 'INSERT INTO tsync_queue (`sql`, `target`, `utimestamp`, `operation`, `table`, `error`, `result`) VALUES (?, ?, ?, ?, ?, ?, ?)';
|
||||||
|
db_insert ($dbh, 'id', $query_queue, @values_queue);
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
logger($pa_config, "Error add sync_queue: $@", 10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# End of function declaration
|
# End of function declaration
|
||||||
# End of defined Code
|
# End of defined Code
|
||||||
|
|
||||||
|
@ -562,13 +562,29 @@ sub cli_create_snmp_trap ($$) {
|
|||||||
sub pandora_create_user ($$$$$) {
|
sub pandora_create_user ($$$$$) {
|
||||||
my ($dbh, $name, $password, $is_admin, $comments) = @_;
|
my ($dbh, $name, $password, $is_admin, $comments) = @_;
|
||||||
|
|
||||||
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
|
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
|
||||||
|
|
||||||
|
if(is_metaconsole($conf) != 1 && $centralized) {
|
||||||
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
|
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $query = 'INSERT INTO tusuario (id_user, fullname, password, comments, is_admin) VALUES (?, ?, ?, ?, ?)';
|
||||||
|
my @values = (
|
||||||
|
safe_input($name),
|
||||||
|
safe_input($name),
|
||||||
|
$password,
|
||||||
|
safe_input($comments),
|
||||||
|
$is_admin
|
||||||
|
);
|
||||||
|
|
||||||
return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, comments, is_admin)
|
my $res = db_insert($dbh, 'id_user', $query, @values);
|
||||||
VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, safe_input($comments), $is_admin);
|
|
||||||
|
if(is_metaconsole($conf) == 1 && $centralized) {
|
||||||
|
db_synch_insert($dbh, $conf, 'tusuario', $query, $res, @values);
|
||||||
|
} else {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user