Merge branch '17-compatibilidad-ante-cambios-de-ip-en-el-agente-integria-4208' into 'develop'

Allow automatic ip

Closes #17

See merge request !31
This commit is contained in:
daniel 2017-01-16 17:47:55 +01:00
commit 981273b2b6
6 changed files with 80 additions and 19 deletions

View File

@ -31,6 +31,7 @@ $ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent);
check_login ();
$ip_target = (string) get_parameter ('ip_target', $ipAgent);
$use_agent = get_parameter ('use_agent');
$snmp_community = (string) get_parameter ('snmp_community', 'public');
$snmp_version = get_parameter('snmp_version', '1');
$snmp3_auth_user = get_parameter('snmp3_auth_user');
@ -305,7 +306,13 @@ if ($create_modules) {
$common_values['tcp_port'] = $tcp_port;
}
$common_values['snmp_community'] = $snmp_community;
$common_values['ip_target'] = $ip_target;
if($use_agent){
$common_values['ip_target'] = 'auto';
}
else{
$common_values['ip_target'] = $ip_target;
}
$common_values['tcp_send'] = $snmp_version;
if ($snmp_version == '3') {
@ -696,18 +703,22 @@ $table->data[0][1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60,
$table->data[0][2] = '<b>' . __('Port') . '</b>';
$table->data[0][3] = html_print_input_text ('tcp_port', $tcp_port, '', 5, 20, true);
$table->data[1][0] = '<b>' . __('Use agent ip') . '</b>';
$table->data[1][1] = html_print_checkbox ('use_agent', 1, $use_agent, true);
$snmp_versions['1'] = 'v. 1';
$snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
$snmp_versions['3'] = 'v. 3';
$table->data[1][0] = '<b>' . __('SNMP community') . '</b>';
$table->data[1][1] = html_print_input_text ('snmp_community', $snmp_community, '', 15, 60, true);
$table->data[2][0] = '<b>' . __('SNMP community') . '</b>';
$table->data[2][1] = html_print_input_text ('snmp_community', $snmp_community, '', 15, 60, true);
$table->data[1][2] = '<b>' . __('SNMP version') . '</b>';
$table->data[1][3] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, '');
$table->data[2][2] = '<b>' . __('SNMP version') . '</b>';
$table->data[2][3] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, '');
$table->data[2][3] .= '<div id="spinner_modules" style="float: left; display: none;">' . html_print_image("images/spinner.gif", true) . '</div>';
$table->data[1][3] .= '<div id="spinner_modules" style="float: left; display: none;">' . html_print_image("images/spinner.gif", true) . '</div>';
html_print_input_hidden('snmpwalk', 1);
html_print_table($table);
@ -760,9 +771,10 @@ if (!$fail) {
echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
echo "<form method='post' action='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_explorer&id_agente=$id_agent'>";
echo '<span id="form_interfaces">';
html_print_input_hidden('create_modules', 1);
html_print_input_hidden('ip_target', $ip_target);
html_print_input_hidden('use_agent', $use_agent);
html_print_input_hidden('tcp_port', $tcp_port);
html_print_input_hidden('snmp_community', $snmp_community);
html_print_input_hidden('snmp_version', $snmp_version);

View File

@ -28,6 +28,7 @@ $ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent);
check_login ();
$ip_target = (string) get_parameter ('ip_target', $ipAgent);
$use_agent = get_parameter ('use_agent');
$snmp_community = (string) get_parameter ('snmp_community', 'public');
$snmp_version = get_parameter('snmp_version', '1');
$snmp3_auth_user = get_parameter('snmp3_auth_user');
@ -136,7 +137,12 @@ if ($create_modules) {
$values['tcp_port'] = $tcp_port;
}
$values['snmp_community'] = $snmp_community;
$values['ip_target'] = $ip_target;
if($use_agent){
$values['ip_target'] = 'auto';
}
else{
$values['ip_target'] = $ip_target;
}
$values['tcp_send'] = $snmp_version;
if ($snmp_version == '3') {
@ -336,18 +342,21 @@ $table->data[0][1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60,
$table->data[0][2] = '<b>' . __('Port') . '</b>';
$table->data[0][3] = html_print_input_text ('tcp_port', $tcp_port, '', 5, 20, true);
$table->data[1][0] = '<b>' . __('Use agent ip') . '</b>';
$table->data[1][1] = html_print_checkbox ('use_agent', 1, $use_agent, true);
$snmp_versions['1'] = 'v. 1';
$snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
$snmp_versions['3'] = 'v. 3';
$table->data[1][0] = '<b>' . __('SNMP community') . '</b>';
$table->data[1][1] = html_print_input_text ('snmp_community', $snmp_community, '', 15, 60, true);
$table->data[2][0] = '<b>' . __('SNMP community') . '</b>';
$table->data[2][1] = html_print_input_text ('snmp_community', $snmp_community, '', 15, 60, true);
$table->data[1][2] = '<b>' . __('SNMP version') . '</b>';
$table->data[1][3] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, '');
$table->data[2][2] = '<b>' . __('SNMP version') . '</b>';
$table->data[2][3] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, '');
$table->data[1][3] .= '<div id="spinner_modules" style="float: left; display: none;">' . html_print_image("images/spinner.gif", true) . '</div>';
$table->data[2][3] .= '<div id="spinner_modules" style="float: left; display: none;">' . html_print_image("images/spinner.gif", true) . '</div>';
html_print_input_hidden('snmpwalk', 1);
html_print_table($table);
@ -409,6 +418,7 @@ if (!empty($interfaces_list)) {
html_print_input_hidden('create_modules', 1);
html_print_input_hidden('ip_target', $ip_target);
html_print_input_hidden('use_agent', $use_agent);
html_print_input_hidden('tcp_port', $tcp_port);
html_print_input_hidden('snmp_community', $snmp_community);
html_print_input_hidden('snmp_version', $snmp_version);

View File

@ -974,6 +974,9 @@ if ($update_module || $create_module) {
$parent_module_id = (int) get_parameter('parent_module_id');
$ip_target = (string) get_parameter ('ip_target');
if($ip_target == ''){
$ip_target = 'auto';
}
$custom_id = (string) get_parameter ('custom_id');
$history_data = (int) get_parameter('history_data');
$dynamic_interval = (int) get_parameter('dynamic_interval');

View File

@ -65,7 +65,25 @@ $extra_title = __('Network server module');
$data = array ();
$data[0] = __('Target IP');
$data[1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60, true);
//show agent_for defect;
html_debug_print($ip_target);
if($ip_target == 'auto'){
$ip_target = agents_get_address ($id_agente);
}
if($page == 'enterprise/godmode/policies/policy_modules'){
$target_ip_values = array();
$target_ip_values['auto'] = __('Auto');
$target_ip_values['force_pri'] = __('Force primary key');
$target_ip_values['custom'] = __('Custom');
$data[1] = html_print_select ($target_ip_values, 'ip_target', '', '', '', '',
true, false, false, '', false, 'width:200px;');
//$table->data['edit35'][1] .= html_print_input_text ('custom_ip_target', '', '', 15, 60, true);
}
else{
$data[1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60, true);
}
// In ICMP modules, port is not configurable
if ($id_module_type >= 6 && $id_module_type <= 7) {

View File

@ -480,9 +480,17 @@ $table->data['edit3'][2] = __('SMNP community');
$table->data['edit3'][3] = html_print_input_text ('snmp_community', '',
'', 10, 15, true);
$target_ip_values = array();
$target_ip_values['auto'] = __('Auto');
$target_ip_values['force_pri'] = __('Force primary key');
$target_ip_values['custom'] = __('Custom');
$table->data['edit35'][0] = __('Target IP');
$table->data['edit35'][1] = html_print_input_text ('ip_target', '', '',
15, 60, true);
$table->data['edit35'][1] = html_print_select ($target_ip_values,
'ip_target', '', '', __('No change'), '', true, false, false, '', false, 'width:200px;');
$table->data['edit35'][1] .= html_print_input_text ('custom_ip_target', '', '', 15, 60, true);
$table->data['edit35'][2] = __('SNMP version');
$table->data['edit35'][3] = html_print_select ($snmp_versions,
'tcp_send', '', '', __('No change'), '', true, false, false, '');

View File

@ -411,9 +411,19 @@ function modules_update_agent_module ($id, $values,
return ERR_EXIST;
}
}
if(isset ($values['ip_target'])){
if($values['ip_target'] == 'force_pri'){
$sql_agent = "SELECT id_agente FROM tagente_modulo WHERE id_agente_modulo=" . $id;
$id_agente = mysql_db_process_sql($sql_agent);
$values['ip_target'] = agents_get_address ($id_agente);
}
elseif($values['ip_target'] == 'custom'){
$values['ip_target'] = $values['custom_ip_target'];
}
}
unset($values['custom_ip_target']);
$where = array();
$where['id_agente_modulo'] = $id;
if ($onlyNoDeletePending) {