2013-06-25 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/configurar_agente.php, include/functions_agents.php: fixed the operations with the ip or ips adress of agent. MERGED FROM THE BRANCH PANDORA_4_0 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8404 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
84d47d8e9d
commit
6b5dc3bc6b
|
@ -1,3 +1,11 @@
|
||||||
|
2013-06-25 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* godmode/agentes/configurar_agente.php,
|
||||||
|
include/functions_agents.php: fixed the operations with the ip or
|
||||||
|
ips adress of agent.
|
||||||
|
|
||||||
|
MERGED FROM THE BRANCH PANDORA_4_0
|
||||||
|
|
||||||
2013-06-25 Miguel de Dios <miguel.dedios@artica.es>
|
2013-06-25 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* godmode/menu.php: fixed the default value for refresh in the
|
* godmode/menu.php: fixed the default value for refresh in the
|
||||||
|
|
|
@ -297,7 +297,7 @@ if ($id_agente) {
|
||||||
if ($inventorytab == -1)
|
if ($inventorytab == -1)
|
||||||
$inventorytab = "";
|
$inventorytab = "";
|
||||||
|
|
||||||
|
|
||||||
$has_remote_conf = enterprise_hook('config_agents_has_remote_configuration',array($id_agente));
|
$has_remote_conf = enterprise_hook('config_agents_has_remote_configuration',array($id_agente));
|
||||||
|
|
||||||
if ($has_remote_conf === true) {
|
if ($has_remote_conf === true) {
|
||||||
|
@ -377,6 +377,7 @@ if ($id_agente) {
|
||||||
'alert' => $alerttab);
|
'alert' => $alerttab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Extensions tabs
|
||||||
foreach ($config['extensions'] as $extension) {
|
foreach ($config['extensions'] as $extension) {
|
||||||
if (isset($extension['extension_god_tab']) && check_acl ($config["id_user"], $group, "AW", $id_agente)) {
|
if (isset($extension['extension_god_tab']) && check_acl ($config["id_user"], $group, "AW", $id_agente)) {
|
||||||
$image = $extension['extension_god_tab']['icon'];
|
$image = $extension['extension_god_tab']['icon'];
|
||||||
|
@ -526,13 +527,19 @@ if ($update_agent) { // if modified some agent paramenter
|
||||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||||
$direccion_agente = io_safe_input($direccion_agente);
|
$direccion_agente = io_safe_input($direccion_agente);
|
||||||
$address_list = (string) get_parameter_post ("address_list", '');
|
$address_list = (string) get_parameter_post ("address_list", '');
|
||||||
if ($address_list != $direccion_agente && $direccion_agente == agents_get_address ($id_agente) && $address_list != agents_get_address ($id_agente)) {
|
|
||||||
|
if ($address_list != $direccion_agente &&
|
||||||
|
$direccion_agente == agents_get_address ($id_agente) &&
|
||||||
|
$address_list != agents_get_address ($id_agente)) {
|
||||||
|
|
||||||
//If we selected another IP in the drop down list to be 'primary':
|
//If we selected another IP in the drop down list to be 'primary':
|
||||||
// a) field is not the same as selectbox
|
// a) field is not the same as selectbox
|
||||||
// b) field has not changed from current IP
|
// b) field has not changed from current IP
|
||||||
// c) selectbox is not the current IP
|
// c) selectbox is not the current IP
|
||||||
if ($address_list != 0)
|
|
||||||
|
if (!empty($address_list)) {
|
||||||
$direccion_agente = $address_list;
|
$direccion_agente = $address_list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$grupo = (int) get_parameter_post ("grupo", 0);
|
$grupo = (int) get_parameter_post ("grupo", 0);
|
||||||
$intervalo = (int) get_parameter_post ("intervalo", SECONDS_5MINUTES);
|
$intervalo = (int) get_parameter_post ("intervalo", SECONDS_5MINUTES);
|
||||||
|
@ -567,7 +574,7 @@ if ($update_agent) { // if modified some agent paramenter
|
||||||
if ($old_value === false) {
|
if ($old_value === false) {
|
||||||
// Create custom field if not exist
|
// Create custom field if not exist
|
||||||
db_process_sql_insert ('tagent_custom_data',
|
db_process_sql_insert ('tagent_custom_data',
|
||||||
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
|
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
db_process_sql_update ('tagent_custom_data',
|
db_process_sql_update ('tagent_custom_data',
|
||||||
|
@ -592,10 +599,12 @@ if ($update_agent) { // if modified some agent paramenter
|
||||||
agents_add_address ($id_agente, $direccion_agente);
|
agents_add_address ($id_agente, $direccion_agente);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$action_delete_ip = (bool)get_parameter('delete_ip', false);
|
||||||
//If IP is set for deletion, delete first
|
//If IP is set for deletion, delete first
|
||||||
if (isset ($_POST["delete_ip"])) {
|
if ($action_delete_ip) {
|
||||||
$delete_ip = get_parameter_post ("address_list");
|
$delete_ip = get_parameter_post ("address_list");
|
||||||
agents_delete_address ($id_agente, $delete_ip);
|
|
||||||
|
$direccion_agente = agents_delete_address($id_agente, $delete_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = db_process_sql_update ('tagente',
|
$result = db_process_sql_update ('tagente',
|
||||||
|
@ -635,6 +644,7 @@ if ($update_agent) { // if modified some agent paramenter
|
||||||
ui_print_success_message (__('Successfully updated'));
|
ui_print_success_message (__('Successfully updated'));
|
||||||
db_pandora_audit("Agent management",
|
db_pandora_audit("Agent management",
|
||||||
"Updated agent $nombre_agente", false, false, $info);
|
"Updated agent $nombre_agente", false, false, $info);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -800,6 +810,7 @@ if ($update_module || $create_module) {
|
||||||
$plugin_pass = (int) get_parameter ('plugin_pass');
|
$plugin_pass = (int) get_parameter ('plugin_pass');
|
||||||
else
|
else
|
||||||
$plugin_pass = (string) get_parameter ('plugin_pass');
|
$plugin_pass = (string) get_parameter ('plugin_pass');
|
||||||
|
|
||||||
$plugin_parameter = (string) get_parameter ('plugin_parameter');
|
$plugin_parameter = (string) get_parameter ('plugin_parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
|
||||||
// Create address for this agent in taddress
|
// Create address for this agent in taddress
|
||||||
agents_add_address ($id_agent, $ip_address);
|
agents_add_address ($id_agent, $ip_address);
|
||||||
|
|
||||||
|
|
||||||
db_pandora_audit ("Agent management", "New agent '$name' created");
|
db_pandora_audit ("Agent management", "New agent '$name' created");
|
||||||
|
|
||||||
return $id_agent;
|
return $id_agent;
|
||||||
|
@ -202,6 +203,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
||||||
$selectText = 'COUNT(talert_template_modules.id) AS count';
|
$selectText = 'COUNT(talert_template_modules.id) AS count';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = sprintf ("SELECT %s
|
$sql = sprintf ("SELECT %s
|
||||||
FROM talert_template_modules
|
FROM talert_template_modules
|
||||||
INNER JOIN tagente_modulo t2
|
INNER JOIN tagente_modulo t2
|
||||||
|
@ -914,6 +916,7 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
||||||
// user can read the agents.
|
// user can read the agents.
|
||||||
// =================================================================
|
// =================================================================
|
||||||
if ($id_agent === null) {
|
if ($id_agent === null) {
|
||||||
|
|
||||||
$sql = "SELECT id_agente
|
$sql = "SELECT id_agente
|
||||||
FROM tagente
|
FROM tagente
|
||||||
WHERE id_grupo IN (" . implode(',', $id_groups) . ")";
|
WHERE id_grupo IN (" . implode(',', $id_groups) . ")";
|
||||||
|
@ -937,6 +940,7 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
||||||
$id_agent = safe_int ($id_agent, 1);
|
$id_agent = safe_int ($id_agent, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$where = "(
|
$where = "(
|
||||||
1 = (
|
1 = (
|
||||||
SELECT is_admin
|
SELECT is_admin
|
||||||
|
@ -1333,23 +1337,35 @@ function agents_delete_address ($id_agent, $ip_address) {
|
||||||
|
|
||||||
$sql = sprintf ("SELECT id_ag
|
$sql = sprintf ("SELECT id_ag
|
||||||
FROM taddress_agent, taddress
|
FROM taddress_agent, taddress
|
||||||
WHERE taddress_agent.id_a = taddress.id_a AND ip = '%s'
|
WHERE taddress_agent.id_a = taddress.id_a
|
||||||
AND id_agent = %d", $ip_address, $id_agent);
|
AND ip = '%s'
|
||||||
|
AND id_agent = %d", $ip_address, $id_agent);
|
||||||
$id_ag = db_get_sql ($sql);
|
$id_ag = db_get_sql ($sql);
|
||||||
if ($id_ag !== false) {
|
if ($id_ag !== false) {
|
||||||
db_process_sql_delete('taddress_agent', array('id_ag' => $id_ag));
|
db_process_sql_delete('taddress_agent', array('id_ag' => $id_ag));
|
||||||
}
|
}
|
||||||
|
|
||||||
$agent_name = agents_get_name($id_agent, "");
|
$agent_name = agents_get_name($id_agent, "");
|
||||||
db_pandora_audit("Agent management",
|
db_pandora_audit("Agent management",
|
||||||
"Deleted IP $ip_address from agent '$agent_name'");
|
"Deleted IP $ip_address from agent '$agent_name'");
|
||||||
|
|
||||||
// Need to change main address?
|
// Need to change main address?
|
||||||
if (agents_get_address ($id_agent) == $ip_address) {
|
if (agents_get_address($id_agent) == $ip_address) {
|
||||||
$new_ips = agents_get_addresses ($id_agent);
|
$new_ips = agents_get_addresses ($id_agent);
|
||||||
|
if (empty($new_ips)) {
|
||||||
|
$new_ip = '';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$new_ip = reset($new_ips);
|
||||||
|
}
|
||||||
|
|
||||||
// Change main address in agent to first one in the list
|
// Change main address in agent to first one in the list
|
||||||
|
|
||||||
db_process_sql_update('tagente', array('direccion' => current ($new_ips)),
|
db_process_sql_update('tagente',
|
||||||
|
array('direccion' => $new_ip),
|
||||||
array('id_agente' => $id_agent));
|
array('id_agente' => $id_agent));
|
||||||
|
|
||||||
|
return $new_ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1681,6 +1697,7 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue