diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 71a5968824..5988473d93 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-220705 +Version: 7.0NG.763-220719 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 e1b837323c..9d3bc7ff6c 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-220705" +pandora_version="7.0NG.763-220719" 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 270f950492..6fc09ff6a8 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 => '220705'; +use constant AGENT_BUILD => '220719'; # 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 d691c2292d..5bfddc5249 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 220705 +%define release 220719 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 8ba0c9824a..61f6702752 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 220705 +%define release 220719 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 b0392882dd..c183977f88 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="220705" +PI_BUILD="220719" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 357f6b0e25..d1abe959a5 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220705} +{220719} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index c187f99683..dedf0a746e 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 220705") +#define PANDORA_VERSION ("7.0NG.763 Build 220719") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 1b6cb3b355..af1beace05 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 220705))" + VALUE "ProductVersion", "(7.0NG.763(Build 220719))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index bd409008fa..c02567ca10 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.763-220705 +Version: 7.0NG.763-220719 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 3c2339c7e8..409eaeb1f1 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-220705" +pandora_version="7.0NG.763-220719" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/56.sql b/pandora_console/extras/mr/56.sql index c197b0f169..da07b1612e 100644 --- a/pandora_console/extras/mr/56.sql +++ b/pandora_console/extras/mr/56.sql @@ -1,5 +1,43 @@ START TRANSACTION; +CREATE TABLE IF NOT EXISTS `tuser_task` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `function_name` VARCHAR(80) NOT NULL DEFAULT '', + `parameters` TEXT , + `name` VARCHAR(60) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + + +CREATE TABLE IF NOT EXISTS `tuser_task_scheduled` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0', + `id_user_task` INT UNSIGNED NOT NULL DEFAULT 0, + `args` TEXT, + `scheduled` ENUM('no','hourly','daily','weekly','monthly','yearly','custom') DEFAULT 'no', + `last_run` INT UNSIGNED DEFAULT 0, + `custom_data` INT NULL DEFAULT 0, + `flag_delete` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_grupo` INT UNSIGNED NOT NULL DEFAULT 0, + `enabled` TINYINT UNSIGNED NOT NULL DEFAULT 1, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tautoconfig` ADD COLUMN `type_execution` VARCHAR(100) NOT NULL DEFAULT 'start'; +ALTER TABLE `tautoconfig` ADD COLUMN `type_periodicity` VARCHAR(100) NOT NULL DEFAULT 'weekly'; +ALTER TABLE `tautoconfig` ADD COLUMN `monday` TINYINT DEFAULT 0; +ALTER TABLE `tautoconfig` ADD COLUMN `tuesday` TINYINT DEFAULT 0; +ALTER TABLE `tautoconfig` ADD COLUMN `wednesday` TINYINT DEFAULT 0; +ALTER TABLE `tautoconfig` ADD COLUMN `thursday` TINYINT DEFAULT 0; +ALTER TABLE `tautoconfig` ADD COLUMN `friday` TINYINT DEFAULT 0; +ALTER TABLE `tautoconfig` ADD COLUMN `saturday` TINYINT DEFAULT 0; +ALTER TABLE `tautoconfig` ADD COLUMN `sunday` TINYINT DEFAULT 0; +ALTER TABLE `tautoconfig` ADD COLUMN `periodically_day_from` INT UNSIGNED DEFAULT NULL; +ALTER TABLE `tautoconfig` ADD COLUMN `periodically_time_from` time NULL DEFAULT NULL; +ALTER TABLE `tautoconfig` ADD COLUMN `executed` TINYINT UNSIGNED NOT NULL DEFAULT 0; + +ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`; + ALTER TABLE `tevent_filter` ADD COLUMN `search_secondary_groups` INT NOT NULL DEFAULT 0; COMMIT; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 9b03dd3168..1337098126 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -526,7 +526,8 @@ $menu_godmode['links']['sub'] = $sub; // Warp Manager. if ((bool) check_acl($config['id_user'], 0, 'PM') === true && (bool) $config['enable_update_manager'] === true) { - $menu_godmode['messages']['text'] = __('Warp Update');; + $menu_godmode['messages']['text'] = __('Warp Update'); + ; $menu_godmode['messages']['id'] = 'god-um_messages'; $menu_godmode['messages']['sec2'] = ''; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 04a7e1126a..3ed36f8737 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -301,7 +301,6 @@ if ($new_user && $config['admin_can_add_user']) { if (enterprise_installed() && is_metaconsole() === true) { $user_info['metaconsole_agents_manager'] = 0; - $user_info['metaconsole_assigned_server'] = ''; $user_info['metaconsole_access_node'] = 0; } @@ -375,7 +374,6 @@ if ($create_user) { if (defined('METACONSOLE')) { $values['metaconsole_access'] = get_parameter('metaconsole_access', 'basic'); $values['metaconsole_agents_manager'] = ($user_is_admin == 1 ? 1 : get_parameter('metaconsole_agents_manager', '0')); - $values['metaconsole_assigned_server'] = get_parameter('metaconsole_assigned_server', ''); $values['metaconsole_access_node'] = ($user_is_admin == 1 ? 1 : get_parameter('metaconsole_access_node', '0')); } } @@ -588,7 +586,6 @@ if ($update_user) { if (enterprise_installed() && defined('METACONSOLE')) { $values['metaconsole_access'] = get_parameter('metaconsole_access'); $values['metaconsole_agents_manager'] = get_parameter('metaconsole_agents_manager', '0'); - $values['metaconsole_assigned_server'] = get_parameter('metaconsole_assigned_server', ''); $values['metaconsole_access_node'] = get_parameter('metaconsole_access_node', '0'); } @@ -1357,15 +1354,6 @@ if ($meta) { true ).''; - $metaconsole_assigned_server = '

'.__('Assigned node').ui_print_help_tip(__('Server where the agents created of this user will be placed'), true).'

'; - $servers = metaconsole_get_servers(); - $servers_for_select = []; - foreach ($servers as $server) { - $servers_for_select[$server['id']] = $server['server_name']; - } - - $metaconsole_assigned_server .= html_print_select($servers_for_select, 'metaconsole_assigned_server', $user_info['metaconsole_assigned_server'], '', '', -1, true, false, false).'
'; - $metaconsole_access_node = '

'.__('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true).'

'; $metaconsole_access_node .= html_print_checkbox( 'metaconsole_access_node', @@ -1416,7 +1404,7 @@ if (!is_metaconsole()) { '.$area_data_timezone_polys.$area_data_timezone_rects.'
'; } else { - echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_assigned_server.$metaconsole_access_node; + echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node; } echo ' @@ -1535,16 +1523,16 @@ $(document).ready (function () { }); $('#checkbox-is_admin').change(function() { - if($('#checkbox-is_admin').is(':checked') == true) { - $('#metaconsole_agents_manager_div').show(); - $('#metaconsole_access_node_div').show(); - if($('#checkbox-metaconsole_agents_manager').prop('checked')) { - $('#metaconsole_assigned_server_div').show(); - } - } else { + if ($('#checkbox-is_admin').is(':checked') == true) { $('#metaconsole_agents_manager_div').hide(); $('#metaconsole_access_node_div').hide(); $('#metaconsole_assigned_server_div').hide(); + } else { + $('#metaconsole_agents_manager_div').show(); + $('#metaconsole_access_node_div').show(); + if ($('#checkbox-metaconsole_agents_manager').prop('checked')) { + $('#metaconsole_assigned_server_div').show(); + } } }); diff --git a/pandora_console/images/alarm-off.png b/pandora_console/images/alarm-off.png new file mode 100644 index 0000000000..99f3895e0b Binary files /dev/null and b/pandora_console/images/alarm-off.png differ diff --git a/pandora_console/images/gear.png b/pandora_console/images/gear.png new file mode 100644 index 0000000000..e383f94e44 Binary files /dev/null and b/pandora_console/images/gear.png differ diff --git a/pandora_console/images/no-alerts-discovered.png b/pandora_console/images/no-alerts-discovered.png new file mode 100644 index 0000000000..ec9b9a88b1 Binary files /dev/null and b/pandora_console/images/no-alerts-discovered.png differ diff --git a/pandora_console/images/play-white.png b/pandora_console/images/play-white.png new file mode 100644 index 0000000000..2b9b1e93b2 Binary files /dev/null and b/pandora_console/images/play-white.png differ diff --git a/pandora_console/images/silence-alerts.png b/pandora_console/images/silence-alerts.png new file mode 100644 index 0000000000..22b1c95930 Binary files /dev/null and b/pandora_console/images/silence-alerts.png differ diff --git a/pandora_console/images/sound_wave.png b/pandora_console/images/sound_wave.png new file mode 100644 index 0000000000..d04c823de3 Binary files /dev/null and b/pandora_console/images/sound_wave.png differ diff --git a/pandora_console/images/stop.png b/pandora_console/images/stop.png new file mode 100644 index 0000000000..20903a0132 Binary files /dev/null and b/pandora_console/images/stop.png differ diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index f90988e383..df1bc50e3c 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -55,6 +55,7 @@ if (! check_acl($config['id_user'], 0, 'ER') return; } +$drawConsoleSound = (bool) get_parameter('drawConsoleSound', false); $process_buffers = (bool) get_parameter('process_buffers', false); $get_extended_event = (bool) get_parameter('get_extended_event'); $change_status = (bool) get_parameter('change_status'); @@ -2232,6 +2233,228 @@ if ($process_buffers === true) { return; } +if ($drawConsoleSound === true) { + echo ui_require_css_file('wizard', 'include/styles/', true); + echo ui_require_css_file('discovery', 'include/styles/', true); + echo ui_require_css_file('sound_events', 'include/styles/', true); + $output = '
'; + // Header tabs. + $output .= ''; + + // Content tabs. + $output .= '
'; + $output .= '

'; + $output .= __('Console configuration'); + $output .= '

'; + $inputs = []; + + // Load filter. + $fields = \events_get_event_filter_select(); + $inputs[] = [ + 'label' => \__('Set condition'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $fields, + 'name' => 'filter_id', + 'selected' => 0, + 'return' => true, + 'nothing' => \__('All new events'), + 'nothing_value' => 0, + 'class' => 'fullwidth', + ], + ]; + + $times_interval = [ + 10 => '10 '.__('seconds'), + 15 => '15 '.__('seconds'), + 30 => '30 '.__('seconds'), + 60 => '60 '.__('seconds'), + ]; + + $times_sound = [ + 2 => '2 '.__('seconds'), + 5 => '5 '.__('seconds'), + 10 => '10 '.__('seconds'), + 15 => '15 '.__('seconds'), + 30 => '30 '.__('seconds'), + 60 => '60 '.__('seconds'), + ]; + + $inputs[] = [ + 'class' => 'interval-sounds', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Interval'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $times_interval, + 'name' => 'interval', + 'selected' => 10, + 'return' => true, + ], + ], + [ + 'label' => __('Time Sound'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $times_sound, + 'name' => 'time_sound', + 'selected' => 10, + 'return' => true, + ], + ], + ], + ]; + + $sounds = [ + 'aircraftalarm.wav' => 'Air craft alarm', + 'air_shock_alarm.wav' => 'Air shock alarm', + 'alien_alarm.wav' => 'Alien alarm', + 'alien_beacon.wav' => 'Alien beacon', + 'bell_school_ringing.wav' => 'Bell school ringing', + 'Door_Alarm.wav' => 'Door alarm', + 'EAS_beep.wav' => 'EAS beep', + 'Firewarner.wav' => 'Fire warner', + 'HardPCMAlarm.wav' => 'Hard PCM Alarm', + 'negativebeep.wav' => 'Negative beep', + 'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation', + ]; + + $inputs[] = [ + 'class' => 'test-sounds', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => \__('Sound melody'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $sounds, + 'name' => 'sound_id', + 'selected' => 'Star_Trek_emergency_simulation.wav', + 'return' => true, + 'class' => 'fullwidth', + ], + ], + [ + 'arguments' => [ + 'type' => 'button', + 'name' => 'melody_sound', + 'label' => __('Test sound'), + 'attributes' => 'class="sub upd"', + 'return' => true, + ], + ], + ], + ]; + + // Print form. + $output .= HTML::printForm( + [ + 'form' => [ + 'action' => '', + 'method' => 'POST', + ], + 'inputs' => $inputs, + ], + true, + false + ); + $output .= '
'; + + $output .= '
'; + $output .= '

'; + $output .= __('Discovered alerts'); + $output .= '

'; + $output .= '
'; + $output .= html_print_image( + 'images/no-alerts-discovered.png', + true, + [ + 'title' => __('No alerts discovered'), + 'class' => 'invert_filter', + ] + ); + $output .= ''; + $output .= __('Congrats! there’s nothing to show'); + $output .= ''; + $output .= '
'; + $output .= '
    '; + $output .= '
    '; + $output .= '
    '; + + $output .= '
    '; + $output .= '
    '; + $output .= '
    '; + $output .= '
    '; + $output .= html_print_input( + [ + 'label' => __('Start'), + 'type' => 'button', + 'name' => 'start-search', + 'attributes' => 'class="sub play"', + 'return' => true, + ], + 'div', + true + ); + $output .= '
    '; + $output .= '
    '; + $output .= html_print_input( + [ + 'type' => 'button', + 'name' => 'no-alerts', + 'label' => __('No alerts'), + 'attributes' => 'class="sub alerts"', + 'return' => true, + ], + 'div', + true + ); + $output .= '
    '; + + $output .= html_print_input( + [ + 'type' => 'hidden', + 'name' => 'mode_alert', + 'value' => 0, + 'return' => true, + ], + 'div', + true + ); + $output .= '
    '; + $output .= '
    '; + + echo $output; + return; +} + if ($get_events_fired) { global $config; $filter_id = (int) get_parameter('filter_id', 0); diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index a0cfb1347d..801cf26a53 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -2483,14 +2483,12 @@ class ConsoleSupervisor SERVER_TYPE_ENTERPRISE_SATELLITE ) ); - $missed = 0; - if (is_array($server_version_list) === true) { foreach ($server_version_list as $server) { if (strpos( $server['version'], - (string) floor($config['current_package']) + (string) floor((int) $config['current_package']) ) === false ) { $missed++; diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index b9420eba44..4b3a9061cc 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -252,6 +252,7 @@ class TreeService extends Tree protected function getProcessedServices() { $is_favourite = $this->getServiceFavouriteFilter(); + $service_search = $this->getServiceNameSearchFilter(); if (users_can_manage_group_all('AR')) { $groups_acl = ''; @@ -259,6 +260,16 @@ class TreeService extends Tree $groups_acl = 'AND ts.id_group IN ('.implode(',', $this->userGroupsArray).')'; } + $exclude_children = 'ts.id NOT IN ( + SELECT DISTINCT id_service_child + FROM tservice_element + WHERE id_server_meta = 0 + )'; + + if ($service_search !== '') { + $exclude_children = '1=1'; + } + $sql = sprintf( 'SELECT ts.id, @@ -277,15 +288,14 @@ class TreeService extends Tree FROM tservice ts LEFT JOIN tservice_element tse ON tse.id_service = ts.id - WHERE ts.id NOT IN ( - SELECT DISTINCT id_service_child - FROM tservice_element - WHERE id_server_meta = 0 - ) + WHERE %s + %s %s %s GROUP BY ts.id', + $exclude_children, $is_favourite, + $service_search, $groups_acl ); @@ -722,6 +732,23 @@ class TreeService extends Tree } + /** + * Retrieve SQL filter for current filter + * + * @return string SQL filter. + */ + protected function getServiceNameSearchFilter() + { + if (isset($this->filter['searchService']) === true + && empty($this->filter['searchService']) === false + ) { + return " AND (ts.name LIKE '%".$this->filter['searchService']."%' OR ts.description LIKE '%".$this->filter['searchService']."%')"; + } + + return ''; + } + + /** * Overwrites partial functionality of general Tree.class. * diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 1e801edbf4..9ceda3b486 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 = 'PC220705'; +$build_version = 'PC220719'; $pandora_version = 'v7.0NG.763'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 8b18fe6417..6c27efe2e0 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2263,7 +2263,14 @@ function check_login($output=true) || (isset($_SESSION['merge-request-user-trick']) === true && $_SESSION['merge-request-user-trick'] === $_SESSION['id_usuario']) ) { - $config['id_user'] = $_SESSION['id_usuario']; + if (isset($config['auth']) === true && $config['auth'] === 'ad' && is_user($_SESSION['id_usuario'])) { + // User name in active directory is case insensitive. + // Get the user name from database. + $user_info = get_user_info($_SESSION['id_usuario']); + $config['id_user'] = $user_info['id_user']; + } else { + $config['id_user'] = $_SESSION['id_usuario']; + } return true; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 5b5d66c85f..3962538669 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4294,3 +4294,140 @@ function agents_get_offspring(int $id_agent) return $return; } + + +function agents_get_starmap(int $id_agent, float $width=0, float $height=0) +{ + ui_require_css_file('heatmap'); + + $all_modules = agents_get_modules($id_agent); + if (empty($all_modules)) { + return null; + } + + $total_modules = count($all_modules); + + // Best square. + $high = (float) max($width, $height); + $low = 0.0; + + while (abs($high - $low) > 0.000001) { + $mid = (($high + $low) / 2.0); + $midval = (floor($width / $mid) * floor($height / $mid)); + if ($midval >= $total_modules) { + $low = $mid; + } else { + $high = $mid; + } + } + + $square_length = min(($width / floor($width / $low)), ($height / floor($height / $low))); + + // Print starmap. + $html = sprintf( + '', + $id_agent, + $width, + $height + ); + + $html .= ''; + $row = 0; + $column = 0; + $x = 0; + $y = 0; + $cont = 1; + foreach ($all_modules as $key => $value) { + // Colour by status. + $status = modules_get_agentmodule_status($key); + switch ($status) { + case 0: + case 4: + case 300: + $status = 'normal'; + break; + + case 1: + case 100: + $status = 'critical'; + break; + + case 2: + case 200: + $status = 'warning'; + break; + + case 3: + $status = 'unknown'; + break; + + case 5: + $status = 'notinit'; + break; + } + + $html .= sprintf( + '', + 'rect_'.$cont, + $x, + $y, + $row, + $column, + $square_length, + $square_length, + $status, + random_int(1, 10) + ); + + $y += $square_length; + $row++; + if ((int) ($y + $square_length) > (int) $height) { + $y = 0; + $x += $square_length; + $row = 0; + $column++; + } + + if ((int) ($x + $square_length) > (int) $width) { + $x = 0; + $y += $square_length; + $column = 0; + $row++; + } + + $cont++; + } + ?> + + '; + $html .= ''; + + return $html; +} diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 2e36708cab..34b8b137d0 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1455,16 +1455,19 @@ function events_get_all( $group_selects = ''; if ($group_by != '') { if ($count === false) { - $group_selects = ',COUNT(id_evento) AS event_rep, - GROUP_CONCAT(DISTINCT user_comment SEPARATOR "
    ") AS comments, - MAX(utimestamp) as timestamp_last, - MIN(utimestamp) as timestamp_first, - MAX(id_evento) as max_id_evento'; - $idx = array_search('te.user_comment', $fields); if ($idx !== false) { unset($fields[$idx]); } + + $group_selects = sprintf( + ',COUNT(id_evento) AS event_rep, + %s + MAX(utimestamp) as timestamp_last, + MIN(utimestamp) as timestamp_first, + MAX(id_evento) as max_id_evento', + ($idx !== false) ? 'GROUP_CONCAT(DISTINCT user_comment SEPARATOR "
    ") AS comments,' : '' + ); } } else { $idx = array_search('te.user_comment', $fields); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 4f471f31f1..11012b96eb 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2558,7 +2558,8 @@ function combined_graph_summatory_average( function graphic_agentaccess( int $id_agent, int $period=0, - ?bool $return=false + ?bool $return=false, + ?bool $agent_view=false ) { global $config; @@ -2599,6 +2600,10 @@ function graphic_agentaccess( $options = []; $options['grid']['hoverable'] = true; + if ($agent_view === true) { + $options['agent_view'] = true; + } + if ($return === true) { return vbar_graph($data_array, $options, 1); } else { diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 94d329fb8e..b97e0398b6 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1013,13 +1013,17 @@ function html_print_select( if(count_shift_'.$id.' == 2 ){ if(shift_array_'.$id.'[0] <= shift_array_'.$id.'[1]) { for (var i = shift_array_'.$id.'[0]; i <= shift_array_'.$id.'[1]; i++) { - var option_value = $("#'.$id.' option").eq(i).val(); - options_selecteds_'.$id.'.push(option_value); + if ($("#'.$id.' option").eq(i).text().includes($(".select2-search__field").val()) == true) { + var option_value = $("#'.$id.' option").eq(i).val(); + options_selecteds_'.$id.'.push(option_value); + } } } else { for (var i = shift_array_'.$id.'[0]; i >= shift_array_'.$id.'[1]; i--) { - var option_value = $("#'.$id.' option").eq(i).val(); - options_selecteds_'.$id.'.push(option_value); + if ($("#'.$id.' option").eq(i).text().includes($(".select2-search__field").val()) == true) { + var option_value = $("#'.$id.' option").eq(i).val(); + options_selecteds_'.$id.'.push(option_value); + } } } @@ -6134,3 +6138,36 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) return $output; } + + +/** + * Prints a simple 'Go Back' button. + * + * @param string $url Destination Url. + * @param array $options Options. + * `button_class`: Class for button. 'w100p' by default. + * `title`: Title of the button. 'Go Back' by default. + * `action_class`: Class of icon of button. 'cancel' by default. + * @param boolean $return If true, return a formed HTML element. + * + * @return mixed + */ +function html_print_go_back_button(string $url, array $options=[], bool $return=false) +{ + $output = html_print_div( + [ + 'class' => ($options['button_class'] ?? 'w100p'), + 'content' => html_print_button( + ($options['title'] ?? __('Go back')), + 'go_back', + false, + 'window.location.href = \''.$url.'\'', + 'class="sub '.($options['action_class'] ?? ' cancel').' right"', + true + ), + ], + $return + ); + + return $output; +} diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 08936c170b..82451e1ac2 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -11121,7 +11121,7 @@ function reporting_get_group_stats($id_group=0, $access='AR', $recursion=true) * * @return array Group statistics */ -function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_permissions=false) +function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_permissions=false, $recursive=false) { global $config; @@ -11165,6 +11165,8 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per $id_group = array_keys( users_get_groups($config['id_user'], $access, false) ); + } else if ($recursive === true) { + $id_group = groups_get_children_ids($id_group); } // ----------------------------------------------------------------- @@ -11295,7 +11297,7 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per $group_stat = db_get_all_rows_sql($sql); $data = [ 'monitor_checks' => (int) $group_stat[0]['modules'], - 'monitor_alerts' => (int) groups_monitor_alerts($group_array), + 'monitor_alerts' => (int) groups_monitor_alerts($group_stat[0]['id_group']), 'monitor_alerts_fired' => (int) $group_stat[0]['alerts_fired'], 'monitor_alerts_fire_count' => (int) $group_stat[0]['alerts_fired'], 'monitor_ok' => (int) $group_stat[0]['normal'], @@ -11309,10 +11311,33 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per 'agent_warning' => (int) $group_stat[0]['agents_warnings'], 'agent_critical' => (int) $group_stat[0]['agents_critical'], 'total_checks' => (int) $group_stat[0]['modules'], - 'total_alerts' => (int) groups_monitor_alerts($group_array), + 'total_alerts' => (int) groups_monitor_alerts($group_stat[0]['id_group']), 'total_agents' => (int) $group_stat[0]['agents'], 'utimestamp' => (int) $group_stat[0]['utimestamp'], ]; + + if ($recursive === true) { + unset($group_stat[0]); + foreach ($group_stat as $value) { + $data['monitor_checks'] = ($data['monitor_checks'] + $value['modules']); + $data['monitor_alerts'] = ($data['monitor_alerts'] + groups_monitor_alerts($value['id_group'])); + $data['monitor_alerts_fired'] = ($data['monitor_alerts_fired'] + $value['alerts_fired']); + $data['monitor_alerts_fire_count'] = ($data['monitor_alerts_fire_count'] + $value['alerts_fired']); + $data['monitor_ok'] = ($data['monitor_ok'] + $value['normal']); + $data['monitor_warning'] = ($data['monitor_warning'] + $value['warning']); + $data['monitor_critical'] = ($data['monitor_critical'] + $value['critical']); + $data['monitor_unknown'] = ($data['monitor_unknown'] + $value['unknown']); + $data['monitor_not_init'] = ($data['monitor_not_init'] + $value['non-init']); + $data['agent_not_init'] = ($data['agent_not_init'] + $value['agents_not_init']); + $data['agent_unknown'] = ($data['agent_unknown'] + $value['agents_unknown']); + $data['agent_ok'] = ($data['agent_ok'] + $value['agents_normal']); + $data['agent_warning'] = ($data['agent_warning'] + $value['agents_warnings']); + $data['agent_critical'] = ($data['agent_critical'] + $value['agents_critical']); + $data['total_checks'] = ($data['total_checks'] + $value['modules']); + $data['total_alerts'] = ($data['total_alerts'] + groups_monitor_alerts($value['id_group'])); + $data['total_agents'] = ($data['total_agents'] + $value['agents']); + } + } } } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d0e747e031..6b6b446f7d 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3416,7 +3416,17 @@ function ui_print_datatable(array $parameters) } // Languages. - $processing = __('Processing'); + $processing = '
    '; + $processing .= ''.__('Processing').' '; + $processing .= str_replace( + '"', + "'", + html_print_image( + 'images/spinner.gif', + true + ) + ); + $processing .= '
    '; // Extra html. $extra = ''; @@ -3524,6 +3534,10 @@ function ui_print_datatable(array $parameters) url: "'.ui_get_full_url('ajax.php', false, false, false).'", type: "POST", dataSrc: function (json) { + if($("#'.$form_id.'_search_bt") != undefined) { + $("#'.$form_id.'_loading").remove(); + } + if (json.error) { console.error(json.error); $("#error-'.$table_id.'").html(json.error); @@ -3570,6 +3584,18 @@ function ui_print_datatable(array $parameters) } }, data: function (data) { + if($("#'.$form_id.'_search_bt") != undefined) { + var loading = \''.html_print_image( + 'images/spinner.gif', + true, + [ + 'id' => $form_id.'_loading', + 'class' => 'loading-search-datatables-button', + ] + ).'\'; + $("#'.$form_id.'_search_bt").parent().append(loading); + } + inputs = $("#'.$form_id.' :input"); values = {}; diff --git a/pandora_console/include/global_config.php b/pandora_console/include/global_config.php index d23c6994a6..b14c2b0ae5 100644 --- a/pandora_console/include/global_config.php +++ b/pandora_console/include/global_config.php @@ -1,5 +1,7 @@ $options['x']['font']['weight'], 'family' => $options['x']['font']['family'], 'variant' => $options['x']['font']['variant'], - 'color' => $options['x']['font']['color'], + 'color' => ($options['agent_view'] === true) ? 'black' : $options['x']['font']['color'], ], 'show' => $options['x']['show'], 'position' => $options['x']['position'], @@ -516,7 +516,7 @@ function vbar_graph( 'weight' => $options['y']['font']['weight'], 'family' => $options['y']['font']['family'], 'variant' => $options['y']['font']['variant'], - 'color' => $options['y']['font']['color'], + 'color' => ($options['agent_view'] === true) ? 'black' : $options['y']['font']['color'], ], 'show' => $options['y']['show'], 'position' => $options['y']['position'], @@ -534,8 +534,8 @@ function vbar_graph( 'aboveData' => $options['grid']['aboveData'], 'color' => $options['grid']['color'], 'backgroundColor' => $options['grid']['backgroundColor'], - 'margin' => $options['grid']['margin'], - 'labelMargin' => $options['grid']['labelMargin'], + 'margin' => ($options['agent_view'] === true) ? 6 : $options['grid']['margin'], + 'labelMargin' => ($options['agent_view'] === true) ? 12 : $options['grid']['labelMargin'], 'axisMargin' => $options['grid']['axisMargin'], 'markings' => $options['grid']['markings'], 'borderWidth' => $options['grid']['borderWidth'], @@ -561,6 +561,10 @@ function vbar_graph( ], ]; + if ($options['agent_view'] === true) { + $params['agent_view'] = true; + } + if (empty($params['data']) === true) { return graph_nodata_image( 0, diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 033382e5ea..8f5256e757 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -670,6 +670,10 @@ function flot_vcolumn_chart(array $options) $style .= 'height:'.$options['generals']['pdf']['height'].'px;'; } + if ($options['agent_view'] === true) { + $style = 'width: 95%; height: 85px'; + } + $class = ''; if ($options['generals']['rotate'] === true) { $class = 'bars-graph-rotate'; diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index d081cf7fca..896149b892 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -2869,7 +2869,7 @@ function donutNarrowGraph( arc = d3.svg .arc() .outerRadius(radius) - .innerRadius(radius - radius / 6); + .innerRadius(radius - radius / 4); svg = donutbody .append("svg") diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index ab276cda9e..b7f4170afa 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1,4 +1,4 @@ -/*global jQuery, $, forced_title_callback, confirmDialog*/ +/*global jQuery, $, forced_title_callback, confirmDialog, progressTimeBar*/ // Show the modal window of an event function show_event_dialog(event, dialog_page) { @@ -1028,3 +1028,256 @@ function process_buffers(buffers) { }); } } + +function openSoundEventModal(settings) { + settings = JSON.parse(atob(settings)); + + // Check modal exists and is open. + if ( + $("#modal-sound").hasClass("ui-dialog-content") && + $("#modal-sound").dialog("isOpen") + ) { + return; + } + + // Initialize modal. + $("#modal-sound") + .empty() + .dialog({ + title: settings.title, + resizable: false, + modal: true, + position: { my: "right top", at: "right bottom", of: window }, + overlay: { + opacity: 0.5, + background: "black" + }, + width: 600, + height: 600, + open: function() { + $.ajax({ + method: "post", + url: settings.url, + data: { + page: settings.page, + drawConsoleSound: 1 + }, + dataType: "html", + success: function(data) { + $("#modal-sound").append(data); + $("#tabs-sound-modal").tabs({ + disabled: [1] + }); + + // Test sound. + $("#button-melody_sound").click(function() { + var sound = false; + if ($("#id_sound_event").length == 0) { + sound = true; + } + + test_sound_button(sound); + }); + + // Play Stop. + $("#button-start-search").click(function() { + var mode = $("#hidden-mode_alert").val(); + var action = false; + if (mode == 0) { + action = true; + } + + action_events_sound(action, settings); + }); + + // Silence Alert. + $("#button-no-alerts").click(function() { + if ($("#button-no-alerts").hasClass("silence-alerts") === true) { + // Remove audio. + remove_audio(); + + // Clean events. + $("#tabs-sound-modal .elements-discovered-alerts ul").empty(); + $("#tabs-sound-modal .empty-discovered-alerts").removeClass( + "invisible_important" + ); + + // Clean progress. + $("#progressbar_time").empty(); + + // Change img button. + $("#button-no-alerts") + .removeClass("silence-alerts") + .addClass("alerts"); + // Change value button. + $("#button-no-alerts").val(settings.noAlert); + + // Background button. + $(".container-button-alert").removeClass("fired"); + + // New progress. + listen_event_sound(settings); + } + }); + }, + error: function(error) { + console.error(error); + } + }); + }, + close: function() { + remove_audio(); + $(this).dialog("destroy"); + } + }) + .show(); +} + +function test_sound_button(test_sound) { + if (test_sound === true) { + add_audio(); + } else { + remove_audio(); + } +} + +function action_events_sound(mode, settings) { + if (mode === true) { + // Enable tabs. + $("#tabs-sound-modal").tabs("option", "disabled", [0]); + // Active tabs. + $("#tabs-sound-modal").tabs("option", "active", 1); + // Change mode. + $("#hidden-mode_alert").val(1); + // Change img button. + $("#button-start-search") + .removeClass("play") + .addClass("stop"); + // Change value button. + $("#button-start-search").val(settings.stop); + // Add Progress bar. + listen_event_sound(settings); + } else { + // Enable tabs. + $("#tabs-sound-modal").tabs("option", "disabled", [1]); + // Active tabs. + $("#tabs-sound-modal").tabs("option", "active", 0); + // Change mode. + $("#hidden-mode_alert").val(0); + // Change img button. + $("#button-start-search") + .removeClass("stop") + .addClass("play"); + // Change value button. + $("#button-start-search").val(settings.start); + // Remove progress bar. + $("#progressbar_time").empty(); + // Remove audio. + remove_audio(); + // Clean events. + $("#tabs-sound-modal .elements-discovered-alerts ul").empty(); + $("#tabs-sound-modal .empty-discovered-alerts").removeClass( + "invisible_important" + ); + // Change img button. + $("#button-no-alerts") + .removeClass("silence-alerts") + .addClass("alerts"); + // Change value button. + $("#button-no-alerts").val(settings.noAlert); + + // Background button. + $(".container-button-alert").removeClass("fired"); + } +} + +function add_audio() { + var sound = "./include/sounds/" + $("#tabs-sound-modal #sound_id").val(); + $(".actions-sound-modal").append( + "