Merge branch 'ent-7116-anadir-token-en-snmp-browser-para-poder-aplicar-ip-del-agente-a-los-modulos' into 'develop'

Ent 7116 anadir token en snmp browser para poder aplicar ip del agente a los modulos

See merge request artica/pandorafms!6061
This commit is contained in:
Rafael Ameijeiras 2023-07-17 06:00:36 +00:00
commit 3f9aea5fe4
3 changed files with 28 additions and 4 deletions

View File

@ -182,6 +182,7 @@ try {
if ($method == 'snmp_browser_create_modules') {
// Get target ids from form.
$use_agent_ip = get_parameter('use_agent_ip', '');
$id_items = get_parameter('id_item2', null);
$id_target = null;
if (empty($id_items) === false) {
@ -209,7 +210,8 @@ try {
$module_target,
$snmp_conf_values,
$id_target,
$server_to_exec
$server_to_exec,
$use_agent_ip
);
// Return fail modules for error/success message.

View File

@ -743,7 +743,8 @@ function modules_create_agent_module(
string $name,
array $values=[],
bool $disableACL=false,
$tags=false
$tags=false,
$use_agent_ip=false,
) {
global $config;
@ -785,6 +786,10 @@ function modules_create_agent_module(
return ERR_EXIST;
}
if ($use_agent_ip === true) {
$values['ip_target'] = agents_get_address($id_agent);
}
// Encrypt passwords.
if (isset($values['plugin_pass']) === true) {
// Avoid two times encryption.

View File

@ -1291,7 +1291,8 @@ function snmp_browser_create_modules_snmp(
string $module_target,
array $snmp_values,
?array $id_target,
?string $server_to_exec=null
?string $server_to_exec=null,
?string $use_agent_ip=''
) {
$target_ip = null;
$target_port = null;
@ -1350,6 +1351,12 @@ function snmp_browser_create_modules_snmp(
}
}
if (empty($use_agent_ip) === false) {
$use_agent_ip = true;
} else {
$use_agent_ip = false;
}
$fail_modules = [];
foreach ($targets_oids as $key => $target_oid) {
@ -1514,7 +1521,7 @@ function snmp_browser_create_modules_snmp(
'history_data' => 1,
];
foreach ($id_target as $agent) {
$ids[] = modules_create_agent_module($agent, $oid['oid'], $values);
$ids[] = modules_create_agent_module($agent, $oid['oid'], $values, false, false, $use_agent_ip);
}
} else if ($module_target == 'policy') {
// Policies only in enterprise version.
@ -1803,6 +1810,16 @@ function snmp_browser_print_create_module_massive(
true
);
$table->data[4][0] = html_print_label_input_block(
__('Use agent IP'),
html_print_checkbox(
'use_agent_ip',
1,
false,
true
)
);
$output .= html_print_table($table, true);
// SNMP extradata.