diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f6887cb4f4..72246ea53c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.763-220630 +Version: 7.0NG.763-220704 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 4716a6a3ef..6bbcbc32c4 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.763-220630" +pandora_version="7.0NG.763-220704" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 10b23cc997..e797e34112 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.763'; -use constant AGENT_BUILD => '220630'; +use constant AGENT_BUILD => '220704'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index f9707d7f21..078acf22be 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.763 -%define release 220630 +%define release 220704 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 6677f694b4..da19200e3d 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.763 -%define release 220630 +%define release 220704 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 5a0703bcb8..a87a343938 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.763" -PI_BUILD="220630" +PI_BUILD="220704" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 90824540ef..1db7c77c21 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220630} +{220704} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 29085af385..adda88535b 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.763 Build 220630") +#define PANDORA_VERSION ("7.0NG.763 Build 220704") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index f65c8cd04d..9df0778fe3 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.763(Build 220630))" + VALUE "ProductVersion", "(7.0NG.763(Build 220704))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index d42b6da5cc..283e3b1287 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.763-220630 +Version: 7.0NG.763-220704 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index f41bcea4b1..1680735c64 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.763-220630" +pandora_version="7.0NG.763-220704" package_pear=0 package_pandora=1 diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index fb5dce8830..5f06eb7b89 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -45,7 +45,7 @@ if ($default != 0) { 'token' => 'event_fields', 'value' => $event_fields, ]; - // update 'event_fields' in tconfig table to keep the value at update. + // Update 'event_fields' in tconfig table to keep the value at update. $result = db_process_sql_update( 'tconfig', $values, @@ -147,7 +147,7 @@ $table->data[1][1] .= ''.html_print_image( $table->data[0][1] = ''; $table->data[0][2] = ''.__('Fields selected').''; -$table->data[1][2] = html_print_select( +$table->data[1][2] = ''.html_print_select( $result_selected, 'fields_selected[]', true, @@ -162,6 +162,25 @@ $table->data[1][2] = html_print_select( 'width: 300px' ); +$table->data[1][2] .= ''; +$table->data[1][2] .= ''.html_print_image( + 'images/darrowup.png', + true, + [ + 'onclick' => 'sortUpDown(\'up\');', + 'title' => __('Move up selected fields'), + ] +).''; +$table->data[1][2] .= ''.html_print_image( + 'images/darrowdown.png', + true, + [ + 'onclick' => 'sortUpDown(\'down\');', + 'title' => __('Move down selected fields'), + ] +).''; +$table->data[1][2] .= ''; + echo ''; html_print_table($table); @@ -174,7 +193,7 @@ echo ''; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 55b967aa08..9726d8fcdd 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -180,6 +180,9 @@ $uncompressed_module = true; $macros_definition = ''; $render_definition = ''; +$text_agent = ''; +$text_agent_module = ''; + $only_data = false; // Users. @@ -678,6 +681,21 @@ switch ($action) { $period = $item['period']; $order_uptodown = $item['order_uptodown']; $show_resume = $item['show_resume']; + + $text_agent = ''; + if (isset($style['text_agent']) === true + && empty($style['text_agent']) === false + ) { + $text_agent = base64_decode($style['text_agent']); + } + + + $text_agent_module = ''; + if (isset($style['text_agent_module']) === true + && empty($style['text_agent_module']) === false + ) { + $text_agent_module = base64_decode($style['text_agent_module']); + } break; case 'availability': @@ -745,6 +763,21 @@ switch ($action) { $show_resume = $item['show_resume']; $show_graph = $item['show_graph']; $order_uptodown = $item['order_uptodown']; + + $text_agent = ''; + if (isset($style['text_agent']) === true + && empty($style['text_agent']) === false + ) { + $text_agent = base64_decode($style['text_agent']); + } + + + $text_agent_module = ''; + if (isset($style['text_agent_module']) === true + && empty($style['text_agent_module']) === false + ) { + $text_agent_module = base64_decode($style['text_agent_module']); + } break; case 'exception': @@ -755,6 +788,21 @@ switch ($action) { $show_resume = $item['show_resume']; $show_graph = $item['show_graph']; $order_uptodown = $item['order_uptodown']; + + $text_agent = ''; + if (isset($style['text_agent']) === true + && empty($style['text_agent']) === false + ) { + $text_agent = base64_decode($style['text_agent']); + } + + + $text_agent_module = ''; + if (isset($style['text_agent_module']) === true + && empty($style['text_agent_module']) === false + ) { + $text_agent_module = base64_decode($style['text_agent_module']); + } break; case 'agent_module': @@ -1093,6 +1141,52 @@ $class = 'databox filters'; + + + + + + + + + + + + + + + + + + @@ -5990,6 +6084,8 @@ function chooseType() { $("#row_render_definition").hide(); $("#row_time_compare_overlapped").hide(); $("#row_quantity").hide(); + $("#row_agent_regexp").hide(); + $("#row_module_regexp").hide(); $("#row_exception_condition_value").hide(); $("#row_exception_condition").hide(); $("#row_dyn_height").hide(); @@ -6480,6 +6576,8 @@ function chooseType() { $("#row_order_uptodown").show(); $("#row_show_resume").show(); $("#row_show_in_same_row").show(); + $("#row_agent_regexp").show(); + $("#row_module_regexp").show(); var checked = $("input[name='last_value']").prop("checked"); @@ -6548,6 +6646,8 @@ function chooseType() { $("#row_description").show(); $("#row_period").show(); $("#row_max_min_avg").show(); + $("#row_agent_regexp").show(); + $("#row_module_regexp").show(); $("#row_quantity").show(); $("#general_list").show(); $("#row_order_uptodown").show(); @@ -6565,6 +6665,8 @@ function chooseType() { $("#row_order_uptodown").show(); $("#row_show_resume").show(); $("#row_show_graph").show(); + $("#row_agent_regexp").show(); + $("#row_module_regexp").show(); var checked = $("input[name='last_value']").prop("checked"); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index e7337418a0..2b03c1a771 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2321,6 +2321,20 @@ switch ($action) { // $values['external_source'] = json_encode($es); break; + case 'top_n': + case 'general': + case 'exception': + $text_agent = get_parameter('text_agent', ''); + $text_agent_module = get_parameter('text_agent_module', ''); + if (empty($text_agent) === false) { + $style['text_agent'] = base64_encode($text_agent); + } + + if (empty($text_agent_module) === false) { + $style['text_agent_module'] = base64_encode($text_agent_module); + } + break; + default: // Default. break; @@ -3073,6 +3087,20 @@ switch ($action) { $es['agent_not_assigned_to_ip'] = get_parameter('agent_not_assigned_to_ip'); break; + case 'top_n': + case 'general': + case 'exception': + $text_agent = get_parameter('text_agent', ''); + $text_agent_module = get_parameter('text_agent_module', ''); + if (empty($text_agent) === false) { + $style['text_agent'] = base64_encode($text_agent); + } + + if (empty($text_agent_module) === false) { + $style['text_agent_module'] = base64_encode($text_agent_module); + } + break; + default: // Default. break; diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index d425c13b14..897d5ddea0 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -1298,6 +1298,15 @@ $table_other->data[$row][1] = html_print_checkbox_switch( ); $row++; +$table_other->data[$row][0] = __('Show empty groups in group view'); +$table_other->data[$row][1] = html_print_checkbox_switch( + 'show_empty_groups', + 1, + $config['show_empty_groups'], + true +); +$row++; + $table_other->data[$row][0] = __('Date format string'); $table_other->data[$row][1] = ''.__('Example').' '.date($config['date_format']); $table_other->data[$row][1] .= html_print_input_text('date_format', $config['date_format'], '', 30, 100, true); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 068fc4797b..aa3d82e1f7 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC220630'; +$build_version = 'PC220704'; $pandora_version = 'v7.0NG.763'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index a7db04abb0..eebc498131 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1245,6 +1245,10 @@ function config_update_config() $error_update[] = __('Show the group name instead the group icon.'); } + if (config_update_value('show_empty_groups', get_parameter('show_empty_groups'), true) === false) { + $error_update[] = __('Show empty groups in group view.'); + } + if (config_update_value('custom_graph_width', (int) get_parameter('custom_graph_width', 1), true) === false) { $error_update[] = __('Default line thickness for the Custom Graph.'); } @@ -3115,6 +3119,10 @@ function config_process_config() config_update_value('show_group_name', 0); } + if (!isset($config['show_empty_groups'])) { + config_update_value('show_empty_groups', 1); + } + if (!isset($config['custom_graph_width'])) { config_update_value('custom_graph_width', 1); } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 4040edb546..8e9c026d77 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -401,15 +401,8 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal case '1': // Group by events. - $event = events_get_event($id_evento, ['estado', 'event_type', 'id_agente', 'id_agentmodule']); - $filter['group_rep'] = 0; - $filter['status'] = $event['estado']; - $filter['event_type'] = $event['event_type']; - $filter['id_agent'] = $event['id_agente']; - $filter['id_agentmodule'] = $event['id_agentmodule']; - $sql = events_get_all( - ['te.id_evento'], + ['te.*'], $filter, // Offset. null, @@ -425,7 +418,18 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal true ); - $target_ids = db_get_all_rows_sql($sql); + $target_ids = db_get_all_rows_sql( + sprintf( + 'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf + ON tu.estado = tf.estado + AND tu.evento = tf.evento + AND tu.id_agente = tf.id_agente + AND tu.id_agentmodule = tf.id_agentmodule + AND tf.max_id_evento = %d', + $sql, + $id_evento + ) + ); // Try to avoid deadlock while updating full set. if ($target_ids !== false && count($target_ids) > 0) { @@ -490,15 +494,8 @@ function events_update_status($id_evento, $status, $filter=null) case '1': // Group by events. - $event = events_get_event($id_evento, ['estado', 'event_type', 'id_agente', 'id_agentmodule']); - $filter['group_rep'] = 0; - $filter['status'] = $event['estado']; - $filter['event_type'] = $event['event_type']; - $filter['id_agent'] = $event['id_agente']; - $filter['id_agentmodule'] = $event['id_agentmodule']; - $sql = events_get_all( - ['te.id_evento'], + ['te.*'], $filter, // Offset. null, @@ -514,7 +511,18 @@ function events_update_status($id_evento, $status, $filter=null) true ); - $target_ids = db_get_all_rows_sql($sql); + $target_ids = db_get_all_rows_sql( + sprintf( + 'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf + ON tu.estado = tf.estado + AND tu.evento = tf.evento + AND tu.id_agente = tf.id_agente + AND tu.id_agentmodule = tf.id_agentmodule + AND tf.max_id_evento = %d', + $sql, + $id_evento + ) + ); // Try to avoid deadlock while updating full set. if ($target_ids !== false && count($target_ids) > 0) { diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 1cafccce6a..6c265e8e0f 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4262,3 +4262,50 @@ function modules_get_min_max_data($id_agent_module, $time_init=0) return $data; } + + +/** + * Get modules match regex. + * + * @param string $regex_alias Regex alias. + * @param string $regex_name_module Regex module name. + * @param string $server_name Name server. + * + * @return array + */ +function modules_get_regex( + $regex_alias, + $regex_name_module='', + $server_name='' +) { + $agent_regexp = sprintf('AND tagente.alias REGEXP "%s"', $regex_alias); + $module_regexp = ''; + if (empty($regex_name_module) === false) { + $module_regexp = sprintf( + 'AND tagente_modulo.nombre REGEXP "%s"', + $regex_name_module + ); + } + + $sql = sprintf( + 'SELECT tagente_modulo.id_agente_modulo as id_agent_module, + "%s" as server_name + FROM tagente_modulo + INNER JOIN tagente + ON tagente.id_agente = tagente_modulo.id_agente + WHERE 1=1 + %s + %s', + $server_name, + $agent_regexp, + $module_regexp + ); + + $result = db_get_all_rows_sql($sql); + + if ($result === false) { + $result = []; + } + + return $result; +} diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index e78f1ccc8b..08936c170b 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -67,6 +67,7 @@ define('REPORT_STATUS_DOWNTIME', 4); define('REPORT_STATUS_IGNORED', 5); // Clases. +use PandoraFMS\Enterprise\Metaconsole\Node; use PandoraFMS\Event; use PandoraFMS\Module; @@ -1544,10 +1545,6 @@ function reporting_event_top_n( $return['top_n'] = $content['top_n_value']; if (empty($content['subitems'])) { - if (is_metaconsole()) { - metaconsole_restore_db(); - } - // Get all the related data. $sql = sprintf( 'SELECT id_agent_module, server_name @@ -1556,7 +1553,67 @@ function reporting_event_top_n( $content['id_rc'] ); - $tops = db_process_sql($sql); + $tops = db_get_all_rows_sql($sql); + if ($tops === false) { + $tops = []; + } + + // REGEXP. + $text_agent = ''; + if (isset($content['style']['text_agent']) === true + && empty($content['style']['text_agent']) === false + ) { + $text_agent = base64_decode($content['style']['text_agent']); + } + + $text_agent_module = ''; + if (isset($content['style']['text_agent_module']) === true + && empty($content['style']['text_agent_module']) === false + ) { + $text_agent_module = base64_decode($content['style']['text_agent_module']); + } + + $modules_regex = []; + if (empty($text_agent) === false) { + if (is_metaconsole() === true) { + $nodes = metaconsole_get_connections(); + foreach ($nodes as $node) { + try { + $nd = new Node($node['id']); + $nd->connect(); + $modules_regex_node = modules_get_regex( + $text_agent, + $text_agent_module, + $node['server_name'] + ); + } catch (\Exception $e) { + $nd->disconnect(); + $modules_regex_node = []; + } finally { + $nd->disconnect(); + } + + $modules_regex = array_merge($modules_regex, $modules_regex_node); + } + } else { + $modules_regex = modules_get_regex( + $text_agent, + $text_agent_module + ); + } + } + + if (empty($modules_regex) === false) { + $tops = array_merge($tops, $modules_regex); + $tops = array_reduce( + $tops, + function ($carry, $item) { + $carry[$item['id_agent_module'].'|'.$item['server_name']] = $item; + return $carry; + }, + [] + ); + } } else { $tops = $content['subitems']; } @@ -1579,6 +1636,9 @@ function reporting_event_top_n( $height = $force_height_chart; } + // Force width 600px. + $width = 600; + if (empty($tops)) { $return['failed'] = __('There are no Agent/Modules defined'); } else { @@ -1590,7 +1650,6 @@ function reporting_event_top_n( if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { - // ui_print_error_message ("Error connecting to ".$server_name); continue; } } @@ -1644,18 +1703,51 @@ function reporting_event_top_n( switch ($order_uptodown) { // Descending. case 1: - array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); + array_multisort( + $data_top, + SORT_DESC, + $agent_name, + SORT_ASC, + $module_name, + SORT_ASC, + $id_agent_module, + SORT_ASC, + $units, + SORT_ASC + ); break; // Ascending. case 2: - array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); + array_multisort( + $data_top, + SORT_ASC, + $agent_name, + SORT_ASC, + $module_name, + SORT_ASC, + $id_agent_module, + SORT_ASC, + $units, + SORT_ASC + ); break; // By agent name or without selection. case 0: case 3: - array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); + array_multisort( + $agent_name, + SORT_ASC, + $data_top, + SORT_ASC, + $module_name, + SORT_ASC, + $id_agent_module, + SORT_ASC, + $units, + SORT_ASC + ); break; default: @@ -1683,66 +1775,18 @@ function reporting_event_top_n( $i = 0; $data_pie_graph = []; $data_hbar = []; - foreach ($data_top as $dt) { - $item_name = ''; - $item_name = ui_print_truncate_text($agent_name[$i], $truncate_size, false, true, false, '...').' - '.ui_print_truncate_text($module_name[$i], $truncate_size, false, true, false, '...'); - - $item_name_key_pie = $item_name; - $exist_key = true; - while ($exist_key) { - if (isset($data_pie_graph[$item_name_key_pie])) { - $item_name_key_pie .= ' '; - } else { - $exist_key = false; - } - } - - $item_name_key_hbar = $item_name; - $exist_key = true; - while ($exist_key) { - if (isset($data_hbar[$item_name_key_hbar])) { - $item_name_key_hbar = ' '.$item_name_key_hbar; - } else { - $exist_key = false; - } - } - - $data_hbar[$item_name]['g'] = $dt; - $data_pie_graph[$item_name] = $dt; - - if ($show_graph == 0 || $show_graph == 1) { - $data = []; - $data['agent'] = $agent_name[$i]; - $data['module'] = $module_name[$i]; - - $data['value'] = $dt; - - $divisor = get_data_multiplier($units[$i]); - - $data['formated_value'] = format_for_graph($dt, 2, '.', ',', $divisor, $units[$i]); - $data_return[] = $data; - } - - $i++; - if ($i >= $top_n_value) { - break; - } - } - } else if ($order_uptodown == 0 || $order_uptodown == 3) { - $i = 0; - $data_pie_graph = []; - $data_hbar = []; - foreach ($agent_name as $an) { - $item_name = ''; + foreach ($data_top as $key_dt => $dt) { $item_name = ui_print_truncate_text( - $agent_name[$i], + $agent_name[$key_dt], $truncate_size, false, true, false, '...' - ).' - '.ui_print_truncate_text( - $module_name[$i], + ); + $item_name .= ' - '; + $item_name .= ui_print_truncate_text( + $module_name[$key_dt], $truncate_size, false, true, @@ -1770,17 +1814,94 @@ function reporting_event_top_n( } } - $data_pie_graph[$item_name] = $data_top[$i]; - $data_hbar[$item_name]['g'] = $data_top[$i]; + $data_hbar[$item_name]['g'] = $dt; + $data_pie_graph[$item_name] = $dt; - $divisor = get_data_multiplier($units[$i]); + if ($show_graph == 0 || $show_graph == 1) { + $data = []; + $data['agent'] = $agent_name[$key_dt]; + $data['module'] = $module_name[$key_dt]; + + $data['value'] = $dt; + + $divisor = get_data_multiplier($units[$key_dt]); + + $data['formated_value'] = format_for_graph( + $dt, + 2, + '.', + ',', + $divisor, + $units[$key_dt] + ); + $data_return[] = $data; + } + + $i++; + if ($i >= $top_n_value) { + break; + } + } + } else if ($order_uptodown == 0 || $order_uptodown == 3) { + $i = 0; + $data_pie_graph = []; + $data_hbar = []; + foreach ($agent_name as $key_an => $an) { + $item_name = ''; + $item_name = ui_print_truncate_text( + $agent_name[$key_an], + $truncate_size, + false, + true, + false, + '...' + ).' - '.ui_print_truncate_text( + $module_name[$key_an], + $truncate_size, + false, + true, + false, + '...' + ); + + $item_name_key_pie = $item_name; + $exist_key = true; + while ($exist_key) { + if (isset($data_pie_graph[$item_name_key_pie])) { + $item_name_key_pie .= ' '; + } else { + $exist_key = false; + } + } + + $item_name_key_hbar = $item_name; + $exist_key = true; + while ($exist_key) { + if (isset($data_hbar[$item_name_key_hbar])) { + $item_name_key_hbar = ' '.$item_name_key_hbar; + } else { + $exist_key = false; + } + } + + $data_pie_graph[$item_name] = $data_top[$key_an]; + $data_hbar[$item_name]['g'] = $data_top[$key_an]; + + $divisor = get_data_multiplier($units[$key_an]); if ($show_graph == 0 || $show_graph == 1) { $data = []; $data['agent'] = $an; - $data['module'] = $module_name[$i]; - $data['value'] = $data_top[$i]; - $data['formated_value'] = format_for_graph($data_top[$i], 2, '.', ',', $divisor, $units[$i]); + $data['module'] = $module_name[$key_an]; + $data['value'] = $data_top[$key_an]; + $data['formated_value'] = format_for_graph( + $data_top[$key_an], + 2, + '.', + ',', + $divisor, + $units[$key_an] + ); $data_return[] = $data; } @@ -1826,7 +1947,7 @@ function reporting_event_top_n( $ttl, $config['homeurl'], 'white', - 'black' + '#DFDFDF' ); } @@ -3150,11 +3271,72 @@ function reporting_exception( WHERE id_report_content = %d', $content['id_rc'] ); - if (is_metaconsole()) { - metaconsole_restore_db(); + + $exceptions = db_get_all_rows_sql($sql); + if ($exceptions === false) { + $exceptions = []; } - $exceptions = db_process_sql($sql); + // REGEXP. + $text_agent = ''; + if (isset($content['style']['text_agent']) === true + && empty($content['style']['text_agent']) === false + ) { + $text_agent = base64_decode($content['style']['text_agent']); + } + + $text_agent_module = ''; + if (isset($content['style']['text_agent_module']) === true + && empty($content['style']['text_agent_module']) === false + ) { + $text_agent_module = base64_decode($content['style']['text_agent_module']); + } + + $modules_regex = []; + if (empty($text_agent) === false) { + if (is_metaconsole() === true) { + $nodes = metaconsole_get_connections(); + foreach ($nodes as $node) { + try { + $nd = new Node($node['id']); + $nd->connect(); + $modules_regex_node = modules_get_regex( + $text_agent, + $text_agent_module, + $node['server_name'] + ); + } catch (\Exception $e) { + $nd->disconnect(); + $modules_regex_node = []; + } finally { + $nd->disconnect(); + } + + $modules_regex = array_merge($modules_regex, $modules_regex_node); + } + } else { + $modules_regex = modules_get_regex( + $text_agent, + $text_agent_module + ); + } + } + + if (empty($modules_regex) === false) { + $exceptions = array_merge($exceptions, $modules_regex); + $exceptions = array_reduce( + $exceptions, + function ($carry, $item) { + if (isset($item['operation']) === false) { + $item['operation'] = 'avg'; + } + + $carry[$item['id_agent_module'].'|'.$item['server_name']] = $item; + return $carry; + }, + [] + ); + } } else { $exceptions = $content['subitems']; } @@ -4924,7 +5106,7 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0) $data_macro['server_id'] ); if (metaconsole_connect($server) != NOERR) { - continue; + continue 2; } } @@ -9423,14 +9605,75 @@ function reporting_general($report, $content) $return['show_in_same_row'] = $content['style']['show_in_same_row']; if (empty($content['subitems'])) { - if (is_metaconsole()) { - metaconsole_restore_db(); - } - $generals = db_get_all_rows_filter( 'treport_content_item', ['id_report_content' => $content['id_rc']] ); + + if ($generals === false) { + $generals = []; + } + + // REGEXP. + $text_agent = ''; + if (isset($content['style']['text_agent']) === true + && empty($content['style']['text_agent']) === false + ) { + $text_agent = base64_decode($content['style']['text_agent']); + } + + $text_agent_module = ''; + if (isset($content['style']['text_agent_module']) === true + && empty($content['style']['text_agent_module']) === false + ) { + $text_agent_module = base64_decode($content['style']['text_agent_module']); + } + + $modules_regex = []; + if (empty($text_agent) === false) { + if (is_metaconsole() === true) { + $nodes = metaconsole_get_connections(); + foreach ($nodes as $node) { + try { + $nd = new Node($node['id']); + $nd->connect(); + $modules_regex_node = modules_get_regex( + $text_agent, + $text_agent_module, + $node['server_name'] + ); + } catch (\Exception $e) { + $nd->disconnect(); + $modules_regex_node = []; + } finally { + $nd->disconnect(); + } + + $modules_regex = array_merge($modules_regex, $modules_regex_node); + } + } else { + $modules_regex = modules_get_regex( + $text_agent, + $text_agent_module + ); + } + } + + if (empty($modules_regex) === false) { + $generals = array_merge($generals, $modules_regex); + $generals = array_reduce( + $generals, + function ($carry, $item) { + if (isset($item['operation']) === false) { + $item['operation'] = 'avg'; + } + + $carry[$item['id_agent_module'].'|'.$item['server_name']] = $item; + return $carry; + }, + [] + ); + } } else { $generals = $content['subitems']; } @@ -9440,16 +9683,14 @@ function reporting_general($report, $content) } $i = 0; - $index = 0; $is_string = []; - foreach ($generals as $row) { - // Metaconsole connection + foreach ($generals as $key_row => $row) { + // Metaconsole connection. $server_name = $row['server_name']; if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { - // ui_print_error_message ("Error connecting to ".$server_name); continue; } } @@ -9458,7 +9699,7 @@ function reporting_general($report, $content) || modules_is_not_init($row['id_agent_module']) ) { if (is_metaconsole()) { - // Restore db connection + // Restore db connection. metaconsole_restore_db(); } @@ -9469,7 +9710,7 @@ function reporting_general($report, $content) $ag_name = modules_get_agentmodule_agent_alias($row['id_agent_module']); $name_agent = modules_get_agentmodule_agent_name($row['id_agent_module']); $type_mod = modules_get_last_value($row['id_agent_module']); - $is_string[$index] = modules_is_string($row['id_agent_module']); + $is_string[$key_row] = modules_is_string($row['id_agent_module']); $unit = db_get_value( 'unit', 'tagente_modulo', @@ -9478,7 +9719,7 @@ function reporting_general($report, $content) ); $id_module_type = db_get_value('id_tipo_modulo', 'tagente_modulo', 'nombre', $mod_name); if ($content['period'] == 0) { - $data_res[$index] = modules_get_last_value($row['id_agent_module']); + $data_res[$key_row] = modules_get_last_value($row['id_agent_module']); } else { $data_sum = reporting_get_agentmodule_data_sum( $row['id_agent_module'], @@ -9502,34 +9743,34 @@ function reporting_general($report, $content) ); if ($content['style']['show_in_same_row'] && $content['group_by_agent'] == REPORT_GENERAL_NOT_GROUP_BY_AGENT) { - $data_res[$index] = [ + $data_res[$key_row] = [ $data_avg, $data_max, $data_min, $data_sum, ]; } else { - if (is_numeric($type_mod) && !$is_string[$index]) { + if (is_numeric($type_mod) && !$is_string[$key_row]) { switch ($row['operation']) { case 'sum': - $data_res[$index] = $data_sum; + $data_res[$key_row] = $data_sum; break; case 'max': - $data_res[$index] = $data_max; + $data_res[$key_row] = $data_max; break; case 'min': - $data_res[$index] = $data_min; + $data_res[$key_row] = $data_min; break; case 'avg': default: - $data_res[$index] = $data_avg; + $data_res[$key_row] = $data_avg; break; } } else { - $data_res[$index] = $type_mod; + $data_res[$key_row] = $type_mod; } } } @@ -9538,46 +9779,46 @@ function reporting_general($report, $content) switch ($content['group_by_agent']) { case REPORT_GENERAL_NOT_GROUP_BY_AGENT: - $id_agent_module[$index] = $row['id_agent_module']; - $agent_name[$index] = $ag_name; - $module_name[$index] = $mod_name; - $units[$index] = $unit; - $id_module_types[$index] = $id_module_type; - $operations[$index] = $row['operation']; + $id_agent_module[$key_row] = $row['id_agent_module']; + $agent_name[$key_row] = $ag_name; + $module_name[$key_row] = $mod_name; + $units[$key_row] = $unit; + $id_module_types[$key_row] = $id_module_type; + $operations[$key_row] = $row['operation']; break; case REPORT_GENERAL_GROUP_BY_AGENT: - $id_module_types[$index] = $id_module_type; - if ($id_module_types[$index] == 2 || $id_module_types[$index] == 6 || $id_module_types[$index] == 9 || $id_module_types[$index] == 18) { - $data_res[$index] = round($data_res[$index], 0, PHP_ROUND_HALF_DOWN); + $id_module_types[$key_row] = $id_module_type; + if ($id_module_types[$key_row] == 2 || $id_module_types[$key_row] == 6 || $id_module_types[$key_row] == 9 || $id_module_types[$key_row] == 18) { + $data_res[$key_row] = round($data_res[$key_row], 0, PHP_ROUND_HALF_DOWN); } - if ($id_module_types[$index] == 2 || $id_module_types[$index] == 6 || $id_module_types[$index] == 9 || $id_module_types[$index] == 18) { - if ($data_res[$index] == 1) { - $data_res[$index] = 'Up'; - } else if ($data_res[$index] == 0) { - $data_res[$index] = 'Down'; + if ($id_module_types[$key_row] == 2 || $id_module_types[$key_row] == 6 || $id_module_types[$key_row] == 9 || $id_module_types[$key_row] == 18) { + if ($data_res[$key_row] == 1) { + $data_res[$key_row] = 'Up'; + } else if ($data_res[$key_row] == 0) { + $data_res[$key_row] = 'Down'; } } - if ($data_res[$index] === false) { + if ($data_res[$key_row] === false) { $return['data'][$name_agent][$mod_name] = null; } else { - if (!is_numeric($data_res[$index])) { - $return['data'][$name_agent][$mod_name] = $data_res[$index]; + if (!is_numeric($data_res[$key_row])) { + $return['data'][$name_agent][$mod_name] = $data_res[$key_row]; } else { - $return['data'][$name_agent][$mod_name] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, ' '.$unit); + $return['data'][$name_agent][$mod_name] = format_for_graph($data_res[$key_row], 2, '.', ',', $divisor, ' '.$unit); } } break; } if ($content['style']['show_in_same_row']) { - foreach ($data_res[$index] as $val) { + foreach ($data_res[$key_row] as $val) { // Calculate the avg, min and max if (is_numeric($val)) { $change_min = false; - if (is_null($return['min']['value'])) { + if ($return['min']['value'] === null) { $change_min = true; } else { if ($return['min']['value'] > $val) { @@ -9593,7 +9834,7 @@ function reporting_general($report, $content) } $change_max = false; - if (is_null($return['max']['value'])) { + if ($return['max']['value'] === null) { $change_max = true; } else { if ($return['max']['value'] < $val) { @@ -9617,51 +9858,50 @@ function reporting_general($report, $content) } } else { // Calculate the avg, min and max - if (is_numeric($data_res[$index]) && !$is_string[$index]) { + if (is_numeric($data_res[$key_row]) && !$is_string[$key_row]) { $change_min = false; - if (is_null($return['min']['value'])) { + if ($return['min']['value'] === null) { $change_min = true; } else { - if ($return['min']['value'] > $data_res[$index]) { + if ($return['min']['value'] > $data_res[$key_row]) { $change_min = true; } } if ($change_min) { - $return['min']['value'] = $data_res[$index]; - $return['min']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, ' '.$unit); + $return['min']['value'] = $data_res[$key_row]; + $return['min']['formated_value'] = format_for_graph($data_res[$key_row], 2, '.', ',', $divisor, ' '.$unit); $return['min']['agent'] = $ag_name; $return['min']['module'] = $mod_name; } $change_max = false; - if (is_null($return['max']['value'])) { + if ($return['max']['value'] === null) { $change_max = true; } else { - if ($return['max']['value'] < $data_res[$index]) { + if ($return['max']['value'] < $data_res[$key_row]) { $change_max = true; } } if ($change_max) { - $return['max']['value'] = $data_res[$index]; - $return['max']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, ' '.$unit); + $return['max']['value'] = $data_res[$key_row]; + $return['max']['formated_value'] = format_for_graph($data_res[$key_row], 2, '.', ',', $divisor, ' '.$unit); $return['max']['agent'] = $ag_name; $return['max']['module'] = $mod_name; } if ($i == 0) { - $return['avg_value'] = $data_res[$index]; + $return['avg_value'] = $data_res[$key_row]; } else { - $return['avg_value'] = ((($return['avg_value'] * $i) / ($i + 1)) + ($data_res[$index] / ($i + 1))); + $return['avg_value'] = ((($return['avg_value'] * $i) / ($i + 1)) + ($data_res[$key_row] / ($i + 1))); } } } - $index++; $i++; - // Restore dbconnection + // Restore dbconnection. if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { metaconsole_restore_db(); } @@ -9719,20 +9959,19 @@ function reporting_general($report, $content) break; } - $i = 0; - foreach ($data_res as $d) { + foreach ($data_res as $d_key => $d) { $data = []; - $data['agent'] = $agent_name[$i]; - $data['module'] = $module_name[$i]; - $data['id_agent_module'] = $id_agent_module[$i]; - $data['id_agent'] = agents_get_agent_id_by_module_id($id_agent_module[$i]); - $data['id_module_type'] = $id_module_types[$i]; + $data['agent'] = $agent_name[$d_key]; + $data['module'] = $module_name[$d_key]; + $data['id_agent_module'] = $id_agent_module[$d_key]; + $data['id_agent'] = agents_get_agent_id_by_module_id($id_agent_module[$d_key]); + $data['id_module_type'] = $id_module_types[$d_key]; $data['operator'] = ''; if ($content['period'] != 0) { if ($content['style']['show_in_same_row']) { $data['operator'] = 'all'; } else { - switch ($operations[$i]) { + switch ($operations[$d_key]) { case 'sum': $data['operator'] = __('Summatory'); break; @@ -9758,28 +9997,16 @@ function reporting_general($report, $content) if ($val === false) { $data['value'][] = null; } else { - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - break; + $divisor = get_data_multiplier($units[$d_key]); - case 'oracle': - if (preg_match('/[0-9]+,[0-9]E+[+-][0-9]+/', $val)) { - $val = oracle_format_float_to_php($val); - } - break; - } - - $divisor = get_data_multiplier($units[$i]); - - if (!is_numeric($val) || $is_string[$i]) { + if (!is_numeric($val) || $is_string[$d_key]) { $data['value'][] = $val; // to see the chains on the table $data['formated_value'][] = $val; } else { $data['value'][] = $val; - $data['formated_value'][] = format_for_graph($val, 2, '.', ',', $divisor, ' '.$units[$i]); + $data['formated_value'][] = format_for_graph($val, 2, '.', ',', $divisor, ' '.$units[$d_key]); } } } @@ -9787,35 +10014,21 @@ function reporting_general($report, $content) if ($d === false) { $data['value'] = null; } else { - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - break; + $divisor = get_data_multiplier($units[$d_key]); - case 'oracle': - if (preg_match('/[0-9]+,[0-9]E+[+-][0-9]+/', $d)) { - $d = oracle_format_float_to_php($d); - } - break; - } - - $divisor = get_data_multiplier($units[$i]); - - if (!is_numeric($d) || $is_string[$i]) { + if (!is_numeric($d) || $is_string[$d_key]) { $data['value'] = $d; // to see the chains on the table $data['formated_value'] = $d; } else { $data['value'] = $d; - $data['formated_value'] = format_for_graph($d, 2, '.', ',', $divisor, ' '.$units[$i]); + $data['formated_value'] = format_for_graph($d, 2, '.', ',', $divisor, ' '.$units[$d_key]); } } } $return['data'][] = $data; - - $i++; } break; } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index a828e9d9d8..7cce81cd4d 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -961,8 +961,8 @@ function reporting_html_top_n($table, $item, $pdf=0) if ($pdf !== 0) { $return_pdf .= $item['charts']['pie']; } else { - $table->colspan['char_pie']['cell'] = 3; - $table->data['char_pie']['cell'] = $item['charts']['pie']; + $table->colspan['char_pie'][0] = 2; + $table->data['char_pie'][0] = $item['charts']['pie']; } } @@ -970,8 +970,8 @@ function reporting_html_top_n($table, $item, $pdf=0) if ($pdf !== 0) { $return_pdf .= $item['charts']['bars']; } else { - $table->colspan['char_bars']['cell'] = 3; - $table->data['char_bars']['cell'] = $item['charts']['bars']; + // $table->colspan['char_bars']['cell'] = 3; + $table->data['char_pie'][1] = $item['charts']['bars']; } } @@ -4815,6 +4815,7 @@ function reporting_html_general($table, $item, $pdf=0) } $list_modules = array_keys($list_modules); + $table1 = new stdClass(); $table1->width = '99%'; $table1->data = []; $table1->head = array_merge([__('Agent')], $list_modules); diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index bc0d48137f..cbf812d2bd 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -1440,13 +1440,17 @@ function snmp_browser_create_modules_snmp( /** * Prints html for create module from snmp massive dialog * - * @param string $url_form - * @param string $title - * @param boolean $return - * @return void + * @param string $target Target. + * @param string $snmp_conf Conf. + * @param boolean $return Type return. + * + * @return string Output html. */ -function snmp_browser_print_create_module_massive($target='agent', $snmp_conf, $return=false) -{ +function snmp_browser_print_create_module_massive( + $target='agent', + $snmp_conf='', + $return=false +) { global $config; // String for labels. @@ -1458,6 +1462,10 @@ function snmp_browser_print_create_module_massive($target='agent', $snmp_conf, $ case 'policy': $target_item = 'Policies'; break; + + default: + // Not possible. + break; } $output = ""; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 57abcee37d..d0e747e031 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3462,7 +3462,8 @@ function ui_print_datatable(array $parameters) $(document).ready(function(){ $.fn.dataTable.ext.errMode = "none"; $.fn.dataTable.ext.classes.sPageButton = "'.$pagination_class.'"; - dt_'.$table_id.' = $("#'.$table_id.'").DataTable({ + + var settings_datatable = { drawCallback: function(settings) {'; if (isset($parameters['drawCallback'])) { $js .= $parameters['drawCallback']; @@ -3608,7 +3609,9 @@ function ui_print_datatable(array $parameters) $js .= ' ], order: [[ '.$order.' ]] - }); + }; + + var dt_'.$table_id.' = $("#'.$table_id.'").DataTable(settings_datatable); $("#'.$form_id.'_search_bt").click(function (){ dt_'.$table_id.'.draw().page(0) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index fd01d5dad8..0ff126ed8a 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -2652,8 +2652,8 @@ function visual_map_process_wizard_add_modules( $image, $id_layout, $range, - $width=0, - $height=0, + $width, + $height, $period, $process_value, $percentileitem_width, @@ -2669,6 +2669,14 @@ function visual_map_process_wizard_add_modules( $fontf='lato', $fonts='12pt' ) { + if (empty($width) === true) { + $width = 0; + } + + if (empty($height) === true) { + $height = 0; + } + if (empty($id_modules)) { $return = ui_print_error_message( __('No modules selected'), @@ -2923,8 +2931,8 @@ function visual_map_process_wizard_add_agents( $image, $id_layout, $range, - $width=0, - $height=0, + $width, + $height, $period, $process_value, $percentileitem_width, @@ -2942,6 +2950,14 @@ function visual_map_process_wizard_add_agents( ) { global $config; + if (empty($width) === true) { + $width = 0; + } + + if (empty($height) === true) { + $height = 0; + } + if (empty($id_agents)) { $return = ui_print_error_message( __('No agents selected'), @@ -4171,8 +4187,14 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0) * * @return string The text for the parent. */ -function visual_map_create_internal_name_item($label=null, $type, $image, $agent=null, $id_module, $idData) -{ +function visual_map_create_internal_name_item( + $label=null, + $type='', + $image='', + $agent=null, + $id_module=0, + $idData='' +) { $text = ''; if (empty($label)) { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index df6792dccd..ae109ba20d 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -7490,6 +7490,11 @@ div.graph div.legend table { align-items: center; } +.flex_justify { + display: flex; + justify-content: center; +} + .span_priority { width: 20px; height: 10px; diff --git a/pandora_console/install.php b/pandora_console/install.php index b05a809879..4645561795 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@ 0) { } if ($total_agentes > 0) { - // Agents + // Agents. $total_agent_unknown = format_numeric((($agents_unknown * 100) / $total_agentes), 2); $total_agent_critical = format_numeric((($agents_critical * 100) / $total_agentes), 2); $total_agent_warning = format_numeric((($agents_warning * 100) / $total_agentes), 2); @@ -209,7 +209,7 @@ if ($count == 1) { ui_pagination($count); -if (!empty($result_groups)) { +if (empty($result_groups) === false) { echo ''; echo ''; echo ''; @@ -235,10 +235,17 @@ if (!empty($result_groups)) { echo ''; foreach ($result_groups as $data) { + if ((bool) $config['show_empty_groups'] === false + && $data['_total_agents_'] === 0 + && $data['_monitor_checks_'] === 0 + ) { + continue; + } + $groups_id = $data['_id_']; - // Calculate entire row color - if ($groups_id != 0) { + // Calculate entire row color. + if ($groups_id !== '0') { if ($data['_monitors_alerts_fired_'] > 0) { $color_class = 'group_view_alrm'; $status_image = ui_print_status_image('agent_alertsfired_ball.png', '', true); @@ -265,7 +272,7 @@ if (!empty($result_groups)) { echo ""; - // Force + // Force. echo ""; if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) { echo ''.html_print_image( diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index a6d141f82c..1ca059859d 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -2213,11 +2213,9 @@ try { $active_filters_div .= ''; $active_filters_div .= ''; - $table_id = 'events'; + $table_id = 'table_events'; $form_id = 'events_form'; - - // Print datatable. ui_print_datatable( [ diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 0a13ea8106..5e1c38896c 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.763 -%define release 220630 +%define release 220704 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 71bf62921d..8413b8d6c6 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.763 -%define release 220630 +%define release 220704 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 7f62381bc2..dc984d1e44 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.763 -%define release 220630 +%define release 220704 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_plugins/Log_event/getEvent.ps1 b/pandora_plugins/Log_event/getEvent.ps1 new file mode 100644 index 0000000000..19d4237421 --- /dev/null +++ b/pandora_plugins/Log_event/getEvent.ps1 @@ -0,0 +1,112 @@ +################################################################################ +# get Event +################################################################################ +# Copyright (c) 2020 Artica Soluciones Tecnologicas S.L +# Jose Antonio Almendros +################################################################################ +# +# usage: getEvent.exe -command "get_event.exe [event_source] [log_name] [interval] [*nodatalist] [*sendlog]" +# +################################################################################ + +param ( +[switch]$h = $false, +[switch]$nodatalist = $false, +[switch]$sendlog = $false +) + +if (($h -eq $true) -or ($($Args.Count) -le 2)){ + echo "Plugin to get events from the last N minutes" + echo "Usage:" + echo "getEvent.exe [event_source] [log_name] [interval] *[-nodatalist] *[-sendlog]`n" + echo "event_source:`t`tfield Source of the Event" + echo "log_name:`t`tfield Log Name of the Event" + echo "interval:`t`ttime interval from events will be extracted (in minutes)" + echo "nodatalist [optional]:`tshows all output in same module data" + echo "sendlog [optional]:`tsends logs to log server" + echo "Artica ST @ 2020" + exit +} + + +$source = $args[0] +$logname = $args[1] +$interval = $args[2] + + +if (($nodatalist -eq $false) -and ($sendlog -eq $false)) + { + $Logs = get-EventLog -Source $source -LogName $logname -After $((get-date).AddMinutes(-$interval)) | ft -HideTableHeaders + $result = foreach ($Log in $Logs) + { + + if ($Log) + { + echo "" + echo "`r`n" + } + + + } + + echo "" + echo "$source Events" + echo "async_string" + echo "" + echo $result + echo "" + echo "Logs with log name $logname in source $source" + echo "" + } + +else + { + if ($sendlog -eq $false) + { + $Logs = get-EventLog -Source $source -LogName $logname -After $((get-date).AddMinutes(-$interval)) | ft -HideTableHeaders | Out-String + $result = foreach ($Log in $Logs) + { + + echo $Log + echo "`r`n" + + + } + + echo "" + echo "$source Events" + echo "async_string" + echo "" + echo "Logs with log name $logname in source $source" + echo "" + } + } + +if ($sendlog -eq $true) + { + $Logs = get-EventLog -Source $source -LogName $logname -After $((get-date).AddMinutes(-$interval)) | ft -HideTableHeaders | Out-String + $result = foreach ($Log in $Logs) + { + + if ($Log) + { + echo "" + echo "`n" + } + + + } + + echo "" + echo "$source Events" + echo "" + echo $result + echo "" + echo "" + } \ No newline at end of file diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index c84deb8a9f..4749f1e5b7 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.763-220630 +Version: 7.0NG.763-220704 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index f748d78106..69be9ba3d8 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.763-220630" +pandora_version="7.0NG.763-220704" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 7e934dfe27..8fb3ed678f 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -46,7 +46,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.763"; -my $pandora_build = "220630"; +my $pandora_build = "220704"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 056ff7ea6b..73d4db6856 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.763"; -my $pandora_build = "220630"; +my $pandora_build = "220704"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 913992e354..5d6f7be51b 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.763 -%define release 220630 +%define release 220704 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 4b1578a5ae..fd988ec1a4 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.763 -%define release 220630 +%define release 220704 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 92f70012d0..2661d1c2ca 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.763" -PI_BUILD="220630" +PI_BUILD="220704" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index dc283f4a13..b3725bf40f 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.763 Build 220630"; +my $version = "7.0NG.763 Build 220704"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index f907ec4736..e287497f22 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.763 Build 220630"; +my $version = "7.0NG.763 Build 220704"; # save program name for logging my $progname = basename($0);