From 162fb44dd7140925449b0fedb1ce126499accf0d Mon Sep 17 00:00:00 2001 From: "ismael.moreno" Date: Tue, 10 Sep 2019 14:26:50 +0200 Subject: [PATCH 001/200] SFTP support and custom port added --- pandora_plugins/FTP/ftp_plugin/ftp.conf | 22 ++++++---- pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl | 43 ++++++++++++++++---- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/pandora_plugins/FTP/ftp_plugin/ftp.conf b/pandora_plugins/FTP/ftp_plugin/ftp.conf index ff418cdcfb..2d0099b3be 100644 --- a/pandora_plugins/FTP/ftp_plugin/ftp.conf +++ b/pandora_plugins/FTP/ftp_plugin/ftp.conf @@ -5,25 +5,31 @@ #====================================================================== # User and password for FTP connection -conf_ftp_user mario +conf_ftp_user root # Use "" if your password is in blank -conf_ftp_pass pulido +conf_ftp_pass Password + +#Port for FTP/SFTP connection +#conf_ftp_port 22 + +#Set this parameter to 1 if you want stablish an SFTP connection +conf_ftp_sftp 1 # Configure complete name of ftp file --> upload (Local) -conf_ftp_putfile /home/mariopc/Descargas/ejemplo.zip +conf_ftp_putfile /tmp/test_upload.zip # Configure name of ftp file --> upload (FTP server) -conf_ftp_putname prueba.zip +conf_ftp_putname /tmp/test.zip # Configure Ip for FTP Connection conf_ftp_host localhost # Configure name of ftp file --> download (FTP server) -conf_ftp_getfile prueba.zip +conf_ftp_getfile /tmp/test.zip # Configure complete name os ftp file --> download (Local) -conf_ftp_getname prueba.zip +conf_ftp_getname /tmp/test.zip # Configure Operating System (Unix or Windows) conf_operating_system Unix @@ -34,10 +40,10 @@ conf_operating_system Unix conf_ftp_compare write -conf_ftp_compare_file prueba.zip +conf_ftp_compare_file /tmp/prueba.zip -conf_local_comp_file prueba.zip +conf_local_comp_file /tmp/prueba.zip conf_local_downcomp_file /tmp/prueba.zip diff --git a/pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl b/pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl index 0aa463e597..e464c42057 100644 --- a/pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl +++ b/pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl @@ -8,6 +8,7 @@ use strict; use warnings; use Data::Dumper; use Net::FTP; +use Net::SFTP::Foreign; use Time::HiRes qw ( gettimeofday ); my $archivo_cfg = $ARGV[0]; @@ -115,6 +116,14 @@ sub load_external_setup ($) if ($parametro =~ m/^conf\_ftp\_host\s(.*)/i) { $plugin_setup{"conf_ftp_host"} = $1; } + + if ($parametro =~ m/^conf\_ftp\_port\s(.*)/i) { + $plugin_setup{"conf_ftp_port"} = $1; + } + + if ($parametro =~ m/^conf\_ftp\_sftp\s(.*)/i) { + $plugin_setup{"conf_ftp_sftp"} = $1; + } if ($parametro =~ m/^conf\_ftp\_putfile\s(.*)/i) { $plugin_setup{"conf_ftp_putfile"} = $1; @@ -184,20 +193,38 @@ load_external_setup ($archivo_cfg); #------------------------------------------------------------------------- # Start session in FTP server #-------------------------------------------------------------------------- - -my $ftp = Net::FTP->new($plugin_setup{"conf_ftp_host"}) or die("Unable to connect to server: $!");#Connect FTP server -$ftp->login($plugin_setup{"conf_ftp_user"},$plugin_setup{"conf_ftp_pass"}) or die("Failed Login: $!");# Login at FTP server +my $ftp; +if (($plugin_setup{"conf_ftp_sftp"}) && ( $plugin_setup{"conf_ftp_sftp"} == 1)){ + if ($plugin_setup{"conf_ftp_port"}){ + #port => $plugin_setup{"port"}, + $ftp = Net::SFTP::Foreign->new(host => $plugin_setup{"conf_ftp_host"}, port => $plugin_setup{"conf_ftp_port"}, stderr_discard => 1, user => $plugin_setup{"conf_ftp_user"} , password => $plugin_setup{"conf_ftp_pass"},expect_log_user => 'false'); + if($ftp->error){ + die($ftp->error); + } + }else{ + $ftp = Net::SFTP::Foreign->new(host => $plugin_setup{"conf_ftp_host"}, stderr_discard => 1, user => $plugin_setup{"conf_ftp_user"} , password => $plugin_setup{"conf_ftp_pass"},expect_log_user => 'false'); + if($ftp->error){ + die($ftp->error); + } + } +} else { + if ($plugin_setup{"conf_ftp_port"}){ + $ftp = Net::FTP->new(host => $plugin_setup{"conf_ftp_host"},port => $plugin_setup{"conf_ftp_port"}) or die("Unable to connect to server: $!");#Connect FTP server + }else{ + $ftp = Net::FTP->new($plugin_setup{"conf_ftp_host"}) or die("Unable to connect to server: $!");#Connect FTP server + } + $ftp->login($plugin_setup{"conf_ftp_user"},$plugin_setup{"conf_ftp_pass"}) or die("Failed Login: $!");# Login at FTP server #print_module ( "Disp_FTP_$plugin_setup{conf_ftp_host}" , "generic_proc", 1, " Determines whether FTP login to $plugin_setup{conf_ftp_host} has been successful or not" ); +} #------------------------------------------------------------------------- # Returns the module that shows the time and transfer rate.(Upload a file) #-------------------------------------------------------------------------- my $clock0 = gettimeofday(); - $ftp->put($plugin_setup{"conf_ftp_putfile"},$plugin_setup{"conf_ftp_putname"});# Upload file at FTP server + $ftp->put($plugin_setup{"conf_ftp_putfile"},$plugin_setup{"conf_ftp_putname"}) or die("Cannot upload file to server");# Upload file at FTP server my $clock1 = gettimeofday(); my $clockd = $clock1 - $clock0;# Calculate upload transfer time - $ftp->size($plugin_setup{"conf_ftp_putname"});# File size - my $putrate = $ftp->size($plugin_setup{"conf_ftp_putname"})/$clockd;# Calculate rate transfer + my $putrate = $ftp->stat($plugin_setup{"conf_ftp_putname"})->size/$clockd;# Calculate rate transfer my $time_puftp=sprintf("%.2f",$clockd); my $rate_puftp=sprintf("%.2f",$putrate); @@ -212,8 +239,8 @@ $ftp->login($plugin_setup{"conf_ftp_user"},$plugin_setup{"conf_ftp_pass"}) or di $ftp->get($plugin_setup{"conf_ftp_getfile"},$plugin_setup{"conf_ftp_getname"}); my $clock3 = gettimeofday(); my $clockg = $clock3 - $clock2; - $ftp->size($plugin_setup{"conf_ftp_getname"}); - my $getrate = $ftp->size($plugin_setup{"conf_ftp_getname"})/$clockg; + #$ftp->stat($plugin_setup{"conf_ftp_getname"})->size; + my $getrate = $ftp->stat($plugin_setup{"conf_ftp_getname"})->size/$clockg; my $time_getftp=sprintf("%.2f",$clockg); my $rate_getftp=sprintf("%.2f",$getrate); From f03364bf96e7d2a00fa88c64066f010296950140 Mon Sep 17 00:00:00 2001 From: marcos Date: Thu, 6 May 2021 17:08:11 +0200 Subject: [PATCH 002/200] add not option in monitor detail filter --- .../operation/agentes/status_monitor.php | 2130 +++++++++-------- 1 file changed, 1086 insertions(+), 1044 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index ee20c2d8c1..579fcd81bb 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -11,7 +11,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Load global vars +// Load global vars. global $config; check_login(); @@ -115,9 +115,18 @@ $sort = get_parameter('sort', 'none'); $id_module = (int) get_parameter('id_module', 0); $ag_custom_fields = (array) get_parameter('ag_custom_fields', []); $module_option = (int) get_parameter('module_option', 1); + +$not_condition = (string) get_parameter('not_condition', ''); + +// If option not_condition is enabled, the conditions of the queries are reversed. +$condition_query = '='; +if ($not_condition !== '') { + $condition_query = '!='; +} + $autosearch = false; -// It is validated if it receives parameters different from those it has by default +// It is validated if it receives parameters different from those it has by default. if ($ag_freestring !== '' || $moduletype !== '' || $datatype !== '' || $ag_modulename !== '' || $refr !== 0 || $offset !== 0 || $status !== 4 || $modulegroup !== -1 || $tag_filter !== 0 || $sortField !== '' @@ -151,10 +160,10 @@ if ($id_module) { enterprise_hook('open_meta_frame'); -// Get Groups and profiles from user +// Get Groups and profiles from user. $user_groups = implode(',', array_keys(users_get_groups(false, 'AR', false))); -// Begin Build SQL sentences +// Begin Build SQL sentences. $sql_from = ' FROM tagente_modulo INNER JOIN tagente ON tagente_modulo.id_agente = tagente.id_agente @@ -177,7 +186,7 @@ if (is_numeric($ag_group)) { $id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group); } -// Agent group selector +// Agent group selector. if (!is_metaconsole()) { if ($ag_group > 0 && check_acl($config['id_user'], $ag_group, 'AR')) { if ($recursion) { @@ -191,7 +200,7 @@ if (!is_metaconsole()) { ); } else { $sql_conditions_group = sprintf( - ' AND (tagente.id_grupo = %d OR tasg.id_group = %d)', + ' AND (tagente.id_grupo '.$condition_query.' %d OR tasg.id_group '.$condition_query.' %d)', $ag_group, $ag_group ); @@ -230,66 +239,66 @@ if (!is_metaconsole()) { } } -// Module group +// Module group. if (is_metaconsole()) { if ($modulegroup != '-1') { - $sql_conditions .= sprintf(' AND tagente_modulo.id_module_group IN (%s)', $modulegroup); + $sql_conditions .= sprintf(' AND tagente_modulo.id_module_group '.$not_condition.' IN (%s)', $modulegroup); } } else if ($modulegroup > -1) { - $sql_conditions .= sprintf(' AND tagente_modulo.id_module_group = \'%d\'', $modulegroup); + $sql_conditions .= sprintf(' AND tagente_modulo.id_module_group '.$condition_query.' \'%d\'', $modulegroup); } -// Module name selector +// Module name selector. if ($ag_modulename != '') { - $sql_conditions .= " AND tagente_modulo.nombre LIKE '%".$ag_modulename."%'"; + $sql_conditions .= " AND tagente_modulo.nombre $not_condition LIKE '%".$ag_modulename."%'"; } if ($module_option !== 0) { if ($module_option == 1) { - // Only enabled - $sql_conditions .= sprintf(' AND tagente_modulo.disabled = 0'); + // Only enabled. + $sql_conditions .= sprintf(' AND tagente_modulo.disabled '.$condition_query.' 0'); } else if ($module_option == 2) { - // Only disabled - $sql_conditions .= sprintf(' AND tagente_modulo.disabled = 1'); + // Only disabled. + $sql_conditions .= sprintf(' AND tagente_modulo.disabled '.$condition_query.' 1'); } } if ($datatype != '') { - $sql_conditions .= sprintf(' AND ttipo_modulo.id_tipo ='.$datatype); + $sql_conditions .= sprintf(' AND ttipo_modulo.id_tipo '.$condition_query.' '.$datatype); } if ($moduletype != '') { - $sql_conditions .= sprintf(' AND tagente_modulo.id_modulo ='.$moduletype); + $sql_conditions .= sprintf(' AND tagente_modulo.id_modulo '.$condition_query.' '.$moduletype.''); } -// Freestring selector +// Freestring selector. if ($ag_freestring != '') { - $sql_conditions .= ' AND (tagente.nombre COLLATE utf8_general_ci LIKE \'%%'.$ag_freestring.'%%\' - OR tagente.alias COLLATE utf8_general_ci LIKE \'%%'.$ag_freestring.'%%\' - OR tagente_modulo.nombre COLLATE utf8_general_ci LIKE \'%%'.$ag_freestring.'%%\' - OR tagente_modulo.descripcion COLLATE utf8_general_ci LIKE \'%%'.$ag_freestring.'%%\')'; + $sql_conditions .= ' AND (tagente.nombre COLLATE utf8_general_ci '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' + OR tagente.alias COLLATE utf8_general_ci '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' + OR tagente_modulo.nombre COLLATE utf8_general_ci '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' + OR tagente_modulo.descripcion COLLATE utf8_general_ci '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\')'; } -// Status selector +// Status selector. if ($status == AGENT_MODULE_STATUS_NORMAL) { - // Normal - $sql_conditions .= ' AND tagente_estado.estado = 0 + // Normal. + $sql_conditions .= ' AND tagente_estado.estado '.$condition_query.' 0 AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) '; } else if ($status == AGENT_MODULE_STATUS_CRITICAL_BAD) { - // Critical - $sql_conditions .= ' AND tagente_estado.estado = 1 AND utimestamp > 0'; + // Critical. + $sql_conditions .= ' AND tagente_estado.estado '.$condition_query.' 1 AND utimestamp > 0'; } else if ($status == AGENT_MODULE_STATUS_WARNING) { - // Warning - $sql_conditions .= ' AND tagente_estado.estado = 2 AND utimestamp > 0'; + // Warning. + $sql_conditions .= ' AND tagente_estado.estado '.$condition_query.' 2 AND utimestamp > 0'; } else if ($status == AGENT_MODULE_STATUS_NOT_NORMAL) { - // Not normal + // Not normal. $sql_conditions .= ' AND tagente_estado.estado <> 0'; } else if ($status == AGENT_MODULE_STATUS_UNKNOWN) { - // Unknown - $sql_conditions .= ' AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0'; + // Unknown. + $sql_conditions .= ' AND tagente_estado.estado '.$condition_query.' 3 AND tagente_estado.utimestamp <> 0'; } else if ($status == AGENT_MODULE_STATUS_NOT_INIT) { - // Not init - $sql_conditions .= ' AND tagente_estado.utimestamp = 0 + // Not init. + $sql_conditions .= ' AND tagente_estado.utimestamp '.$condition_query.' 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)'; } @@ -300,13 +309,13 @@ if (!empty($min_hours_status)) { $sql_conditions .= sprintf(' AND tagente_estado.last_status_change < %d', $max_time); } -// Filter by agent custom fields +// Filter by agent custom fields. $sql_conditions_custom_fields = ''; if (!empty($ag_custom_fields)) { $cf_filter = []; foreach ($ag_custom_fields as $field_id => $value) { if (!empty($value)) { - $cf_filter[] = '(tagent_custom_data.id_field = '.$field_id.' AND tagent_custom_data.description LIKE \'%'.$value.'%\')'; + $cf_filter[] = '(tagent_custom_data.id_field '.$condition_query.' '.$field_id.' AND tagent_custom_data.description '.$not_condition.' LIKE \'%'.$value.'%\')'; } } @@ -318,24 +327,24 @@ if (!empty($ag_custom_fields)) { } } -// Filter by tag +// Filter by tag. if ($tag_filter !== 0) { if (is_metaconsole()) { - $sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN ( + $sql_conditions .= ' AND tagente_modulo.id_agente_modulo '.$not_condition.' IN ( SELECT ttag_module.id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag IN ('.$tag_filter.'))'; + WHERE ttag_module.id_tag '.$not_condition.' IN ('.$tag_filter.'))'; } else { - $sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN ( + $sql_conditions .= ' AND tagente_modulo.id_agente_modulo '.$not_condition.' IN ( SELECT ttag_module.id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag = '.$tag_filter.')'; + WHERE ttag_module.id_tag '.$condition_query.' '.$tag_filter.')'; } } -// Apply the module ACL with tags +// Apply the module ACL with tags. $sql_conditions_tags = ''; if (!users_is_admin()) { @@ -356,20 +365,20 @@ if (!users_is_admin()) { } } -// Two modes of filter. All the filters and only ACLs filter +// Two modes of filter. All the filters and only ACLs filter. $sql_conditions_all = $sql_conditions.$sql_conditions_group.$sql_conditions_tags.$sql_conditions_custom_fields; -// Get count to paginate +// Get count to paginate. if (!defined('METACONSOLE')) { $count = db_get_sql('SELECT COUNT(DISTINCT tagente_modulo.id_agente_modulo)'.$sql_from.$sql_conditions_all); } -// Get limit_sql depend of the metaconsole or standard mode +// Get limit_sql depend of the metaconsole or standard mode. if (is_metaconsole()) { - // Offset will be used to get the subset of modules + // Offset will be used to get the subset of modules. $inferior_limit = $offset; $superior_limit = ($config['block_size'] + $offset); - // Offset reset to get all elements + // Offset reset to get all elements. $offset = 0; if (!isset($config['meta_num_elements'])) { $config['meta_num_elements'] = 100; @@ -380,9 +389,9 @@ if (is_metaconsole()) { $limit_sql = $config['block_size']; } -// End Build SQL sentences +// End Build SQL sentences. // -// Start Build Search Form +// Start Build Search Form. // $table = new StdClass(); $table->width = '100%'; @@ -436,7 +445,7 @@ $fields[AGENT_MODULE_STATUS_WARNING] = __('Warning'); $fields[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical'); $fields[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown'); $fields[AGENT_MODULE_STATUS_NOT_NORMAL] = __('Not normal'); -// default +// Default. $fields[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); $table->data[0][2] = __('Monitor status'); @@ -528,32 +537,32 @@ $network_available = db_get_sql( FROM tserver WHERE server_type = 1' ); -// POSTGRESQL AND ORACLE COMPATIBLE +// POSTGRESQL AND ORACLE COMPATIBLE. $wmi_available = db_get_sql( 'SELECT count(*) FROM tserver WHERE server_type = 6' ); -// POSTGRESQL AND ORACLE COMPATIBLE +// POSTGRESQL AND ORACLE COMPATIBLE. $plugin_available = db_get_sql( 'SELECT count(*) FROM tserver WHERE server_type = 4' ); -// POSTGRESQL AND ORACLE COMPATIBLE +// POSTGRESQL AND ORACLE COMPATIBLE. $prediction_available = db_get_sql( 'SELECT count(*) FROM tserver WHERE server_type = 5' ); -// POSTGRESQL AND ORACLE COMPATIBLE +// POSTGRESQL AND ORACLE COMPATIBLE. $wux_available = db_get_sql( 'SELECT count(*) FROM tserver WHERE server_type = 17' ); -// POSTGRESQL AND ORACLE COMPATIBLE - // Development mode to use all servers +// POSTGRESQL AND ORACLE COMPATIBLE. +// Development mode to use all servers. if ($develop_bypass) { $network_available = 1; $wmi_available = 1; @@ -606,7 +615,7 @@ $min_hours_val = empty($min_hours_status) ? '' : (int) $min_hours_status; $table->data[2][4] = ''.__('Min. hours in current status').''; $table->data[2][5] = html_print_input_text('min_hours_status', $min_hours_val, '', 12, 20, true); -$table->data[3][0] = 'data[3][0] = 'data[3][0] .= '>'.__('Data type').''; @@ -619,7 +628,7 @@ switch ($moduletype) { $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo - WHERE categoria IN (6,7,8,0,1,2,-1) order by descripcion ' + WHERE categoria '.$not_condition.' IN (6,7,8,0,1,2,-1) order by descripcion ' ); break; @@ -627,7 +636,7 @@ switch ($moduletype) { $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo - WHERE categoria between 3 and 5 ' + WHERE categoria '.$not_condition.' between 3 and 5 ' ); break; @@ -635,7 +644,7 @@ switch ($moduletype) { $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo - WHERE categoria between 0 and 2 ' + WHERE categoria '.$not_condition.' between 0 and 2 ' ); break; @@ -643,7 +652,7 @@ switch ($moduletype) { $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo - WHERE categoria between 0 and 2 ' + WHERE categoria '.$not_condition.' between 0 and 2 ' ); break; @@ -651,7 +660,7 @@ switch ($moduletype) { $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo - WHERE categoria = 9' + WHERE categoria '.$condition_query.' 9' ); break; @@ -659,7 +668,7 @@ switch ($moduletype) { $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo - WHERE categoria = 0' + WHERE categoria '.$condition_query.' 0' ); break; @@ -667,7 +676,7 @@ switch ($moduletype) { $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo - WHERE nombre = \'web_analysis\'' + WHERE nombre '.$condition_query.' \'web_analysis\'' ); break; @@ -677,6 +686,10 @@ switch ($moduletype) { FROM ttipo_modulo' ); break; + + default: + // Nothing. + break; } $a = db_get_all_rows_sql($sql); @@ -704,294 +717,115 @@ foreach ($a as $valor) { $table->data[3][1] .= ''; + $table->data[3][1] .= '
'; + $table->data[3][1] .= html_print_input( + [ + 'type' => 'checkbox', + 'name' => 'not_condition', + 'return' => true, + 'checked' => $check_not_condition, + 'value' => 'NOT', + ] + ); + $table->data[3][1] .= __('Not condition').ui_print_help_tip(__('If this option is enabled, the events that DO NOT comply with this condition will be displayed.'), true); + $table->data[3][1] .= '
'; $table_custom_fields = new stdClass(); $table_custom_fields->class = 'filters'; $table_custom_fields->width = '100%'; -if (is_metaconsole()) { - $table_custom_fields->styleTable = 'margin-left:0px; margin-top:15px;'; - $table_custom_fields->cellpadding = '0'; - $table_custom_fields->cellspacing = '0'; -} + if (is_metaconsole()) { + $table_custom_fields->styleTable = 'margin-left:0px; margin-top:15px;'; + $table_custom_fields->cellpadding = '0'; + $table_custom_fields->cellspacing = '0'; + } $table_custom_fields->style = []; -if (!is_metaconsole()) { - $table_custom_fields->style[0] = 'font-weight: bold; width: 150px;'; -} else { - $table_custom_fields->style[0] = 'font-weight: bold;'; -} + if (!is_metaconsole()) { + $table_custom_fields->style[0] = 'font-weight: bold; width: 150px;'; + } else { + $table_custom_fields->style[0] = 'font-weight: bold;'; + } -$table_custom_fields->colspan = []; -$table_custom_fields->data = []; + $table_custom_fields->colspan = []; + $table_custom_fields->data = []; -$custom_fields = db_get_all_fields_in_table('tagent_custom_fields'); -if ($custom_fields === false) { - $custom_fields = []; -} + $custom_fields = db_get_all_fields_in_table('tagent_custom_fields'); + if ($custom_fields === false) { + $custom_fields = []; + } -foreach ($custom_fields as $custom_field) { - $row = []; - $row[0] = $custom_field['name']; + foreach ($custom_fields as $custom_field) { + $row = []; + $row[0] = $custom_field['name']; - $custom_field_value = ''; - if (!empty($ag_custom_fields)) { - $custom_field_value = $ag_custom_fields[$custom_field['id_field']]; - if (empty($custom_field_value)) { $custom_field_value = ''; + if (!empty($ag_custom_fields)) { + $custom_field_value = $ag_custom_fields[$custom_field['id_field']]; + if (empty($custom_field_value)) { + $custom_field_value = ''; + } + } + + $row[1] = html_print_input_text('ag_custom_fields['.$custom_field['id_field'].']', $custom_field_value, '', 100, 300, true); + + $table_custom_fields->data[] = $row; } - } - $row[1] = html_print_input_text('ag_custom_fields['.$custom_field['id_field'].']', $custom_field_value, '', 100, 300, true); - - $table_custom_fields->data[] = $row; -} - -$filters = '
'; -if (is_metaconsole()) { - $table->colspan[4][0] = 7; - $table->cellstyle[4][0] = 'padding: 10px;'; - $table->data[4][0] = ui_toggle( - html_print_table($table_custom_fields, true), - __('Advanced Options'), - '', - '', - true, - true - ); - - $filters .= html_print_table($table, true); - $filters .= '
'; - ui_toggle($filters, __('Show filters'), '', '', false); -} else { - $table->colspan[4][0] = 7; - $table->cellstyle[4][0] = 'padding-left: 10px;'; - $table->data[4][0] = ui_toggle( - html_print_table( - $table_custom_fields, - true - ), - __('Agent custom fields'), - '', - '', - true, - true, - '', - 'white-box-content', - 'white_table_graph' - ); - - $filters .= html_print_table($table, true); - $filters .= ''; - echo $filters; -} - -unset($table); -// End Build Search Form -// -// Sort functionality -$selected = true; -$selectAgentNameUp = false; -$selectAgentNameDown = false; -$selectDataTypeUp = false; -$selectDataTypeDown = false; -$selectTypeUp = false; -$selectTypeDown = false; -$selectModuleNameUp = false; -$selectModuleNameDown = false; -$selectIntervalUp = false; -$selectIntervalDown = false; -$selectStatusUp = false; -$selectStatusDown = false; -$selectDataUp = false; -$selectDataDown = false; -$selectTimestampUp = false; -$selectTimestampDown = false; -$order = null; - -switch ($sortField) { - case 'agent_alias': - switch ($sort) { - case 'up': - $selectAgentNameUp = $selected; - $order = [ - 'field' => 'tagente.alias', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectAgentNameDown = $selected; - $order = [ - 'field' => 'tagente.alias', - 'order' => 'DESC', - ]; - break; + if ($not_condition !== '') { + $check_not_condition = true; } - break; - case 'type': - switch ($sort) { - case 'up': - $selectDataTypeUp = $selected; - $order = [ - 'field' => 'tagente_modulo.id_tipo_modulo', - 'order' => 'ASC', - ]; - break; - case 'down': - $selectDataTypeDown = $selected; - $order = [ - 'field' => 'tagente_modulo.id_tipo_modulo', - 'order' => 'DESC', - ]; - break; + + + $filters = '
'; + + + if (is_metaconsole()) { + $table->colspan[4][0] = 7; + $table->cellstyle[4][0] = 'padding: 10px;'; + $table->data[4][0] = ui_toggle( + html_print_table($table_custom_fields, true), + __('Advanced Options'), + '', + '', + true, + true + ); + + $filters .= html_print_table($table, true); + $filters .= '
'; + ui_toggle($filters, __('Show filters'), '', '', false); + } else { + $table->colspan[4][0] = 7; + $table->cellstyle[4][0] = 'padding-left: 10px;'; + $table->data[4][0] = ui_toggle( + html_print_table( + $table_custom_fields, + true + ), + __('Agent custom fields'), + '', + '', + true, + true, + '', + 'white-box-content', + 'white_table_graph' + ); + + $filters .= html_print_table($table, true); + $filters .= ''; + echo $filters; } - break; - case 'moduletype': - switch ($sort) { - case 'up': - $selectTypeUp = $selected; - $order = [ - 'field' => 'tagente_modulo.id_modulo', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectTypeDown = $selected; - $order = [ - 'field' => 'tagente_modulo.id_modulo', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'module_name': - switch ($sort) { - case 'up': - $selectModuleNameUp = $selected; - $order = [ - 'field' => 'tagente_modulo.nombre', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectModuleNameDown = $selected; - $order = [ - 'field' => 'tagente_modulo.nombre', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'interval': - switch ($sort) { - case 'up': - $selectIntervalUp = $selected; - $order = [ - 'field' => 'tagente_modulo.module_interval', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectIntervalDown = $selected; - $order = [ - 'field' => 'tagente_modulo.module_interval', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'status': - switch ($sort) { - case 'up': - $selectStatusUp = $selected; - $order = [ - 'field' => 'tagente_estado.estado', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectStatusDown = $selected; - $order = [ - 'field' => 'tagente_estado.estado', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'last_status_change': - switch ($sort) { - case 'up': - $selectStatusUp = $selected; - $order = [ - 'field' => 'tagente_estado.last_status_change', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectStatusDown = $selected; - $order = [ - 'field' => 'tagente_estado.last_status_change', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'timestamp': - switch ($sort) { - case 'up': - $selectTimestampUp = $selected; - $order = [ - 'field' => 'tagente_estado.utimestamp', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectTimestampDown = $selected; - $order = [ - 'field' => 'tagente_estado.utimestamp', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'data': - switch ($sort) { - case 'up': - $selectDataUp = $selected; - $order = [ - 'field' => 'tagente_estado.datos', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectDataDown = $selected; - $order = [ - 'field' => 'tagente_estado.datos', - 'order' => 'DESC', - ]; - break; - } - break; - - default: - $selectAgentNameUp = $selected; + unset($table); + // End Build Search Form. + // + // Sort functionality. + $selected = true; + $selectAgentNameUp = false; $selectAgentNameDown = false; $selectDataTypeUp = false; $selectDataTypeDown = false; @@ -1007,14 +841,214 @@ switch ($sortField) { $selectDataDown = false; $selectTimestampUp = false; $selectTimestampDown = false; - $order = [ - 'field' => 'tagente.alias', - 'order' => 'ASC', - ]; - break; -} + $order = null; -$sql = 'SELECT + switch ($sortField) { + case 'agent_alias': + switch ($sort) { + case 'up': + $selectAgentNameUp = $selected; + $order = [ + 'field' => 'tagente.alias', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectAgentNameDown = $selected; + $order = [ + 'field' => 'tagente.alias', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'type': + switch ($sort) { + case 'up': + $selectDataTypeUp = $selected; + $order = [ + 'field' => 'tagente_modulo.id_tipo_modulo', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectDataTypeDown = $selected; + $order = [ + 'field' => 'tagente_modulo.id_tipo_modulo', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'moduletype': + switch ($sort) { + case 'up': + $selectTypeUp = $selected; + $order = [ + 'field' => 'tagente_modulo.id_modulo', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectTypeDown = $selected; + $order = [ + 'field' => 'tagente_modulo.id_modulo', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'module_name': + switch ($sort) { + case 'up': + $selectModuleNameUp = $selected; + $order = [ + 'field' => 'tagente_modulo.nombre', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectModuleNameDown = $selected; + $order = [ + 'field' => 'tagente_modulo.nombre', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'interval': + switch ($sort) { + case 'up': + $selectIntervalUp = $selected; + $order = [ + 'field' => 'tagente_modulo.module_interval', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectIntervalDown = $selected; + $order = [ + 'field' => 'tagente_modulo.module_interval', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'status': + switch ($sort) { + case 'up': + $selectStatusUp = $selected; + $order = [ + 'field' => 'tagente_estado.estado', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectStatusDown = $selected; + $order = [ + 'field' => 'tagente_estado.estado', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'last_status_change': + switch ($sort) { + case 'up': + $selectStatusUp = $selected; + $order = [ + 'field' => 'tagente_estado.last_status_change', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectStatusDown = $selected; + $order = [ + 'field' => 'tagente_estado.last_status_change', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'timestamp': + switch ($sort) { + case 'up': + $selectTimestampUp = $selected; + $order = [ + 'field' => 'tagente_estado.utimestamp', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectTimestampDown = $selected; + $order = [ + 'field' => 'tagente_estado.utimestamp', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'data': + switch ($sort) { + case 'up': + $selectDataUp = $selected; + $order = [ + 'field' => 'tagente_estado.datos', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectDataDown = $selected; + $order = [ + 'field' => 'tagente_estado.datos', + 'order' => 'DESC', + ]; + break; + } + break; + + default: + $selectAgentNameUp = $selected; + $selectAgentNameDown = false; + $selectDataTypeUp = false; + $selectDataTypeDown = false; + $selectTypeUp = false; + $selectTypeDown = false; + $selectModuleNameUp = false; + $selectModuleNameDown = false; + $selectIntervalUp = false; + $selectIntervalDown = false; + $selectStatusUp = false; + $selectStatusDown = false; + $selectDataUp = false; + $selectDataDown = false; + $selectTimestampUp = false; + $selectTimestampDown = false; + $order = [ + 'field' => 'tagente.alias', + 'order' => 'ASC', + ]; + break; + } + + $sql = 'SELECT (SELECT GROUP_CONCAT(ttag.name SEPARATOR \',\') FROM ttag WHERE ttag.id_tag IN ( @@ -1060,623 +1094,648 @@ $sql = 'SELECT LIMIT '.$offset.','.$limit_sql; -// We do not show the modules until the user searches with the filter -if ($autosearch) { - if (! defined('METACONSOLE')) { - $result = db_get_all_rows_sql($sql); + // We do not show the modules until the user searches with the filter. + if ($autosearch) { + if (! defined('METACONSOLE')) { + $result = db_get_all_rows_sql($sql); - if ($result === false) { - $result = []; - } else { - ui_pagination($count, false, $offset, 0, false, 'offset', true); - } - } else { - // For each server defined and not disabled: - $servers = db_get_all_rows_sql( - 'SELECT * + if ($result === false) { + $result = []; + } else { + ui_pagination($count, false, $offset, 0, false, 'offset', true); + } + } else { + // For each server defined and not disabled. + $servers = db_get_all_rows_sql( + 'SELECT * FROM tmetaconsole_setup WHERE disabled = 0' - ); - if ($servers === false) { - $servers = []; - } - - $result = []; - $count_modules = 0; - foreach ($servers as $server) { - // If connection was good then retrieve all data server - if (metaconsole_connect($server) == NOERR) { - $connection = true; - } else { - $connection = false; - } - - $result_server = db_get_all_rows_sql($sql); - - if (!empty($result_server)) { - // Create HASH login info - $pwd = $server['auth_token']; - $auth_serialized = json_decode($pwd, true); - - if (is_array($auth_serialized)) { - $pwd = $auth_serialized['auth_token']; - $api_password = $auth_serialized['api_password']; - $console_user = $auth_serialized['console_user']; - $console_password = $auth_serialized['console_password']; + ); + if ($servers === false) { + $servers = []; } - $user = $config['id_user']; - $user_rot13 = str_rot13($config['id_user']); - $hashdata = $user.$pwd; - $hashdata = md5($hashdata); - $url_hash = '&'.'loginhash=auto&'.'loginhash_data='.$hashdata.'&'.'loginhash_user='.$user_rot13; - - foreach ($result_server as $result_element_key => $result_element_value) { - $result_server[$result_element_key]['server_id'] = $server['id']; - $result_server[$result_element_key]['server_name'] = $server['server_name']; - $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; - $result_server[$result_element_key]['hashdata'] = $hashdata; - $result_server[$result_element_key]['user'] = $config['id_user']; - $result_server[$result_element_key]['groups_in_server'] = agents_get_all_groups_agent( - $result_element_value['id_agent'], - $result_element_value['id_group'] - ); - - $count_modules++; - } - - $result = array_merge($result, $result_server); - } - - metaconsole_restore_db(); - } - - if ($count_modules > $config['block_size']) { - ui_pagination($count_modules, false, $offset); - } - - // Get number of elements of the pagination - $result = ui_meta_get_subset_array($result, $inferior_limit, $superior_limit); - } -} - -if (($config['dbtype'] == 'oracle') && ($result !== false)) { - for ($i = 0; $i < count($result); $i++) { - unset($result[$i]['rnum']); - } -} - - -// Urls to sort the table. -$url_agent_name = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_type = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_module_name = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_server_type = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_interval = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_status = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_status = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_data = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_timestamp_up = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; -$url_timestamp_down = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; - -$url_agent_name .= '&refr='.$refr.'&datatype='.$datatype.'&moduletype='.$moduletype.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_type .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_module_name .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_server_type .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_interval .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_status .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_status .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_data .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_timestamp_up .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; -$url_timestamp_down .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; - -// Holy god... -$url_agent_name .= '&recursion='.$recursion; -$url_type .= '&recursion='.$recursion; -$url_module_name .= '&recursion='.$recursion; -$url_server_type .= '&recursion='.$recursion; -$url_interval .= '&recursion='.$recursion; -$url_status .= '&recursion='.$recursion; -$url_status .= '&recursion='.$recursion; -$url_data .= '&recursion='.$recursion; -$url_timestamp_up .= '&recursion='.$recursion; -$url_timestamp_down .= '&recursion='.$recursion; - - -$url_agent_name .= '&sort_field=agent_alias&sort='; -$url_type .= '&sort_field=type&sort='; -$url_module_name .= '&sort_field=module_name&sort='; -$url_server_type .= '&sort_field=moduletype&sort='; -$url_interval .= '&sort_field=interval&sort='; -$url_status .= '&sort_field=status&sort='; -$url_status .= '&sort_field=last_status_change&sort='; -$url_data .= '&sort_field=data&sort='; -$url_timestamp_up .= '&sort_field=timestamp&sort=up'; -$url_timestamp_down .= '&sort_field=timestamp&sort=down'; - -// Start Build List Result -if (!empty($result)) { - $table = new StdClass(); - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->width = '100%'; - $table->class = 'info_table'; - $table->head = []; - $table->data = []; - $table->size = []; - $table->align = []; - - $show_fields = explode(',', $config['status_monitor_fields']); - - - if (in_array('policy', $show_fields)) { - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - $table->head[0] = ''.__('P.').''; - } - } - - if (in_array('agent', $show_fields) || is_metaconsole()) { - $table->head[1] = __('Agent'); - $table->head[1] .= ui_get_sorting_arrows($url_agent_name.'up', $url_agent_name.'down', $selectAgentNameUp, $selectAgentNameDown); - } - - if (in_array('data_type', $show_fields) || is_metaconsole()) { - $table->head[2] = __('Data Type'); - $table->head[2] .= ui_get_sorting_arrows($url_type.'up', $url_type.'down', $selectDataTypeUp, $selectDataTypeDown); - $table->align[2] = 'left'; - } - - if (in_array('module_name', $show_fields) || is_metaconsole()) { - $table->head[3] = __('Module name'); - $table->head[3] .= ui_get_sorting_arrows($url_module_name.'up', $url_module_name.'down', $selectModuleNameUp, $selectModuleNameDown); - } - - if (in_array('server_type', $show_fields) || is_metaconsole()) { - $table->head[4] = __('Server type'); - $table->head[4] .= ui_get_sorting_arrows($url_server_type.'up', $url_server_type.'down', $selectTypeUp, $selectTypeDown); - } - - if (in_array('interval', $show_fields) || is_metaconsole()) { - $table->head[5] = __('Interval'); - $table->head[5] .= ui_get_sorting_arrows($url_interval.'up', $url_interval.'down', $selectIntervalUp, $selectIntervalDown); - $table->align[5] = 'left'; - } - - if (in_array('status', $show_fields) || is_metaconsole()) { - $table->head[6] = __('Status'); - $table->head[6] .= ui_get_sorting_arrows($url_status.'up', $url_status.'down', $selectStatusUp, $selectStatusDown); - $table->align[6] = 'left'; - } - - if (in_array('last_status_change', $show_fields)) { - $table->head[7] = __('Last status change'); - $table->head[7] .= ui_get_sorting_arrows($url_status.'up', $url_status.'down', $selectStatusUp, $selectStatusDown); - $table->align[7] = 'left'; - } - - if (in_array('graph', $show_fields) || is_metaconsole()) { - $table->head[8] = __('Graph'); - $table->align[8] = 'left'; - } - - if (in_array('warn', $show_fields) || is_metaconsole()) { - $table->head[9] = __('Warn'); - $table->align[9] = 'left'; - } - - if (in_array('data', $show_fields) || is_metaconsole()) { - $table->head[10] = __('Data'); - $table->align[10] = 'left'; - if (is_metaconsole()) { - $table->head[10] .= ui_get_sorting_arrows($url_data.'up', $url_data.'down', $selectDataUp, $selectDataDown); - } - } - - if (in_array('timestamp', $show_fields) || is_metaconsole()) { - $table->head[11] = __('Timestamp'); - $table->head[11] .= ui_get_sorting_arrows($url_timestamp_up, $url_timestamp_down, $selectTimestampUp, $selectTimestampDown); - $table->align[11] = 'left'; - } - - $id_type_web_content_string = db_get_value( - 'id_tipo', - 'ttipo_modulo', - 'nombre', - 'web_content_string' - ); - - foreach ($result as $row) { - // Avoid unset, null and false value - if (empty($row['server_name'])) { - $row['server_name'] = ''; - } - - $is_web_content_string = (bool) db_get_value_filter( - 'id_agente_modulo', - 'tagente_modulo', - [ - 'id_agente_modulo' => $row['id_agente_modulo'], - 'id_tipo_modulo' => $id_type_web_content_string, - ] - ); - - // Fixed the goliat sends the strings from web - // without HTML entities - if ($is_web_content_string) { - $row['datos'] = io_safe_input($row['datos']); - } - - // Fixed the data from Selenium Plugin - if ($row['datos'] != strip_tags($row['datos'])) { - $row['datos'] = io_safe_input($row['datos']); - } - - $data = []; - - if (in_array('policy', $show_fields) || is_metaconsole()) { - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - if (is_metaconsole()) { - $node = metaconsole_get_connection_by_id($row['server_id']); - if (metaconsole_load_external_db($node) !== NOERR) { - // Restore the default connection. - metaconsole_restore_db(); - $errors++; - break; - } - } - - $policyInfo = policies_info_module_policy($row['id_agente_modulo']); - - if ($policyInfo === false) { - $data[0] = ''; - } else { - $linked = policies_is_module_linked($row['id_agente_modulo']); - - $adopt = false; - if (policies_is_module_adopt($row['id_agente_modulo'])) { - $adopt = true; - } - - if ($linked) { - if ($adopt) { - $img = 'images/policies_brick.png'; - $title = __('(Adopt) ').$policyInfo['name_policy']; - } else { - $img = 'images/policies_mc.png'; - $title = $policyInfo['name_policy']; - } + $result = []; + $count_modules = 0; + foreach ($servers as $server) { + // If connection was good then retrieve all data server. + if (metaconsole_connect($server) == NOERR) { + $connection = true; } else { - if ($adopt) { - $img = 'images/policies_not_brick.png'; - $title = __('(Unlinked) (Adopt) ').$policyInfo['name_policy']; - } else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ').$policyInfo['name_policy']; + $connection = false; + } + + $result_server = db_get_all_rows_sql($sql); + + if (!empty($result_server)) { + // Create HASH login info. + $pwd = $server['auth_token']; + $auth_serialized = json_decode($pwd, true); + + if (is_array($auth_serialized)) { + $pwd = $auth_serialized['auth_token']; + $api_password = $auth_serialized['api_password']; + $console_user = $auth_serialized['console_user']; + $console_password = $auth_serialized['console_password']; } + + $user = $config['id_user']; + $user_rot13 = str_rot13($config['id_user']); + $hashdata = $user.$pwd; + $hashdata = md5($hashdata); + $url_hash = '&'.'loginhash=auto&'.'loginhash_data='.$hashdata.'&'.'loginhash_user='.$user_rot13; + + foreach ($result_server as $result_element_key => $result_element_value) { + $result_server[$result_element_key]['server_id'] = $server['id']; + $result_server[$result_element_key]['server_name'] = $server['server_name']; + $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; + $result_server[$result_element_key]['hashdata'] = $hashdata; + $result_server[$result_element_key]['user'] = $config['id_user']; + $result_server[$result_element_key]['groups_in_server'] = agents_get_all_groups_agent( + $result_element_value['id_agent'], + $result_element_value['id_group'] + ); + + $count_modules++; + } + + $result = array_merge($result, $result_server); } - if (is_metaconsole()) { - $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; - } else { - $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; - } - } - - if (is_metaconsole()) { metaconsole_restore_db(); } + + if ($count_modules > $config['block_size']) { + ui_pagination($count_modules, false, $offset); + } + + // Get number of elements of the pagination. + $result = ui_meta_get_subset_array($result, $inferior_limit, $superior_limit); } } - if (in_array('agent', $show_fields) || is_metaconsole()) { - $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; - - // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view - if (defined('METACONSOLE')) { - $agent_link = ''; - $agent_alias = ui_print_truncate_text( - $agent_alias, - 'agent_small', - false, - true, - false, - '[…]', - 'font-size:7.5pt;' - ); - if (can_user_access_node()) { - $data[1] = $agent_link.''.$agent_alias.''; - } else { - $data[1] = $agent_alias; - } - } else { - $data[1] = ''; - $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;'); - $data[1] .= ''; + if (($config['dbtype'] == 'oracle') && ($result !== false)) { + for ($i = 0; $i < count($result); $i++) { + unset($result[$i]['rnum']); } } - if (in_array('data_type', $show_fields) || is_metaconsole()) { - $data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true, ['class' => 'invert_filter']); - $agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); - if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) { - $show_edit_icon = true; - if (defined('METACONSOLE')) { - if (!can_user_access_node()) { - $show_edit_icon = false; - } - $url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']); - } else { - $url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'; - } + // Urls to sort the table. + $url_agent_name = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_type = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_module_name = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_server_type = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_interval = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_status = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_status = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_data = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_timestamp_up = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; + $url_timestamp_down = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; - if ($show_edit_icon) { - $table->cellclass[][2] = 'action_buttons'; - $data[2] .= ''.html_print_image( - 'images/config.png', - true, - [ - 'alt' => '0', - 'border' => '', - 'title' => __('Edit'), - ] - ).''; + $url_agent_name .= '&refr='.$refr.'&datatype='.$datatype.'&moduletype='.$moduletype.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_type .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_module_name .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_server_type .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_interval .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_status .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_status .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_data .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_timestamp_up .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + $url_timestamp_down .= '&datatype='.$datatype.'&moduletype='.$moduletype.'&refr='.$refr.'&modulegroup='.$modulegroup.'&offset='.$offset.'&ag_group='.$ag_group.'&ag_freestring='.$ag_freestring.'&ag_modulename='.$ag_modulename.'&status='.$status.$ag_custom_fields_params; + + // Holy god... + $url_agent_name .= '&recursion='.$recursion; + $url_type .= '&recursion='.$recursion; + $url_module_name .= '&recursion='.$recursion; + $url_server_type .= '&recursion='.$recursion; + $url_interval .= '&recursion='.$recursion; + $url_status .= '&recursion='.$recursion; + $url_status .= '&recursion='.$recursion; + $url_data .= '&recursion='.$recursion; + $url_timestamp_up .= '&recursion='.$recursion; + $url_timestamp_down .= '&recursion='.$recursion; + + + $url_agent_name .= '&sort_field=agent_alias&sort='; + $url_type .= '&sort_field=type&sort='; + $url_module_name .= '&sort_field=module_name&sort='; + $url_server_type .= '&sort_field=moduletype&sort='; + $url_interval .= '&sort_field=interval&sort='; + $url_status .= '&sort_field=status&sort='; + $url_status .= '&sort_field=last_status_change&sort='; + $url_data .= '&sort_field=data&sort='; + $url_timestamp_up .= '&sort_field=timestamp&sort=up'; + $url_timestamp_down .= '&sort_field=timestamp&sort=down'; + + // Start Build List Result. + if (!empty($result)) { + $table = new StdClass(); + $table->cellpadding = 0; + $table->cellspacing = 0; + $table->width = '100%'; + $table->class = 'info_table'; + $table->head = []; + $table->data = []; + $table->size = []; + $table->align = []; + + $show_fields = explode(',', $config['status_monitor_fields']); + + + if (in_array('policy', $show_fields)) { + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { + $table->head[0] = ''.__('P.').''; } } - } - if (in_array('module_name', $show_fields) || is_metaconsole()) { - $data[3] = ui_print_truncate_text($row['module_name'], 'module_small', false, true, true); - if ($row['extended_info'] != '') { - $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); + if (in_array('agent', $show_fields) || is_metaconsole()) { + $table->head[1] = __('Agent'); + $table->head[1] .= ui_get_sorting_arrows($url_agent_name.'up', $url_agent_name.'down', $selectAgentNameUp, $selectAgentNameDown); } - if ($row['tags'] != '') { - $data[3] .= html_print_image( - '/images/tag_red.png', - true, - [ - 'title' => $row['tags'], - 'class' => 'tag_row', - ] - ); - } - } - - if (in_array('server_type', $show_fields) || is_metaconsole()) { - $data[4] = servers_show_type($row['id_modulo']); - } - - - if (in_array('interval', $show_fields) || is_metaconsole()) { - $data[5] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); - } - - if (in_array('status', $show_fields) || is_metaconsole()) { - if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 - || $row['module_type'] > 23) && $row['module_type'] != 100) - ) { - $data[6] = ui_print_status_image( - STATUS_MODULE_NO_DATA, - __('NOT INIT'), - true - ); - } else if ($row['estado'] == 0) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_OK, - __('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_OK, - __('NORMAL').': '.htmlspecialchars($row['datos']), - true - ); - } - } else if ($row['estado'] == 1) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_CRITICAL, - __('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_CRITICAL, - __('CRITICAL').': '.htmlspecialchars($row['datos']), - true - ); - } - } else if ($row['estado'] == 2) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_WARNING, - __('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_WARNING, - __('WARNING').': '.htmlspecialchars($row['datos']), - true - ); - } - } else if ($row['estado'] == 3) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').': '.htmlspecialchars($row['datos']), - true - ); - } - } else if ($row['estado'] == 4) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_NO_DATA, - __('NO DATA').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_NO_DATA, - __('NO DATA').': '.htmlspecialchars($row['datos']), - true - ); - } - } else { - $last_status = modules_get_agentmodule_last_status( - $row['id_agente_modulo'] - ); - switch ($last_status) { - case 0: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.htmlspecialchars($row['datos']), - true - ); - } - break; - - case 1: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.htmlspecialchars($row['datos']), - true - ); - } - break; - - case 2: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.htmlspecialchars($row['datos']), - true - ); - } - break; - } - } - } - - if (in_array('last_status_change', $show_fields) || is_metaconsole()) { - $data[7] = ($row['last_status_change'] > 0) ? human_time_comparation($row['last_status_change']) : __('N/A'); - } - - if (in_array('graph', $show_fields) || is_metaconsole()) { - $data[8] = ''; - - $acl_graphs = false; - - // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions - if (!is_metaconsole()) { - $agent_groups = agents_get_all_groups_agent($row['id_agent'], $row['id_group']); - $acl_graphs = check_acl_one_of_groups($config['id_user'], $agent_groups, 'RR'); - } else { - $acl_graphs = true; + if (in_array('data_type', $show_fields) || is_metaconsole()) { + $table->head[2] = __('Data Type'); + $table->head[2] .= ui_get_sorting_arrows($url_type.'up', $url_type.'down', $selectDataTypeUp, $selectDataTypeDown); + $table->align[2] = 'left'; } - if ($row['history_data'] == 1 && $acl_graphs) { - $graph_type = return_graphtype($row['module_type']); - - $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); - $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); - $win_handle = 'day_'.$handle; - - $graph_params = [ - 'type' => $graph_type, - 'period' => SECONDS_1DAY, - 'id' => $row['id_agente_modulo'], - 'refresh' => SECONDS_10MINUTES, - ]; - - if (is_metaconsole() && isset($row['server_id'])) { - // Set the server id - $graph_params['server'] = $row['server_id']; - } - - $graph_params_str = http_build_query($graph_params); - - $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; - - $data[8] = get_module_realtime_link_graph($row); - - if (!is_snapshot_data($row['datos'])) { - $data[8] .= ''.html_print_image('images/chart.png', true, ['border' => '0', 'alt' => '', 'class' => 'invert_filter']).''; - } - - $data[8] .= ''.html_print_image( - 'images/binary.png', - true, - [ - 'border' => '0', - 'alt' => '', - 'class' => 'invert_filter', - ] - ).''; - - $data[8] .= ''.$row['module_name'].''; + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $table->head[3] = __('Module name'); + $table->head[3] .= ui_get_sorting_arrows($url_module_name.'up', $url_module_name.'down', $selectModuleNameUp, $selectModuleNameDown); } - } - if (in_array('warn', $show_fields) || is_metaconsole()) { - $data[9] = ui_print_module_warn_value( - $row['max_warning'], - $row['min_warning'], - $row['str_warning'], - $row['max_critical'], - $row['min_critical'], - $row['str_critical'], - $row['warning_inverse'], - $row['critical_inverse'] + if (in_array('server_type', $show_fields) || is_metaconsole()) { + $table->head[4] = __('Server type'); + $table->head[4] .= ui_get_sorting_arrows($url_server_type.'up', $url_server_type.'down', $selectTypeUp, $selectTypeDown); + } + + if (in_array('interval', $show_fields) || is_metaconsole()) { + $table->head[5] = __('Interval'); + $table->head[5] .= ui_get_sorting_arrows($url_interval.'up', $url_interval.'down', $selectIntervalUp, $selectIntervalDown); + $table->align[5] = 'left'; + } + + if (in_array('status', $show_fields) || is_metaconsole()) { + $table->head[6] = __('Status'); + $table->head[6] .= ui_get_sorting_arrows($url_status.'up', $url_status.'down', $selectStatusUp, $selectStatusDown); + $table->align[6] = 'left'; + } + + if (in_array('last_status_change', $show_fields)) { + $table->head[7] = __('Last status change'); + $table->head[7] .= ui_get_sorting_arrows($url_status.'up', $url_status.'down', $selectStatusUp, $selectStatusDown); + $table->align[7] = 'left'; + } + + if (in_array('graph', $show_fields) || is_metaconsole()) { + $table->head[8] = __('Graph'); + $table->align[8] = 'left'; + } + + if (in_array('warn', $show_fields) || is_metaconsole()) { + $table->head[9] = __('Warn'); + $table->align[9] = 'left'; + } + + if (in_array('data', $show_fields) || is_metaconsole()) { + $table->head[10] = __('Data'); + $table->align[10] = 'left'; + if (is_metaconsole()) { + $table->head[10] .= ui_get_sorting_arrows($url_data.'up', $url_data.'down', $selectDataUp, $selectDataDown); + } + } + + if (in_array('timestamp', $show_fields) || is_metaconsole()) { + $table->head[11] = __('Timestamp'); + $table->head[11] .= ui_get_sorting_arrows($url_timestamp_up, $url_timestamp_down, $selectTimestampUp, $selectTimestampDown); + $table->align[11] = 'left'; + } + + $id_type_web_content_string = db_get_value( + 'id_tipo', + 'ttipo_modulo', + 'nombre', + 'web_content_string' ); - if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { - if ($config['render_proc']) { - switch ($row['module_type']) { - case 2: - case 6: - case 9: - case 18: - case 21: - case 31: - if ($row['datos'] >= 1) { - $salida = $config['render_proc_ok']; - } else { - $salida = $config['render_proc_fail']; - } - break; + foreach ($result as $row) { + // Avoid unset, null and false value. + if (empty($row['server_name'])) { + $row['server_name'] = ''; + } - default: + $is_web_content_string = (bool) db_get_value_filter( + 'id_agente_modulo', + 'tagente_modulo', + [ + 'id_agente_modulo' => $row['id_agente_modulo'], + 'id_tipo_modulo' => $id_type_web_content_string, + ] + ); + + // Fixed the goliat sends the strings from web. + // Without HTML entities. + if ($is_web_content_string) { + $row['datos'] = io_safe_input($row['datos']); + } + + // Fixed the data from Selenium Plugin. + if ($row['datos'] != strip_tags($row['datos'])) { + $row['datos'] = io_safe_input($row['datos']); + } + + $data = []; + + if (in_array('policy', $show_fields) || is_metaconsole()) { + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { + if (is_metaconsole()) { + $node = metaconsole_get_connection_by_id($row['server_id']); + if (metaconsole_load_external_db($node) !== NOERR) { + // Restore the default connection. + metaconsole_restore_db(); + $errors++; + break; + } + } + + $policyInfo = policies_info_module_policy($row['id_agente_modulo']); + + if ($policyInfo === false) { + $data[0] = ''; + } else { + $linked = policies_is_module_linked($row['id_agente_modulo']); + + $adopt = false; + if (policies_is_module_adopt($row['id_agente_modulo'])) { + $adopt = true; + } + + if ($linked) { + if ($adopt) { + $img = 'images/policies_brick.png'; + $title = __('(Adopt) ').$policyInfo['name_policy']; + } else { + $img = 'images/policies_mc.png'; + $title = $policyInfo['name_policy']; + } + } else { + if ($adopt) { + $img = 'images/policies_not_brick.png'; + $title = __('(Unlinked) (Adopt) ').$policyInfo['name_policy']; + } else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ').$policyInfo['name_policy']; + } + } + + if (is_metaconsole()) { + $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; + } else { + $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; + } + } + + if (is_metaconsole()) { + metaconsole_restore_db(); + } + } + } + + if (in_array('agent', $show_fields) || is_metaconsole()) { + $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; + + // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view + if (defined('METACONSOLE')) { + $agent_link = ''; + $agent_alias = ui_print_truncate_text( + $agent_alias, + 'agent_small', + false, + true, + false, + '[…]', + 'font-size:7.5pt;' + ); + if (can_user_access_node()) { + $data[1] = $agent_link.''.$agent_alias.''; + } else { + $data[1] = $agent_alias; + } + } else { + $data[1] = ''; + $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;'); + $data[1] .= ''; + } + } + + if (in_array('data_type', $show_fields) || is_metaconsole()) { + $data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true, ['class' => 'invert_filter']); + $agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); + if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) { + $show_edit_icon = true; + if (defined('METACONSOLE')) { + if (!can_user_access_node()) { + $show_edit_icon = false; + } + + $url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']); + } else { + $url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'; + } + + if ($show_edit_icon) { + $table->cellclass[][2] = 'action_buttons'; + $data[2] .= ''.html_print_image( + 'images/config.png', + true, + [ + 'alt' => '0', + 'border' => '', + 'title' => __('Edit'), + ] + ).''; + } + } + } + + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $data[3] = ui_print_truncate_text($row['module_name'], 'module_small', false, true, true); + if ($row['extended_info'] != '') { + $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); + } + + if ($row['tags'] != '') { + $data[3] .= html_print_image( + '/images/tag_red.png', + true, + [ + 'title' => $row['tags'], + 'class' => 'tag_row', + ] + ); + } + } + + if (in_array('server_type', $show_fields) || is_metaconsole()) { + $data[4] = servers_show_type($row['id_modulo']); + } + + + if (in_array('interval', $show_fields) || is_metaconsole()) { + $data[5] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); + } + + if (in_array('status', $show_fields) || is_metaconsole()) { + if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 + || $row['module_type'] > 23) && $row['module_type'] != 100) + ) { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NOT INIT'), + true + ); + } else if ($row['estado'] == 0) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_OK, + __('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_OK, + __('NORMAL').': '.htmlspecialchars($row['datos']), + true + ); + } + } else if ($row['estado'] == 1) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_CRITICAL, + __('CRITICAL').': '.remove_right_zeros( + number_format($row['datos'], $config['graph_precision']) + ), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_CRITICAL, + __('CRITICAL').': '.htmlspecialchars($row['datos']), + true + ); + } + } else if ($row['estado'] == 2) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_WARNING, + __('WARNING').': '.remove_right_zeros( + number_format($row['datos'], $config['graph_precision']) + ), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_WARNING, + __('WARNING').': '.htmlspecialchars($row['datos']), + true + ); + } + } else if ($row['estado'] == 3) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').': '.remove_right_zeros( + number_format($row['datos'], $config['graph_precision']) + ), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').': '.htmlspecialchars($row['datos']), + true + ); + } + } else if ($row['estado'] == 4) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NO DATA').': '.remove_right_zeros( + number_format($row['datos'], $config['graph_precision']) + ), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NO DATA').': '.htmlspecialchars($row['datos']), + true + ); + } + } else { + $last_status = modules_get_agentmodule_last_status( + $row['id_agente_modulo'] + ); + switch ($last_status) { + case 0: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.htmlspecialchars($row['datos']), + true + ); + } + break; + + case 1: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.htmlspecialchars($row['datos']), + true + ); + } + break; + + case 2: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.htmlspecialchars($row['datos']), + true + ); + } + break; + } + } + } + + if (in_array('last_status_change', $show_fields) || is_metaconsole()) { + $data[7] = ($row['last_status_change'] > 0) ? human_time_comparation($row['last_status_change']) : __('N/A'); + } + + if (in_array('graph', $show_fields) || is_metaconsole()) { + $data[8] = ''; + + $acl_graphs = false; + + // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions. + if (!is_metaconsole()) { + $agent_groups = agents_get_all_groups_agent($row['id_agent'], $row['id_group']); + $acl_graphs = check_acl_one_of_groups($config['id_user'], $agent_groups, 'RR'); + } else { + $acl_graphs = true; + } + + if ($row['history_data'] == 1 && $acl_graphs) { + $graph_type = return_graphtype($row['module_type']); + + $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); + $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); + $win_handle = 'day_'.$handle; + + $graph_params = [ + 'type' => $graph_type, + 'period' => SECONDS_1DAY, + 'id' => $row['id_agente_modulo'], + 'refresh' => SECONDS_10MINUTES, + ]; + + if (is_metaconsole() && isset($row['server_id'])) { + // Set the server id. + $graph_params['server'] = $row['server_id']; + } + + $graph_params_str = http_build_query($graph_params); + + $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; + + $data[8] = get_module_realtime_link_graph($row); + + if (!is_snapshot_data($row['datos'])) { + $data[8] .= ''.html_print_image('images/chart.png', true, ['border' => '0', 'alt' => '', 'class' => 'invert_filter']).''; + } + + $data[8] .= ''.html_print_image( + 'images/binary.png', + true, + [ + 'border' => '0', + 'alt' => '', + 'class' => 'invert_filter', + ] + ).''; + + $data[8] .= ''.$row['module_name'].''; + } + } + + if (in_array('warn', $show_fields) || is_metaconsole()) { + $data[9] = ui_print_module_warn_value( + $row['max_warning'], + $row['min_warning'], + $row['str_warning'], + $row['max_critical'], + $row['min_critical'], + $row['str_critical'], + $row['warning_inverse'], + $row['critical_inverse'] + ); + + if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { + if ($config['render_proc']) { + switch ($row['module_type']) { + case 2: + case 6: + case 9: + case 18: + case 21: + case 31: + if ($row['datos'] >= 1) { + $salida = $config['render_proc_ok']; + } else { + $salida = $config['render_proc_fail']; + } + break; + + default: + switch ($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { + $salida = human_milliseconds_to_string($row['datos']); + } else { + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + } + break; + + default: + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + } + break; + } + } else { switch ($row['module_type']) { case 15: $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); @@ -1691,152 +1750,135 @@ if (!empty($result)) { $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); break; } - break; - } - } else { - switch ($row['module_type']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - $salida = human_milliseconds_to_string($row['datos']); - } else { - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - } - break; - - default: - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; - } - } - - // Show units ONLY in numeric data types - if (isset($row['unit'])) { - $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); - if ($data_macro) { - $salida = $data_macro; - } else { - $salida .= ' '.''.io_safe_output($row['unit']).''; - if (strlen($salida) > $config['agent_size_text_small']) { - $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); - // clean tag - $text_aux = explode(' $row['id_agente_modulo'], - 'interval' => $row['current_interval'], - 'module_name' => $row['module_name'], - 'id_node' => $row['server_id'], - ] - ); - $salida = ui_get_snapshot_image($link, $is_snapshot).'  '; - } else { - $sub_string = substr(io_safe_output($row['datos']), 0, 12); - if ($module_value == $sub_string) { - if ($module_value == 0 && !$sub_string) { - $salida = 0; - } else { + // Show units ONLY in numeric data types. + if (isset($row['unit'])) { $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); if ($data_macro) { $salida = $data_macro; } else { - $salida = $row['datos']; + $salida .= ' '.''.io_safe_output($row['unit']).''; + if (strlen($salida) > $config['agent_size_text_small']) { + $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); + // Clean tag . + $text_aux = explode(' $row['id_agente_modulo'], + 'interval' => $row['current_interval'], + 'module_name' => $row['module_name'], + 'id_node' => $row['server_id'], + ] + ); + $salida = ui_get_snapshot_image($link, $is_snapshot).'  '; } else { - $salida = ''.'".''.$sub_string.' '."".html_print_image('images/rosette.png', true).''; + } + } } } } + + if (in_array('data', $show_fields) || is_metaconsole()) { + $data[10] = $salida; + } + + if (in_array('timestamp', $show_fields) || is_metaconsole()) { + if ($row['module_interval'] > 0) { + $interval = $row['module_interval']; + } else { + $interval = $row['agent_interval']; + } + + if ($row['estado'] == 3) { + $option = [ + 'html_attr' => 'class="redb"', + 'style' => 'font-size:7pt;', + ]; + } else { + $option = ['style' => 'font-size:7pt;']; + } + + $data[11] = ui_print_timestamp($row['utimestamp'], true, $option); + } + + array_push($table->data, $data); } - } - if (in_array('data', $show_fields) || is_metaconsole()) { - $data[10] = $salida; - } + html_print_table($table); - if (in_array('timestamp', $show_fields) || is_metaconsole()) { - if ($row['module_interval'] > 0) { - $interval = $row['module_interval']; + if ($count_modules > $config['block_size']) { + ui_pagination($count_modules, false, $offset, 0, false, 'offset', true, 'pagination-bottom'); + } + } else { + if ($first_interaction) { + ui_print_info_message(['no_close' => true, 'message' => __('This group doesn\'t have any monitor')]); } else { - $interval = $row['agent_interval']; + ui_print_info_message(['no_close' => true, 'message' => __('Sorry no search parameters')]); } - - if ($row['estado'] == 3) { - $option = [ - 'html_attr' => 'class="redb"', - 'style' => 'font-size:7pt;', - ]; - } else { - $option = ['style' => 'font-size:7pt;']; - } - - $data[11] = ui_print_timestamp($row['utimestamp'], true, $option); } - array_push($table->data, $data); - } + // End Build List Result. + echo "
"; - html_print_table($table); + enterprise_hook('close_meta_frame'); - if ($count_modules > $config['block_size']) { - ui_pagination($count_modules, false, $offset, 0, false, 'offset', true, 'pagination-bottom'); - } -} else { - if ($first_interaction) { - ui_print_info_message(['no_close' => true, 'message' => __('This group doesn\'t have any monitor')]); - } else { - ui_print_info_message(['no_close' => true, 'message' => __('Sorry no search parameters')]); - } -} + ui_require_javascript_file('pandora_modules'); -// End Build List Result. -echo "
"; - -enterprise_hook('close_meta_frame'); - -ui_require_javascript_file('pandora_modules'); - -?> + ?> From 56b641871666f554d3589bc71d4a91b031fa1fa8 Mon Sep 17 00:00:00 2001 From: marcos Date: Thu, 17 Jun 2021 15:04:21 +0200 Subject: [PATCH 031/200] add not condition filter --- pandora_console/operation/agentes/status_monitor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 387b1d5897..90d767af68 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -2050,14 +2050,14 @@ function changeNotConditionStatus() { document.getElementById("select2-modulegroup-container").innerHTML = "None"; document.getElementById("select2-tag_filter-container").innerHTML = "None"; $('select[name=datatypebox] > option:first-child').val('None'); - + $('#datatypebox option:first').text('None'); }else { document.getElementById("select2-status-container").innerHTML = "All"; document.getElementById("select2-moduletype-container").innerHTML = "All"; document.getElementById("select2-ag_group-container").innerHTML = "All"; document.getElementById("select2-modulegroup-container").innerHTML = "All"; document.getElementById("select2-tag_filter-container").innerHTML = "All"; - $('select[name=datatypebox] > option:first-child').val('None'); + $('#datatypebox option:first').text('All'); } From 0c5b8766d01e848c104d9a63764318fd9360b73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= Date: Fri, 18 Jun 2021 14:05:59 +0200 Subject: [PATCH 032/200] Change snmpwalk behaviour in module configuration --- .../agentes/module_manager_editor_network.php | 45 +------------------ 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index be00db6518..d47a3b37be 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -577,12 +577,7 @@ $(document).ready (function () { $('#text-ip_target').keyup(function() { $('#text-target_ip').val($(this).val()); }); - $('#text-target_ip').keyup(function() { - $('#text-ip_target').val($(this).val()); - }); - $('#text-community').keyup(function() { - $('#text-snmp_community').val($(this).val()); - }); + $('#text-snmp_community').keyup(function() { $('#text-community').val($(this).val()); }); @@ -591,61 +586,25 @@ $(document).ready (function () { // Display or collapse the SNMP browser's v3 options checkSNMPVersion (); }); - $('#snmp_browser_version').change(function() { - $('#snmp_version').val($(this).val()); - - // Display or collapse the SNMP v3 options in the main window - if ($(this).val() == "3") { - $("#simple-field_snmpv3_row1").attr("style", ""); - $("#simple-field_snmpv3_row2").attr("style", ""); - $("#simple-field_snmpv3_row3").attr("style", ""); - $("input[name=active_snmp_v3]").val(1); - $("input[name=snmp_community]").attr("disabled", true); - } - else { - $("#simple-field_snmpv3_row1").css("display", "none"); - $("#simple-field_snmpv3_row2").css("display", "none"); - $("#simple-field_snmpv3_row3").css("display", "none"); - $("input[name=active_snmp_v3]").val(0); - $("input[name=snmp_community]").removeAttr('disabled'); - } - }); $('#snmp3_auth_user').keyup(function() { $('#snmp3_browser_auth_user').val($(this).val()); }); - $('#snmp3_browser_auth_user').keyup(function() { - $('#snmp3_auth_user').val($(this).val()); - }); $('#snmp3_security_level').change(function() { $('#snmp3_browser_security_level').val($(this).val()); }); - $('#snmp3_browser_security_level').change(function() { - $('#snmp3_security_level').val($(this).val()); - }); $('#snmp3_auth_method').change(function() { $('#snmp3_browser_auth_method').val($(this).val()); }); - $('#snmp3_browser_auth_method').change(function() { - $('#snmp3_auth_method').val($(this).val()); - }); $('#snmp3_auth_pass').keyup(function() { $('#snmp3_browser_auth_pass').val($(this).val()); }); - $('#snmp3_browser_auth_pass').keyup(function() { - $('#snmp3_auth_pass').val($(this).val()); - }); $('#snmp3_privacy_method').change(function() { $('#snmp3_browser_privacy_method').val($(this).val()); }); - $('#snmp3_browser_privacy_method').change(function() { - $('#snmp3_privacy_method').val($(this).val()); - }); $('#snmp3_privacy_pass').keyup(function() { $('#snmp3_browser_privacy_pass').val($(this).val()); }); - $('#snmp3_browser_privacy_pass').keyup(function() { - $('#snmp3_privacy_pass').val($(this).val()); - }); + var custom_ip_target = ""; if(custom_ip_target == ''){ $("#text-custom_ip_target").hide(); From 5aeab363e999dd3678e633bd6e4aca7bd1f0f704 Mon Sep 17 00:00:00 2001 From: marcos Date: Mon, 21 Jun 2021 11:25:19 +0200 Subject: [PATCH 033/200] more size for select owner modal events --- pandora_console/include/functions_events.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index c1d7aeb404..d2e6dbe106 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -3576,7 +3576,12 @@ function events_page_responses($event, $childrens_ids=[]) '', __('None'), -1, - true + true, + false, + true, + '', + false, + 'width: 70%' ); $data[2] .= html_print_button( __('Update'), From 951924dd9354f9c49081b54cb9b9443b7733c9e8 Mon Sep 17 00:00:00 2001 From: marcos Date: Mon, 21 Jun 2021 11:40:48 +0200 Subject: [PATCH 034/200] colspan 1 to group selector custom graph --- .../godmode/reporting/graph_builder.graph_editor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 1d9b891b79..54ced4e030 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -331,9 +331,9 @@ echo "
"; echo ''; -echo "".__('Filter group').''; +echo "".__('Filter group').''; echo ''; -echo "".html_print_select_groups( +echo "".html_print_select_groups( $config['id_user'], ($report_w == true) ? 'RW' : (($report_m == true) ? 'RM' : 'RW'), true, From 289e8a3902fdee02d82f62b98b809dfa5348f591 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 22 Jun 2021 17:05:45 +0200 Subject: [PATCH 035/200] #7668 fixed tags --- pandora_console/include/lib/Dashboard/Widgets/events_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index 5f5f732128..e457df69bf 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -529,11 +529,11 @@ class EventsListWidget extends Widget if ($customFilter !== false) { $filter = $customFilter; $filter['tag_with'] = base64_encode( - json_encode($filter['tag_with']) + io_safe_output($filter['tag_with']) ); $filter['tag_without'] = base64_encode( - json_encode($filter['tag_without']) + io_safe_output($filter['tag_without']) ); if (!empty($filter['id_agent_module'])) { From 538f17441fc5e2bc265da79b908043177aedf7b7 Mon Sep 17 00:00:00 2001 From: Calvo Date: Wed, 23 Jun 2021 12:49:32 +0200 Subject: [PATCH 036/200] Fixed missing return on tags_update_policy_module_tag function --- pandora_console/include/functions_tags.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 8b1c725143..247e31bd1c 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -511,6 +511,11 @@ function tags_update_policy_module_tag($id_policy_module, $tags, $autocommit=fal } } + if ($errn > 0) { + return false; + } else { + return true; + } } From 38711ca06749cd5bf230ec8649cc77aed683f9cb Mon Sep 17 00:00:00 2001 From: Calvo Date: Wed, 23 Jun 2021 15:13:19 +0200 Subject: [PATCH 037/200] Added icons colors_and_text and faces for server crashed status --- .../status_sets/color_text/server_crash.png | Bin 0 -> 1160 bytes .../images/status_sets/faces/server_crash.png | Bin 0 -> 1231 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 pandora_console/images/status_sets/color_text/server_crash.png create mode 100755 pandora_console/images/status_sets/faces/server_crash.png diff --git a/pandora_console/images/status_sets/color_text/server_crash.png b/pandora_console/images/status_sets/color_text/server_crash.png new file mode 100644 index 0000000000000000000000000000000000000000..43b0c50baa785c2383d226c797b4c219daa7a2fe GIT binary patch literal 1160 zcmV;31b6$1P)+wb?aZ0k=j^Mge_&;0ecvMSo3CG7yS%pULu>HC7(-1xqfS^47a$8b zXNY403^!Je%5#w`U3+@XNV; z$9B}!t*ck2_wK{}xxvv_uz7bqNljr9zKfFJ`^WbOt{KaCZg;o=Jqj&lOg^>IAUq5UX-KWsK%GsI$)7$XRqjq~4 zRp>6QpwR?Nn94wiZ{*43Bu>*+PP_`;M~JkmSJUC4yQ{D$>FZ9U5!MQ8hVllQ&HBk>UsoK2H+UL! z*?BnE8o4)lxapf|MF1(#Tdv5&jp{?apEX=RBHq6bTNV35clk2zbeixnY^OL8B zr>0TYISDAc+|zYU9k$rt?yUNaC?$&u1?b#0JD#4O&7e zqIHG|8jNd@j41WQwlhIDSQabOro`omm&`fGZD0We2+j(j(o~iGUf)-$$N`|TG*Uwd zjYxt|LP)&hA#gMYSR$1+6i8~QAgF5? z4jc#=b974(B2oq2mx&A@9z^7YEz1x|qJ*H-RXPO6 aIr|St0a!0WnD*-c0000Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2i*i3 z3M(APwvd_t00d7-L_t(I%e9nmXw_91$3N$s-~Ic$cXQ6^c6F|~W>FDyMPj2rb`v5= zLMq>=g)NaHGJ2QAFoTR(yZi6=@0?!j zDqf|c7e4TX!*d=!=Xsv<@W3rH@o$&?n@EcyU9v!%D3QQNU|~#@oQX3SQfzMffbRbV z-oKH7P~L7!t$GQ&xfPX+A}oXPG=8=~e)JgUzTSz6<_FuivFJa+{cmxPxNWL>OL;_^)vp{Ey%R8^|`Teluy`VdH0a zV}db+j39-=2m!`mw2#q65Or9wr^p}8@#j|`Pqpu$>MBRxSbl2x`lP)uj&pfC1Y<}U zMXDG=B~UVnR5nt@kSY#(0{7CV*ezjZFI|~D^a=wvf%`X+4(08(n#D_SuY7?tC4>ku zbPUqZoMm_fq?KU!sA1W2e=#%yLWB^)!=3zwn)~m?II*_luad3+%OYK=Rh{_mUbKH2 zP#`T140s&=qeORa0i_b`=_xRN-lw~_h>#XYiSaY&(m`gYmr>GmRe(jFws>r8LWL_Bj#!x5KIjdpO-?rv{iyjBrH2l;G6<9 zm;lhswcq3YcRQ(zd`J-Fm~HQ7%R61vMs`le7!BHBiep%I810e(u&(`FfDl4}SHJ*9 z_!#M7w2O1$4WtNTgv1z4SZ_lc2ctcV=Ytb~Q$k1s!StkE0}F*Qt`@?NV?+)u9klBr zWS$FGYS^)>$dA8fS-K?3>+2KLMJ6$>3q~Uxz(g^w2MSZ!iU_%2GK&;V;DB)*jO!pg z&G$bS89GuTpVyo`?eOKdSqcRYJP%49I3QIW?qn7jB3C&TVFvS~BUsV)=?omeF$ARo zL&qgkIq*EgR1QYZ2qwmTa5T6ee2}pg3THB?FoPA~m}K+0A9kT)i%~Qq3LpZ&Xqubv zqOq}_xv4Po=hxG`;BG9HgaGhCgy$e4Eu7!iM^v)80=)1exp;^x&oCIPD z3m!vRHUu6CmE-n0ho%`tsv;Jux*b{l2$u#;pcL>pC|zWh0zwJoME*41fOr&%f2$~5-@qS6*ul<1%%5F tM9b$;*)Pg6Wd(p&F1=KiTlU{N`y1py)7TXEUNZmy002ovPDHLkV1n~WDt7 Date: Wed, 23 Jun 2021 15:34:52 +0200 Subject: [PATCH 038/200] Fixed color --- pandora_console/include/styles/pandora.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 3b37291fe4..6350659aec 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -7208,7 +7208,7 @@ div.graph div.legend table { } .bg_82B92E { - background-color: #82b92e; + background-color: #82b92e !important; } .bg_B2B2B2 { @@ -7233,13 +7233,13 @@ div.graph div.legend table { background-color: #eee; } .bg_ffd { - background-color: #ffd036; + background-color: #ffd036 !important; } .bg_ff5 { - background-color: #ff5653; + background-color: #ff5653 !important; } .bg_ff9 { - background-color: #ff9e39; + background-color: #ff9e39 !important; } .bg_lightgray { background-color: lightgray; From 2bc607c4aa6be4171761236894f233c9b5c30929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= Date: Wed, 23 Jun 2021 16:14:37 +0200 Subject: [PATCH 039/200] Fixed issue with select2 fields --- pandora_console/include/functions_html.php | 2 +- .../include/javascript/functions_pandora_networkmap.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index d934c7815d..e465c94750 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -915,7 +915,7 @@ function html_print_select( ui_require_javascript_file('select2.min'); } - $output .= ''; + $output .= ''; } if ($return) { diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index 23e7f0cb57..0d440d3048 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -965,7 +965,8 @@ function load_interfaces(selected_links) { $("#relations_table-no_relations").css("display", "none"); $("#relations_table-loading").css("display", ""); - var template_relation_row = $("#relations_table-template_row").clone(); + var template_relation_row = $("#relations_table-template_row"); + template_relation_row.clone(); $(template_relation_row).css("display", ""); $(template_relation_row).attr("class", "relation_link_row"); From fafcef7e854ec267cfddfc4bcd4a403a645eb3d8 Mon Sep 17 00:00:00 2001 From: marcos Date: Wed, 23 Jun 2021 17:35:16 +0200 Subject: [PATCH 040/200] se command sanpshot black theme --- pandora_console/operation/agentes/snapshot_view.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_console/operation/agentes/snapshot_view.php b/pandora_console/operation/agentes/snapshot_view.php index 11bb4fcdd2..2308269532 100644 --- a/pandora_console/operation/agentes/snapshot_view.php +++ b/pandora_console/operation/agentes/snapshot_view.php @@ -79,13 +79,16 @@ if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AR')) { if ($refresh > 0) { $query = ui_get_url_refresh(false); echo ''; + if ($config['style'] === 'pandora_black') { + echo ''; + } } ?> <?php echo __('%s Snapshot data view for module (%s)', get_product_name(), $label); ?> - + "; echo __('Current data at %s', $last_timestamp); From 76d996a96650e70a5b60d2b041dcd41adbcfdaae Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 24 Jun 2021 12:51:14 +0200 Subject: [PATCH 041/200] Fixed tags in events --- pandora_console/include/functions_events.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index c1d7aeb404..acf0b8f0dc 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1151,7 +1151,12 @@ function events_get_all( $tags_names[$id_tag] = tags_get_name($id_tag); } - $_tmp .= ' AND ( '; + if ($tags[0] === $id_tag) { + $_tmp .= ' AND ( '; + } else { + $_tmp .= ' OR ( '; + } + $_tmp .= sprintf( ' tags LIKE "%s" OR', $tags_names[$id_tag] From fec01148017f4ddf47e87c7d847ad3c63be17423 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 24 Jun 2021 13:22:25 +0200 Subject: [PATCH 042/200] set urls as macros in console supervisor --- .../include/class/ConsoleSupervisor.php | 64 +++++++++---------- .../include/functions_messages.php | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 84c30f8b8f..9ecf10ad34 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -808,7 +808,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.LICENSE.LIMITED', 'title' => __('Limited mode.'), 'message' => io_safe_output($config['limited_mode']), - 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/license'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', ] ); } else { @@ -834,7 +834,7 @@ class ConsoleSupervisor $msg, $days_to_expiry ), - 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/license'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', ] ); } else if ($days_to_expiry < 0) { @@ -852,7 +852,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.LICENSE.EXPIRATION', 'title' => $title, 'message' => $msg, - 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/license'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', ] ); return false; @@ -929,7 +929,7 @@ class ConsoleSupervisor 'Directory %s is not writable. Please, configure corresponding permissions.', $config['attachment_store'] ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); return; @@ -951,7 +951,7 @@ class ConsoleSupervisor 'There are more than %d files in attachment, consider cleaning up attachment directory manually.', $config['num_files_attachment'] ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -985,7 +985,7 @@ class ConsoleSupervisor 'Remote configuration directory %s is not readable. Please, adjust configuration.', $remote_config_dir ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); return; @@ -1004,7 +1004,7 @@ class ConsoleSupervisor 'Remote configuration directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/conf' ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); } else { @@ -1022,7 +1022,7 @@ class ConsoleSupervisor 'Collections directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/collections' ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); } else { @@ -1040,7 +1040,7 @@ class ConsoleSupervisor 'MD5 directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/md5' ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); } else { @@ -1071,7 +1071,7 @@ class ConsoleSupervisor $MAX_FILES_DATA_IN, $remote_config_dir ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -1094,7 +1094,7 @@ class ConsoleSupervisor $MAX_BADXML_FILES_DATA_IN, $remote_config_dir ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -1186,7 +1186,7 @@ class ConsoleSupervisor $modules_queued, $queue['queued_modules'] ), - 'url' => ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60'), + 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', ] ); } else { @@ -1322,7 +1322,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.SERVER.STATUS.'.$server['id_server'], 'title' => $msg, 'message' => $description, - 'url' => ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60'), + 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', ] ); } @@ -1634,7 +1634,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.HISTORYDB', 'title' => __('Historical database not available'), 'message' => __('Historical database is enabled, though not accessible with the current configuration.'), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', ] ); } else { @@ -1681,7 +1681,7 @@ class ConsoleSupervisor 'Your database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', io_safe_output(get_product_name()) ), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -1741,7 +1741,7 @@ class ConsoleSupervisor 'Historical database maintenance problem.' ), 'message' => __('Your historical database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', get_product_name()), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -1780,7 +1780,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.HISTORYDB.MR', 'title' => __('Historical database MR mismatch'), 'message' => __('Your historical database is not using the same schema as the main DB. This could produce anomalies while storing historical data.'), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', ] ); } else { @@ -1821,7 +1821,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.EXT.ELASTICSEARCH', 'title' => __('Log collector cannot connect to ElasticSearch'), 'message' => __('ElasticSearch is not available using current configuration.'), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=log'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=log', ] ); } else { @@ -1891,7 +1891,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.METACONSOLE.DB_CONNECTION', 'title' => __('Metaconsole DB is not available.'), 'message' => __('Cannot connect with Metaconsole DB using current configuration.'), - 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise', ] ); } @@ -1920,7 +1920,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.DOWNTIME', 'title' => __('Scheduled downtime running.'), 'message' => __('A scheduled downtime is running. Some monitoring data won\'t be available while downtime is taking place.'), - 'url' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'), + 'url' => '__url__/index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list', ] ); return; @@ -2081,7 +2081,7 @@ class ConsoleSupervisor date('M j, G:i:s ', $next_downtime_begin), date('M j, G:i:s ', $next_downtime_end) ), - 'url' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'), + 'url' => '__url__/index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list', ] ); return; @@ -2142,7 +2142,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.SECURITY.DEFAULT_PASSWORD', 'title' => __('Default password for "Admin" user has not been changed'), 'message' => __('Please, change the default password since it is a commonly reported vulnerability.'), - 'url' => ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list'), + 'url' => '__url__/index.php?sec=gusuarios&sec2=godmode/users/user_list', ] ); } else { @@ -2178,7 +2178,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.MISC.FONTPATH', 'title' => __('Default font doesn\'t exist'), 'message' => __('Your defined font doesn\'t exist or is not defined. Please, check font parameters in your config'), - 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=vis'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup§ion=vis', ] ); } else { @@ -2205,7 +2205,7 @@ class ConsoleSupervisor 'Your %s has the "develop_bypass" mode enabled. This is a developer mode and should be disabled in a production environment. This value is located in the main index.php file', get_product_name() ), - 'url' => ui_get_full_url('index.php'), + 'url' => '__url__/index.php', ] ); } else { @@ -2228,7 +2228,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.MISC.EVENTSTORMPROTECTION', 'title' => __('Event storm protection is enabled.'), 'message' => __('Some events may get lost while this mode is enabled. The server must be restarted after altering this setting.'), - 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', ] ); } else { @@ -2255,7 +2255,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP', 'title' => __('Failed to retrieve updates, please configure utility'), 'message' => $message, - 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', ] ); } @@ -2275,7 +2275,7 @@ class ConsoleSupervisor get_product_name() ), 'message' => __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'), - 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online', ] ); } else { @@ -2313,7 +2313,7 @@ class ConsoleSupervisor 'There is one or more minor releases available. .About minor release update.', $url ), - 'url' => ui_get_full_url('index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online'), + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', ] ); } else { @@ -2362,7 +2362,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.CRON.CONFIGURED', 'title' => __('DiscoveryConsoleTasks is not configured.'), 'message' => __($message_conf_cron), - 'url' => ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist'), + 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist', ] ); } else { @@ -2462,7 +2462,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.SERVER.MISALIGNED', 'title' => __($title_ver_misaligned), 'message' => __($message_ver_misaligned), - 'url' => ui_get_full_url('index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online'), + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', ] ); } @@ -2507,7 +2507,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.ALLOWOVERRIDE.MESSAGE', 'title' => __('AllowOverride is disabled'), 'message' => __($message), - 'url' => ui_get_full_url('index.php'), + 'url' => '__url__/index.php', ] ); } @@ -2553,7 +2553,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.HAMASTER.MESSAGE', 'title' => __('Desynchronized operation on the node '.$node['host']), 'message' => __($message), - 'url' => ui_get_full_url('index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster'), + 'url' => '__url__/index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster', ] ); } else { diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index f929eb9ed1..a8a0b009bf 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -662,7 +662,7 @@ function messages_get_url($message_id) // Return URL stored if is set in database. if (isset($messages['url'])) { - return $messages['url']; + return str_replace('__url__', ui_get_full_url('/'), $messages['url']); } // Return the message direction. From 26acac191f473f93f49b280621babccfb84e0164 Mon Sep 17 00:00:00 2001 From: marcos Date: Fri, 25 Jun 2021 09:37:26 +0200 Subject: [PATCH 043/200] ad not condition on monitor detail --- pandora_console/include/functions_html.php | 10 +++++-- .../operation/agentes/status_monitor.php | 29 +++++++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index d934c7815d..c60968b6b6 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -436,6 +436,7 @@ function html_print_select_style($fields, $name, $selected='', $style='', $scrip * @param string $size Style, size (width) of element. * @param boolean $simple_multiple_options Discovery simple multiple inputs. * @param boolean $required Required input. + * @param string $inverse Change All to None with inverse condition. * * @return string HTML code if return parameter is true. */ @@ -462,7 +463,8 @@ function html_print_select_groups( $include_groups=false, $size=false, $simple_multiple_options=false, - $required=false + $required=false, + $inverse='' ) { $output = ''; @@ -522,7 +524,11 @@ function html_print_select_groups( if (empty($selected) === false) { $fields = [ $selected => groups_get_name($selected) ]; } else if ($returnAllGroup === true && $multiple === false) { - $fields = [ $selected => groups_get_name(null, true) ]; + if ($selected === 0 && $inverse !== '') { + $fields = [ $selected => 'None' ]; + } else { + $fields = [ $selected => groups_get_name(null, true) ]; + } } } else { foreach ($selected as $k) { diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 90d767af68..8856d89423 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -144,6 +144,11 @@ $module_option = (int) get_parameter('module_option', 1); $not_condition = (string) get_parameter('not_condition', ''); +$is_none = 'All'; +if ($not_condition !== '') { + $is_none = 'None'; +} + // If option not_condition is enabled, the conditions of the queries are reversed. $condition_query = '='; if ($not_condition !== '') { @@ -459,7 +464,13 @@ $table->data[0][1] .= html_print_select_groups( false, false, 'id_grupo', - false + false, + false, + false, + false, + false, + false, + $not_condition ); $table->data[0][1] .= '
'; $table->data[0][1] .= html_print_input( @@ -489,7 +500,7 @@ $table->data[0][3] = html_print_select( 'status', $status, '', - __('All'), + __($is_none), -1, true, false, @@ -517,7 +528,7 @@ if (!is_metaconsole()) { $rows_select = modules_get_modulegroups(); } -$table->data[0][5] = html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'), -1, true, false, true, '', false, 'width: 120px;'); +$table->data[0][5] = html_print_select($rows_select, 'modulegroup', $modulegroup, '', __($is_none), -1, true, false, true, '', false, 'width: 120px;'); $table->rowspan[0][6] = 3; $table->data[0][6] = html_print_submit_button( @@ -554,7 +565,7 @@ if (empty($tags)) { 'tag_filter', $tag_filter, '', - __('All'), + __($is_none), '', true, false, @@ -633,7 +644,7 @@ if (enterprise_installed()) { $table->data[2][0] = ''.__('Server type').''; -$table->data[2][1] = html_print_select($typemodules, 'moduletype', $moduletype, '', __('All'), '', true, false, true, '', false, 'width: 150px;'); +$table->data[2][1] = html_print_select($typemodules, 'moduletype', $moduletype, '', __($is_none), '', true, false, true, '', false, 'width: 150px;'); $monitor_options = [ 0 => __('All'), @@ -732,7 +743,7 @@ $table->data[3][1] .= '