Change the policy agents to work on serialized way

This commit is contained in:
fermin831 2018-07-18 14:50:09 +02:00
parent f317f3e736
commit 223d13edd5
2 changed files with 9 additions and 6 deletions

View File

@ -796,6 +796,8 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge
* @param boolean $childGroups The flag to get agents in the child group of group parent passed. By default false. * @param boolean $childGroups The flag to get agents in the child group of group parent passed. By default false.
* @param boolean $serialized Only in metaconsole. Return the key as <server id><SEPARATOR><agent id>. By default false. * @param boolean $serialized Only in metaconsole. Return the key as <server id><SEPARATOR><agent id>. By default false.
* @param string $separator Only in metaconsole. Separator for the serialized data. By default |. * @param string $separator Only in metaconsole. Separator for the serialized data. By default |.
* @param bool $add_alert_bulk_op //TODO documentation
* @param bool $force_serialized. If the agent has not id_server (typically in node) put 0 as <server_id>.
* *
* @return array An array with all agents in the group or an empty array * @return array An array with all agents in the group or an empty array
*/ */
@ -808,7 +810,7 @@ function agents_get_group_agents (
$serialized = false, $serialized = false,
$separator = '|', $separator = '|',
$add_alert_bulk_op = false, $add_alert_bulk_op = false,
$meta_use_main_id = false $force_serialized = false
) { ) {
global $config; global $config;
@ -960,7 +962,7 @@ function agents_get_group_agents (
$table_name = 'tmetaconsole_agent'; $table_name = 'tmetaconsole_agent';
$fields = array( $fields = array(
$meta_use_main_id ? 'id_agente' : 'id_tagente AS id_agente', 'id_tagente AS id_agente',
'alias', 'alias',
'id_tmetaconsole_setup AS id_server' 'id_tmetaconsole_setup AS id_server'
); );
@ -986,8 +988,9 @@ function agents_get_group_agents (
if ($serialized && isset($row["id_server"])) { if ($serialized && isset($row["id_server"])) {
$key = $row["id_server"] . $separator . $row["id_agente"]; $key = $row["id_server"] . $separator . $row["id_agente"];
} } elseif ($force_serialized) {
else { $key = "0" . $separator . $row["id_agente"];
} else {
$key = $row["id_agente"]; $key = $row["id_agente"];
} }

View File

@ -5455,7 +5455,7 @@ function api_set_add_agent_policy($id, $thrash1, $other, $thrash2) {
} }
if ($id_agent_policy === false) { if ($id_agent_policy === false) {
$success = enterprise_hook('policies_create_agent', array($other['data'][0], $id, true)); $success = enterprise_hook('policies_create_agent', array($other['data'][0], $id));
} }
else { else {
returnError('error_add_agent_policy', __('Error adding agent to policy. The agent is already in the policy.')); returnError('error_add_agent_policy', __('Error adding agent to policy. The agent is already in the policy.'));