update agent
This commit is contained in:
parent
57f6ad097a
commit
c13644951f
|
@ -239,6 +239,14 @@ if ($create_agent) {
|
|||
|
||||
$agent_created_ok = true;
|
||||
|
||||
$tpolicy_group = db_get_sql("SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = ".$grupo);
|
||||
|
||||
if($tpolicy_group){
|
||||
db_process_sql_insert ('tpolicy_agents',
|
||||
array('id_policy' => $tpolicy_group, 'id_agent' => $id_agente));
|
||||
}
|
||||
|
||||
$info = 'Name: ' . $nombre_agente .
|
||||
' IP: ' . $direccion_agente .
|
||||
' Group: ' . $grupo .
|
||||
|
@ -787,6 +795,47 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
if ($old_interval != $intervalo) {
|
||||
enterprise_hook('config_agents_update_config_interval', array($id_agente, $intervalo));
|
||||
}
|
||||
|
||||
if($grupo){
|
||||
$group_old = db_get_sql("SELECT id_grupo FROM tagente WHERE id_agente =" .$id_agente);
|
||||
|
||||
$tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = ".$group_old);
|
||||
|
||||
if($tpolicy_group_old){
|
||||
foreach ($tpolicy_group_old as $key => $value) {
|
||||
$tpolicy_agents_old= db_get_sql("SELECT * FROM tpolicy_agents
|
||||
WHERE id_policy = ".$value['id_policy'] . " AND id_agent =" .$id_agente);
|
||||
|
||||
if($tpolicy_agents_old){
|
||||
$result2 = db_process_sql_update ('tpolicy_agents',
|
||||
array('pending_delete' => 1),
|
||||
array ('id_agent' => $id_agente, 'id_policy' => $value['id_policy']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//pruebassssss
|
||||
$tpolicy_group = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = ".$grupo);
|
||||
|
||||
if($tpolicy_group){
|
||||
foreach ($tpolicy_group as $key => $value) {
|
||||
$tpolicy_agents= db_get_sql("SELECT * FROM tpolicy_agents
|
||||
WHERE id_policy = ".$value['id_policy'] . " AND id_agent =" .$id_agente);
|
||||
|
||||
if(!$tpolicy_agents){
|
||||
db_process_sql_insert ('tpolicy_agents',
|
||||
array('id_policy' => $value['id_policy'], 'id_agent' => $id_agente));
|
||||
} else {
|
||||
$result3 = db_process_sql_update ('tpolicy_agents',
|
||||
array('pending_delete' => 0),
|
||||
array ('id_agent' => $id_agente, 'id_policy' => $value['id_policy']));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$info = 'Group: ' . $grupo . ' Interval: ' . $intervalo .
|
||||
' Comments: ' . $comentarios . ' Mode: ' . $modo .
|
||||
|
|
|
@ -139,9 +139,61 @@ if ($update_agents) {
|
|||
isset($values['id_grupo'])) {
|
||||
$values['update_module_count'] = 1; // Force an update of the agent cache.
|
||||
}
|
||||
$group_old = false;
|
||||
if($values['id_grupo']){
|
||||
$group_old = db_get_sql("SELECT id_grupo FROM tagente WHERE id_agente =" .$id_agent);
|
||||
}
|
||||
|
||||
$result = db_process_sql_update ('tagente',
|
||||
$values,
|
||||
array ('id_agente' => $id_agent));
|
||||
|
||||
if($group_old || $result){
|
||||
$tpolicy_group_old = db_get_sql("SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = ".$group_old);
|
||||
|
||||
if($tpolicy_group_old){
|
||||
$tpolicy_agents_old= db_get_sql("SELECT * FROM tpolicy_agents
|
||||
WHERE id_policy = ".$tpolicy_group_old . " AND id_agent =" .$id_agent);
|
||||
|
||||
if($tpolicy_agents_old){
|
||||
$result2 = db_process_sql_update ('tpolicy_agents',
|
||||
array('pending_delete' => 1),
|
||||
array ('id_agent' => $id_agent, 'id_policy' => $tpolicy_group_old));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$tpolicy_group_new = db_get_sql("SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = ".$values['id_grupo']);
|
||||
|
||||
if($tpolicy_group_new){
|
||||
$tpolicy_agents_new= db_get_sql("SELECT * FROM tpolicy_agents
|
||||
WHERE id_policy = ".$tpolicy_group_new . " AND id_agent =" .$id_agent);
|
||||
|
||||
if($tpolicy_agents_new){
|
||||
$result3 = db_process_sql_update ('tpolicy_agents',
|
||||
array('pending_delete' => 0),
|
||||
array ('id_agent' => $id_agent, 'id_policy' => $tpolicy_group_new));
|
||||
} else {
|
||||
db_process_sql_insert ('tpolicy_agents',
|
||||
array('id_policy' => $tpolicy_group_new, 'id_agent' => $id_agent));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if($values['id_grupo'] || $result){
|
||||
// $tpolicy_agents= db_get_sql("SELECT * FROM tpolicy_agents
|
||||
// WHERE id_policy = ".$tpolicy_group . " AND id_agent =" .$id_agente);
|
||||
//
|
||||
// $tpolicy_group = db_get_sql("SELECT id_policy FROM tpolicy_groups
|
||||
// WHERE id_group = ".$values['id_grupo']);
|
||||
// if ($tpolicy_group){
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// Update Custom Fields
|
||||
|
|
Loading…
Reference in New Issue