diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index 658f7dd9fc..54a0a77d49 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -228,11 +228,11 @@ foreach ($result as $row) { $rowPair = !$rowPair; $data = array(); - $data[0] = $row["id_usuario"]; + $data[0] = io_safe_output($row["id_usuario"]); $data[1] = ui_print_session_action_icon($row["accion"], true) . $row["accion"]; $data[2] = ui_print_help_tip(date($config["date_format"], $row["utimestamp"]), true) . ui_print_timestamp($row["utimestamp"], true); - $data[3] = $row["ip_origen"]; + $data[3] = io_safe_output($row["ip_origen"]); $data[4] = io_safe_output($row["descripcion"]); if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index 8500166413..f57d7cd48e 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -484,21 +484,23 @@ if($append_tab_filter){ $table->id = 'save_filter_form'; $table->width = '100%'; $table->class = 'databox'; + $table->rowspan = array(); if($filters['id'] == 'extended_create_filter'){ echo "
"; $table->data[0][0] = __('Filter name'); $table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true); - $table->data[0][2] = __('Group'); - $table->data[0][3] = html_print_select_groups( + $table->data[1][0] = __('Group'); + $table->data[1][1] = html_print_select_groups( $config['id_user'], 'AR', true, 'group_search_cr', 0, '', '', '0', true, false, - false, '', false, '', false, false, + false, '', false, 'width:180px;', false, false, 'id_grupo', false ); - $table->data[0][4] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true); + $table->rowspan[0][2] = 2; + $table->data[0][2] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true); } else{ echo "
"; @@ -516,7 +518,7 @@ if($append_tab_filter){ $table->data[1][1] = html_print_select_groups( $config['id_user'], 'AR', true, 'group_search_up', $group, '', '', '0', true, false, - false, '', false, '', false, false, + false, '', false, 'width:180px;', false, false, 'id_grupo', false ); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 7ce0d2df69..c223738b2a 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -485,8 +485,6 @@ define("OPTION_AGENT_AUTOCOMPLETE", 9); define("OPTION_SELECT_MULTISELECTION", 10); define("OPTION_COLOR_PICKER", 11); -define("DASHBOARD_WIDGET_ID_VISUAL_CONSOLE", 22); - /* Transactional map constants */ define("NODE_TYPE", 0); define("ARROW_TYPE", 1); diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index dcc038b620..404fd2cfbf 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -193,6 +193,13 @@ function get_custom_fields_data ($custom_field_name) { function agent_counters_custom_fields($filters){ //filter by status agent $and_status = ""; + + $agent_state_normal = 0; + $agent_state_critical = 0; + $agent_state_warning = 0; + $agent_state_unknown = 0; + $agent_state_notinit = 0; + $agent_state_total = 0; if(is_array($filters['id_status'])){ if(!in_array(-1, $filters['id_status'])){ if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $filters['id_status'])){ @@ -200,34 +207,34 @@ function agent_counters_custom_fields($filters){ $and_status = " AND ( "; foreach ($filters['id_status'] as $key => $value) { $and_status .= ($key != 0) - ? " OR (" - : " ("; + ? " OR " + : " "; switch ($value) { default: case AGENT_STATUS_NORMAL: - $and_status .= " ta.critical_count = 0 - AND ta.warning_count = 0 - AND ta.unknown_count = 0 - AND ta.total_count <> ta.notinit_count ) "; + $agent_state_normal = agents_get_status_clause(AGENT_STATUS_NORMAL); + $and_status .= agents_get_status_clause(AGENT_STATUS_NORMAL); break; case AGENT_STATUS_CRITICAL: - $and_status .= " ta.critical_count > 0 ) "; + $and_status .= agents_get_status_clause(AGENT_STATUS_CRITICAL); + $agent_state_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL); break; case AGENT_STATUS_WARNING: - $and_status .= " ta.critical_count = 0 - AND ta.warning_count > 0 ) "; + $and_status .= agents_get_status_clause(AGENT_STATUS_WARNING); + $agent_state_warning = agents_get_status_clause(AGENT_STATUS_WARNING); break; case AGENT_STATUS_UNKNOWN: - $and_status .= " ta.critical_count = 0 - AND ta.warning_count = 0 - AND ta.unknown_count > 0 ) "; + $and_status .= agents_get_status_clause(AGENT_STATUS_UNKNOWN); + $agent_state_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN); break; case AGENT_STATUS_NOT_INIT: - $and_status .= " ta.total_count = ta.notinit_count ) "; + $and_status .= agents_get_status_clause(AGENT_STATUS_NOT_INIT); + $agent_state_notinit = agents_get_status_clause(AGENT_STATUS_NOT_INIT); break; } } $and_status .= " ) "; + $agent_state_total = agents_get_status_clause(AGENT_STATUS_ALL); } } else{ @@ -237,14 +244,45 @@ function agent_counters_custom_fields($filters){ OR ( ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0 ) OR ( ta.total_count = ta.notinit_count ) ) "; + + $agent_state_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL); + $agent_state_warning = agents_get_status_clause(AGENT_STATUS_WARNING); + $agent_state_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN); + $agent_state_notinit = agents_get_status_clause(AGENT_STATUS_NOT_INIT); + $agent_state_total = agents_get_status_clause(AGENT_STATUS_ALL); } } + else{ + $agent_state_normal = agents_get_status_clause(AGENT_STATUS_NORMAL); + $agent_state_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL); + $agent_state_warning = agents_get_status_clause(AGENT_STATUS_WARNING); + $agent_state_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN); + $agent_state_notinit = agents_get_status_clause(AGENT_STATUS_NOT_INIT); + $agent_state_total = agents_get_status_clause(AGENT_STATUS_ALL); + } } //filter by status module + $empty_agents_count = "UNION ALL + SELECT ta.id_agente, + 0 AS c_m_total, + 0 AS mm_normal, + 0 AS mm_critical, + 0 AS mm_warning, + 0 AS mm_unknown, + 0 AS mm_not_init, + 0 AS mm_total + FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND ta.total_count = 0 + $groups_and"; + $and_module_status = ""; if(is_array($filters['module_status'])){ if(!in_array(-1, $filters['module_status'])){ + $empty_agents_count = ""; if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $filters['module_status'])){ if(count($filters['module_status']) > 0){ $and_module_status = " AND ( "; @@ -277,25 +315,15 @@ function agent_counters_custom_fields($filters){ else{ //not normal $and_module_status = "AND tae.estado <> 0 AND tae.estado <> 300 "; + $empty_agents_count = ""; } } } //filters module if($filters['module_search']){ - $and_module_search = 'AND nombre LIKE "%' . $filters['module_search'] . '%"'; - } - - $module_filter = ""; - if($and_module_search != '' || $and_module_status != ''){ - $module_filter = ' AND ( - SELECT count(*) AS n - FROM tagente_modulo tam - INNER JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo - WHERE tam.id_agente=ta.id_agente - '. $and_module_search . ' ' . $and_module_status .' - ) > 0 '; + $and_module_search = 'AND tam.nombre LIKE "%' . $filters['module_search'] . '%"'; + $empty_agents_count = ""; } //filter group and check ACL groups @@ -359,42 +387,63 @@ function agent_counters_custom_fields($filters){ // Establishes connection if (metaconsole_load_external_db ($server_data) !== NOERR) continue; - $query = sprintf("SELECT - tcd.description as name_data, - SUM(ta.normal_count) AS m_normal, - SUM(ta.critical_count) AS m_critical, - SUM(ta.warning_count) AS m_warning, - SUM(ta.unknown_count) AS m_unknown, - SUM(ta.notinit_count) AS m_not_init, - SUM(ta.fired_count) AS m_alerts, - SUM(ta.total_count) AS m_total, - SUM(IF(ta.critical_count > 0, 1, 0)) AS a_critical, - SUM(IF(ta.critical_count = 0 AND ta.warning_count > 0, 1, 0)) AS a_warning, - SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0, 1, 0)) AS a_unknown, - SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count = 0 AND ta.notinit_count <> ta.total_count, 1, 0)) AS a_normal, - SUM(IF(ta.total_count = ta.notinit_count, 1, 0)) AS a_not_init, - COUNT(ta.id_agente) AS a_agents, - GROUP_CONCAT(DISTINCT(ta.id_agente) SEPARATOR ',') as ids - FROM tagente ta - INNER JOIN tagent_custom_data tcd - ON tcd.id_agent = ta.id_agente + $query = sprintf( + "SELECT tcd.description AS name_data, + SUM(IF($agent_state_total, 1, 0)) AS a_agents, + SUM(IF($agent_state_critical, 1, 0)) AS a_critical, + SUM(IF($agent_state_warning, 1, 0)) AS a_warning, + SUM(IF($agent_state_unknown, 1, 0)) AS a_unknown, + SUM(IF($agent_state_normal, 1, 0)) AS a_normal, + SUM(IF($agent_state_notinit, 1, 0)) AS a_not_init, + SUM(tagent_counters.mm_normal) AS m_normal, + SUM(tagent_counters.mm_critical) AS m_critical, + SUM(tagent_counters.mm_warning) AS m_warning, + SUM(tagent_counters.mm_unknown) AS m_unknown, + SUM(tagent_counters.mm_not_init) AS m_not_init, + SUM(tagent_counters.mm_total) AS m_total + FROM tagent_custom_data tcd INNER JOIN tagent_custom_fields tcf ON tcd.id_field = tcf.id_field - LEFT JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE ta.disabled = 0 - AND tcf.name = '%s' + INNER JOIN ( + SELECT ta.id_agente, + ta.total_count AS c_m_total, + SUM( IF(tae.estado = 0, 1, 0) ) AS mm_normal, + SUM( IF(tae.estado = 1, 1, 0) ) AS mm_critical, + SUM( IF(tae.estado = 2, 1, 0) ) AS mm_warning, + SUM( IF(tae.estado = 3, 1, 0) ) AS mm_unknown, + SUM( IF(tae.estado = 4 OR tae.estado = 5, 1, 0) ) AS mm_not_init, + COUNT(tam.id_agente_modulo) AS mm_total + FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tam.id_agente = tae.id_agente + AND tam.id_agente_modulo = tae.id_agente_modulo + WHERE ta.disabled = 0 + AND tam.disabled = 0 + %s + %s + %s + %s + GROUP by ta.id_agente + %s + ) AS tagent_counters + ON tcd.id_agent = tagent_counters.id_agente + INNER JOIN tagente ta + ON ta.id_agente = tagent_counters.id_agente + WHERE tcf.name = '%s' AND tcd.description <> '' %s - %s - %s - %s GROUP BY tcd.description", - $custom_field_name, - $custom_data_and, $groups_and, $and_status, - $module_filter + $and_module_search, + $and_module_status, + $empty_agents_count, + $custom_field_name, + $custom_data_and ); $result_meta[$server_data['id']] = db_get_all_rows_sql($query); @@ -406,6 +455,11 @@ function agent_counters_custom_fields($filters){ FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tam.id_agente = tae.id_agente + AND tam.id_agente_modulo = tae.id_agente_modulo INNER JOIN tagent_custom_data tcd ON tcd.id_agent = ta.id_agente INNER JOIN tagent_custom_fields tcf @@ -413,22 +467,28 @@ function agent_counters_custom_fields($filters){ WHERE ta.disabled = 0 AND tcf.name = '%s' AND tcd.description <> '' + AND tam.disabled = 0 %s %s %s %s + %s + GROUP BY ta.id_agente ", $server_data['id'], $custom_field_name, $custom_data_and, $groups_and, $and_status, - $module_filter + $and_module_search, + $and_module_status ); $node_result = db_get_all_rows_sql($query_data); + if (empty($node_result)) $node_result = array(); + $data = array_merge($data, $node_result); // Restore connection to root node metaconsole_restore_db(); @@ -455,7 +515,6 @@ function agent_counters_custom_fields($filters){ 't_a_not_init' => 0, 't_a_agents' => 0 ); - foreach ($result_meta as $k => $nodo) { if(isset($nodo) && is_array($nodo)){ foreach ($nodo as $key => $value) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 613574ee27..8b25a5b467 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -10361,7 +10361,7 @@ function reporting_label_macro ($item, $label) { case 'MTTR': case 'automatic_graph': if (preg_match("/_agent_/", $label)) { - if (count($item['agents']) > 1) { + if (isset($item['agents']) && count($item['agents']) > 1) { $agent_name = count($item['agents']) . __(' agents'); } else { diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index be948e9415..c986eb0510 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -3060,7 +3060,8 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$) { 'custom_id' => $custom_id, 'url_address' => $url_address, 'timezone_offset' => $timezone_offset, - 'alias' => $alias + 'alias' => $alias, + 'update_module_count' => 1, # Force to replicate in metaconsole }); my $agent_id = db_insert ($dbh, 'id_agente', "INSERT INTO tagente $columns", @{$values}); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index cec179c499..22096c292a 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -35,6 +35,8 @@ use threads; # Used to calculate the MD5 checksum of a string use constant MOD232 => 2**32; +# 2 to the power of 32. +use constant POW232 => 2**32; # UTF-8 flags deletion from multibyte characters when files are opened. use open OUT => ":utf8"; @@ -122,6 +124,7 @@ our @EXPORT = qw( check_server_threads start_server_thread stop_server_threads + generate_agent_name_hash ); # ID of the different servers @@ -1813,6 +1816,146 @@ sub stop_server_threads { @ServerThreads = (); } +################################################################################ +# Generate random hash as agent name. +################################################################################ +sub generate_agent_name_hash { + my ($agent_alias, $server_ip) = @_; + return sha256(join('|', ($agent_alias, $server_ip, time(), sprintf("%04d", rand(10000))))); +} + +############################################################################### +# Return the SHA256 checksum of the given string as a hex string. +# Pseudocode from: http://en.wikipedia.org/wiki/SHA-2#Pseudocode +############################################################################### +my @K2 = ( + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, + 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, + 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, + 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, + 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +); +sub sha256 { + my $str = shift; + + # No input! + if (!defined($str)) { + return ""; + } + + # Note: All variables are unsigned 32 bits and wrap modulo 2^32 when + # calculating. + + # First 32 bits of the fractional parts of the square roots of the first 8 + # primes. + my $h0 = 0x6a09e667; + my $h1 = 0xbb67ae85; + my $h2 = 0x3c6ef372; + my $h3 = 0xa54ff53a; + my $h4 = 0x510e527f; + my $h5 = 0x9b05688c; + my $h6 = 0x1f83d9ab; + my $h7 = 0x5be0cd19; + + # Pre-processing. + my $msg = unpack ("B*", pack ("A*", $str)); + my $bit_len = length ($msg); + + # Append "1" bit to message. + $msg .= '1'; + + # Append "0" bits until message length in bits = 448 (mod 512). + $msg .= '0' while ((length ($msg) % 512) != 448); + + # Append bit /* bit, not byte */ length of unpadded message as 64-bit + # big-endian integer to message. + $msg .= unpack ("B32", pack ("N", $bit_len >> 32)); + $msg .= unpack ("B32", pack ("N", $bit_len)); + + # Process the message in successive 512-bit chunks. + for (my $i = 0; $i < length ($msg); $i += 512) { + + my @w; + my $chunk = substr ($msg, $i, 512); + + # Break chunk into sixteen 32-bit big-endian words. + for (my $j = 0; $j < length ($chunk); $j += 32) { + push (@w, unpack ("N", pack ("B32", substr ($chunk, $j, 32)))); + } + + # Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array: + for (my $i = 16; $i < 64; $i++) { + my $s0 = rightrotate($w[$i - 15], 7) ^ rightrotate($w[$i - 15], 18) ^ ($w[$i - 15] >> 3); + my $s1 = rightrotate($w[$i - 2], 17) ^ rightrotate($w[$i - 2], 19) ^ ($w[$i - 2] >> 10); + $w[$i] = ($w[$i - 16] + $s0 + $w[$i - 7] + $s1) % POW232; + } + + # Initialize working variables to current hash value. + my $a = $h0; + my $b = $h1; + my $c = $h2; + my $d = $h3; + my $e = $h4; + my $f = $h5; + my $g = $h6; + my $h = $h7; + + # Compression function main loop. + for (my $i = 0; $i < 64; $i++) { + my $S1 = rightrotate($e, 6) ^ rightrotate($e, 11) ^ rightrotate($e, 25); + my $ch = ($e & $f) ^ ((0xFFFFFFFF & (~ $e)) & $g); + my $temp1 = ($h + $S1 + $ch + $K2[$i] + $w[$i]) % POW232; + my $S0 = rightrotate($a, 2) ^ rightrotate($a, 13) ^ rightrotate($a, 22); + my $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c); + my $temp2 = ($S0 + $maj) % POW232; + + $h = $g; + $g = $f; + $f = $e; + $e = ($d + $temp1) % POW232; + $d = $c; + $c = $b; + $b = $a; + $a = ($temp1 + $temp2) % POW232; + } + + # Add the compressed chunk to the current hash value. + $h0 = ($h0 + $a) % POW232; + $h1 = ($h1 + $b) % POW232; + $h2 = ($h2 + $c) % POW232; + $h3 = ($h3 + $d) % POW232; + $h4 = ($h4 + $e) % POW232; + $h5 = ($h5 + $f) % POW232; + $h6 = ($h6 + $g) % POW232; + $h7 = ($h7 + $h) % POW232; + } + + # Produce the final hash value (big-endian). + return unpack ("H*", pack ("N", $h0)) . + unpack ("H*", pack ("N", $h1)) . + unpack ("H*", pack ("N", $h2)) . + unpack ("H*", pack ("N", $h3)) . + unpack ("H*", pack ("N", $h4)) . + unpack ("H*", pack ("N", $h5)) . + unpack ("H*", pack ("N", $h6)) . + unpack ("H*", pack ("N", $h7)); +} + +############################################################################### +# Rotate a 32-bit number a number of bits to the right. +############################################################################### +sub rightrotate { + my ($x, $c) = @_; + + return (0xFFFFFFFF & ($x << (32 - $c))) | ($x >> $c); +} + # End of function declaration # End of defined Code diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index d614a4ea67..9223260223 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -103,7 +103,7 @@ sub help_screen{ print "Available options by category:\n\n" unless $param ne ''; print "Available options for $param:\n\n" unless $param eq ''; print "AGENTS:\n\n" unless $param ne ''; - help_screen_line('--create_agent', " \n\t [
]", 'Create agent'); + help_screen_line('--create_agent', " \n\t [
]", 'Create agent'); help_screen_line('--update_agent', ' ', "Update an agent field. The fields can be \n\t the following: agent_name, address, description, group_name, interval, os_name, disabled (0-1), \n\t parent_name, cascade_protection (0-1), icon_path, update_gis_data (0-1), custom_id"); help_screen_line('--delete_agent', '', 'Delete agent'); help_screen_line('--disable_group', '', 'Disable agents from an entire group'); @@ -996,21 +996,29 @@ sub cli_enable_group() { ############################################################################## sub cli_create_agent() { - my ($agent_name,$os_name,$group_name,$server_name,$address,$description,$interval) = @ARGV[2..8]; + my ($agent_name,$os_name,$group_name,$server_name,$address,$description,$interval, $alias_as_name) = @ARGV[2..9]; print_log "[INFO] Creating agent '$agent_name'\n\n"; $address = '' unless defined ($address); $description = (defined ($description) ? safe_input($description) : '' ); # safe_input() might be better at pandora_create_agent() (when passing 'description' to db_insert()) $interval = 300 unless defined ($interval); - + $alias_as_name = 1 unless defined ($alias_as_name); + my $agent_alias = undef; + + if (!$alias_as_name) { + $agent_alias = $agent_name; + $agent_name = generate_agent_name_hash($agent_alias, $conf{'dbhost'}); + } + my $id_group = get_group_id($dbh,$group_name); exist_check($id_group,'group',$group_name); my $os_id = get_os_id($dbh,$os_name); exist_check($id_group,'operating system',$group_name); my $agent_exists = get_agent_id($dbh,$agent_name); non_exist_check($agent_exists, 'agent name', $agent_name); - pandora_create_agent ($conf, $server_name, $agent_name, $address, $id_group, 0, $os_id, $description, $interval, $dbh); + pandora_create_agent ($conf, $server_name, $agent_name, $address, $id_group, 0, $os_id, $description, $interval, $dbh, + undef, undef, undef, undef, undef, undef, undef, undef, $agent_alias); } ############################################################################## @@ -5697,7 +5705,7 @@ sub pandora_manage_main ($$$) { cli_enable_group(); } elsif ($param eq '--create_agent') { - param_check($ltotal, 7, 3); + param_check($ltotal, 8, 4); cli_create_agent(); } elsif ($param eq '--delete_agent') {