From a0b02670fb4028a5a6752463a5aceb4fa37b23ee Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 10:45:27 +0200 Subject: [PATCH 01/28] #11954 Fix pagination --- pandora_console/godmode/agentes/fields_manager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 25b06e2f5a..53b4995d20 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -217,6 +217,7 @@ foreach ($fields as $field) { array_push($table->data, $data); } +$tablePagination = ''; if ($fields) { html_print_table($table); $tablePagination = ui_pagination($count_fields, false, $offset, 0, true, 'offset', false); @@ -231,6 +232,9 @@ html_print_action_buttons( [ 'icon' => 'next' ], true ), - ['type' => 'form_action'] + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], ); echo ''; From eab6a00300d97a1ef5ab8da2097f14af712c90c4 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 10:49:59 +0200 Subject: [PATCH 02/28] #11945 Amend changes --- pandora_console/godmode/agentes/fields_manager.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 53b4995d20..25b06e2f5a 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -217,7 +217,6 @@ foreach ($fields as $field) { array_push($table->data, $data); } -$tablePagination = ''; if ($fields) { html_print_table($table); $tablePagination = ui_pagination($count_fields, false, $offset, 0, true, 'offset', false); @@ -232,9 +231,6 @@ html_print_action_buttons( [ 'icon' => 'next' ], true ), - [ - 'type' => 'form_action', - 'right_content' => $tablePagination, - ], + ['type' => 'form_action'] ); echo ''; From 9ae34fae404fa1bc7c324448cd67fc275cd92020 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 12:35:32 +0200 Subject: [PATCH 03/28] #11954 Fix delete alerts action in bulk --- .../godmode/massive/massive_delete_action_alerts.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/massive/massive_delete_action_alerts.php b/pandora_console/godmode/massive/massive_delete_action_alerts.php index cad37a3a29..0cd712e124 100644 --- a/pandora_console/godmode/massive/massive_delete_action_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_action_alerts.php @@ -111,7 +111,8 @@ if ($delete) { $alerts_agent_modules = []; foreach ($agent_alerts['simple'] as $agent_alert) { if ((in_array($agent_alert['id_alert_template'], $id_alert_templates)) && (in_array($agent_alert['id_agent_module'], $modules_id))) { - $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); + // $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); + $alerts_agent_modules[] = $agent_alert['id']; } } @@ -126,7 +127,7 @@ if ($delete) { $agent_module_actions = []; foreach ($alerts_agent_modules as $alert_agent_module) { - $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module['id'], ['id', 'id_alert_action']); + $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module, ['id', 'id_alert_action']); foreach ($agent_module_actions as $agent_module_action) { foreach ($actions as $action) { From 5328153dc3918bc8590e39160ab7045464a1b8ea Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 12 Sep 2023 14:19:15 +0200 Subject: [PATCH 04/28] #11494 Create widget class for service level --- pandora_console/include/functions.php | 26 +++++++++++++++---- .../include/lib/Dashboard/Widget.php | 4 +++ pandora_console/include/styles/dashboards.css | 5 ++++ .../include/styles/pandora_black.css | 5 ++++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 0895325ef5..0c031052e5 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -306,32 +306,48 @@ function format_for_graph( } -function human_milliseconds_to_string($seconds) +function human_milliseconds_to_string($seconds, $size_text='large') { $ret = ''; // get the days $days = intval(intval($seconds) / (360000 * 24)); if ($days > 0) { - $ret .= "$days days "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$days d").' '; + } else { + $ret .= "$days days "; + } } // get the hours $hours = ((intval($seconds) / 360000) % 24); if ($hours > 0) { - $ret .= "$hours hours "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$hours h").' '; + } else { + $ret .= "$hours hours "; + } } // get the minutes $minutes = ((intval($seconds) / 6000) % 60); if ($minutes > 0) { - $ret .= "$minutes minutes "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$minutes m").' '; + } else { + $ret .= "$minutes minutes "; + } } // get the seconds $seconds = ((intval($seconds) / 100) % 60); if ($seconds > 0) { - $ret .= "$seconds seconds"; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$seconds s").' '; + } else { + $ret .= "$seconds seconds "; + } } return $ret; diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 9bedc71f50..efc02d8c0e 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -444,6 +444,10 @@ class Widget $className .= '\HeatmapWidget'; break; + case 'service_level': + $className .= '\ServiceLevelWidget'; + break; + default: $className = false; break; diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 05ba550030..c012c925b1 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -279,6 +279,11 @@ li#div-textarea label { display: initial; } +.content-widget .container-top { + height: 100%; + width: 99%; +} + .widget-groups-status { display: flex; flex-direction: row; diff --git a/pandora_console/include/styles/pandora_black.css b/pandora_console/include/styles/pandora_black.css index 725a1c67d0..de9e125041 100644 --- a/pandora_console/include/styles/pandora_black.css +++ b/pandora_console/include/styles/pandora_black.css @@ -784,6 +784,11 @@ form ul.form_flex { width: 100%; } +.content-widget .container-top { + height: 100%; + width: 99%; +} + .container-layout { border-radius: 5px; border: 3px dashed #fff; From 7bbec73687d5b9f32bb46b51b2aa923b8e922713 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 12 Sep 2023 16:07:20 +0200 Subject: [PATCH 05/28] #11494 Service Lavel Widget Class --- .../lib/Dashboard/Widgets/service_level.php | 682 ++++++++++++++++++ 1 file changed, 682 insertions(+) create mode 100644 pandora_console/include/lib/Dashboard/Widgets/service_level.php diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_level.php b/pandora_console/include/lib/Dashboard/Widgets/service_level.php new file mode 100644 index 0000000000..2d570685b7 --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/service_level.php @@ -0,0 +1,682 @@ +width = $width; + + // Height. + $this->height = $height; + + // Grid Width. + $this->gridWidth = $gridWidth; + + // Options. + $this->values = $this->decoders($this->getOptionsWidget()); + + // Positions. + $this->position = $this->getPositionWidget(); + + // Page. + $this->page = basename(__FILE__); + + // ClassName. + $class = new \ReflectionClass($this); + $this->className = $class->getShortName(); + + // Title. + $this->title = __('Service Level Detail'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'service_level'; + } + + // This forces at least a first configuration. + $this->configurationRequired = false; + if (isset($this->values['mModules']) === false) { + $this->configurationRequired = true; + } + + $this->overflow_scrollbars = false; + } + + + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['interval']) === true) { + $values['interval'] = $decoder['interval']; + } else { + $values['interval'] = '28800'; + } + + if (isset($decoder['show_agents']) === true) { + $values['show_agents'] = $decoder['show_agents']; + } else { + $values['show_agents'] = '0'; + } + + if (isset($decoder['mTypeShow']) === true) { + $values['mTypeShow'] = $decoder['mTypeShow']; + } + + if (isset($decoder['mGroup']) === true) { + $values['mGroup'] = $decoder['mGroup']; + } + + if (isset($decoder['mRecursion']) === true) { + $values['mRecursion'] = $decoder['mRecursion']; + } + + if (isset($decoder['mModuleGroup']) === true) { + $values['mModuleGroup'] = $decoder['mModuleGroup']; + } + + if (isset($decoder['mAgents']) === true) { + $values['mAgents'] = $decoder['mAgents']; + } + + if (isset($decoder['mShowCommonModules']) === true) { + $values['mShowCommonModules'] = $decoder['mShowCommonModules']; + } + + if (isset($decoder['mModules']) === true) { + $values['mModules'] = $decoder['mModules']; + } + + return $values; + } + + + /** + * Generates inputs for form (specific). + * + * @return array Of inputs. + * + * @throws Exception On error. + */ + public function getFormInputs(): array + { + $values = $this->values; + + // Retrieve global - common inputs. + $inputs = parent::getFormInputs(); + + // Interval. + $fields = [ + '604800' => __('1 week'), + '172800' => __('48 hours'), + '86400' => __('24 hours'), + '43200' => __('12 hours'), + '28800' => __('8 hours'), + + ]; + + $inputs[] = [ + 'label' => __('Interval'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $fields, + 'name' => 'interval-'.$this->cellId, + 'selected' => $values['interval'], + 'return' => true, + ], + ]; + + // Show agent. + $inputs[] = [ + 'label' => __('Show agents'), + 'arguments' => [ + 'type' => 'switch', + 'name' => 'show_agents-'.$this->cellId, + 'value' => $values['show_agents'], + 'return' => true, + ], + ]; + + $return_all_group = false; + + if (users_can_manage_group_all('RM') || $this->values['mGroup'] == 0) { + $return_all_group = true; + } + + $mgroup = ''; + if (isset($this->values['mGroup']) === false) { + $sql = sprintf( + 'SELECT id_group FROM tdashboard WHERE id = %d', + $this->dashboardId + ); + + $group_dahsboard = db_get_value_sql($sql); + if ($group_dahsboard > 0) { + $mgroup = $group_dahsboard; + } + } + + if (is_metaconsole() === true) { + $this->values['mAgents'] = $this->getIdCacheAgent($this->values['mAgents']); + } + + $inputs[] = [ + 'class' => 'flex flex-row', + 'id' => 'select_multiple_modules_filtered', + 'arguments' => [ + 'type' => 'select_multiple_modules_filtered', + 'uniqId' => $this->cellId, + 'mGroup' => (isset($this->values['mGroup']) === true) ? $this->values['mGroup'] : $mgroup, + 'mRecursion' => (isset($this->values['mRecursion']) === true) ? $this->values['mRecursion'] : '', + 'mModuleGroup' => (isset($this->values['mModuleGroup']) === true) ? $this->values['mModuleGroup'] : '', + 'mAgents' => (isset($this->values['mAgents']) === true) ? $this->values['mAgents'] : '', + 'mShowCommonModules' => (isset($this->values['mShowCommonModules']) === true) ? $this->values['mShowCommonModules'] : '', + 'mModules' => (isset($this->values['mModules']) === true) ? $this->values['mModules'] : '', + 'mShowSelectedOtherGroups' => true, + 'mReturnAllGroup' => $return_all_group, + 'mMetaFields' => ((bool) is_metaconsole()), + 'commonModulesSwitch' => true, + ], + ]; + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost():array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + $values['interval'] = \get_parameter('interval-'.$this->cellId, '28800'); + + $values['show_agents'] = \get_parameter('show_agents-'.$this->cellId, '0'); + + $values['mTypeShow'] = \get_parameter( + 'filtered-type-show-'.$this->cellId + ); + + $values['mGroup'] = \get_parameter( + 'filtered-module-group-'.$this->cellId + ); + $values['mRecursion'] = \get_parameter_switch( + 'filtered-module-recursion-'.$this->cellId + ); + $values['mModuleGroup'] = \get_parameter( + 'filtered-module-module-group-'.$this->cellId + ); + $values['mAgents'] = \get_parameter( + 'filtered-module-agents-'.$this->cellId + ); + if (is_metaconsole() === true) { + $values['mAgents'] = $this->getRealIdAgentNode($values['mAgents']); + } + + $values['mShowCommonModules'] = \get_parameter( + 'filtered-module-show-common-modules-'.$this->cellId + ); + $values['mModules'] = explode( + ',', + \get_parameter( + 'filtered-module-modules-'.$this->cellId + ) + ); + + return $values; + } + + + /** + * Draw widget. + * + * @return string; + */ + public function load() + { + global $config; + + $output = ''; + if (check_acl($config['id_user'], 0, 'AR') === 0) { + $output .= '
'; + $output .= ui_print_error_message( + __('You don\'t have access'), + '', + true + ); + $output .= '
'; + return $output; + } + + $interval_range = []; + $current_timestamp = time(); + $interval_range['start'] = ($current_timestamp - $this->values['interval']); + $interval_range['end'] = $current_timestamp; + + $reduceAllModules = array_reduce( + $this->values['mModules'], + function ($carry, $item) { + if ($item === null) { + return $carry; + } + + if (is_metaconsole() === true) { + $item = explode('|', $item); + $serverId = $item[0]; + $fullname = $item[1]; + if ($this->values['mShowCommonModules'] !== 'on') { + $item = explode(' » ', $fullname); + $name = $item[1]; + $carry['modules_selected'][$serverId][$name] = null; + $carry['modules'][$name] = null; + } else { + $carry['modules'][$fullname] = null; + } + } else { + $carry['modules'][$item] = null; + } + + return $carry; + } + ); + + $allModules = $reduceAllModules['modules']; + $visualData = []; + // Extract info agents selected. + $target_agents = explode(',', $this->values['mAgents']); + foreach ($target_agents as $agent_id) { + try { + if (is_metaconsole() === true && str_contains($agent_id, '|') === true) { + $server_agent = explode('|', $agent_id); + } else { + $id_agente = $agent_id; + } + + if ((bool) is_metaconsole() === true) { + if (isset($server_agent) === true) { + $id_agente = $server_agent[1]; + $tserver = $server_agent[0]; + } else { + $tmeta_agent = db_get_row_filter( + 'tmetaconsole_agent', + [ 'id_agente' => $id_agente ] + ); + $id_agente = $tmeta_agent['id_tagente']; + $tserver = $tmeta_agent['id_tmetaconsole_setup']; + } + + if (metaconsole_connect(null, $tserver) !== NOERR) { + continue; + } + } + + $agent = new Agent((int) $id_agente); + $visualData[$agent_id]['agent_status'] = $agent->lastStatus(); + $visualData[$agent_id]['agent_name'] = $agent->name(); + $visualData[$agent_id]['agent_alias'] = $agent->alias(); + $visualData[$agent_id]['modules'] = []; + + if (empty($allModules) === false) { + if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') { + if (isset($reduceAllModules['modules_selected'][$tserver]) === true) { + $modules = $agent->searchModules( + ['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])] + ); + } else { + $modules = null; + } + } else { + $modules = $agent->searchModules( + ['nombre' => array_keys($allModules)] + ); + } + } + + $visualData[$agent_id]['modules'] = $allModules; + foreach ($modules as $module) { + if ($module === null) { + continue; + } + + $data_module_array = $module->toArray(); + $visualData[$agent_id]['modules'][$module->name()] = []; + $last_status = $module->getStatus()->toArray(); + $visualData[$agent_id]['modules'][$module->name()]['last_status_change'] = $last_status['last_status_change']; + + // Mean Time Between Failure. + // Mean Time To Solution. + // Availability. + $module_data = service_level_module_data($interval_range['start'], $interval_range['end'], $data_module_array['id_agente_modulo']); + if ($module_data['mtrs'] !== false && $module_data['mtbf'] !== false && $module_data['availability'] !== false) { + $visualData[$agent_id]['modules'][$module->name()]['mtrs'] = human_milliseconds_to_string(($module_data['mtrs'] * 100), 'short'); + $visualData[$agent_id]['modules'][$module->name()]['mtbf'] = human_milliseconds_to_string(($module_data['mtbf'] * 100), 'short'); + $visualData[$agent_id]['modules'][$module->name()]['availability'] = $module_data['availability']; + } else { + $visualData[$agent_id]['modules'][$module->name()]['mtrs'] = '-'; + $visualData[$agent_id]['modules'][$module->name()]['mtbf'] = '-'; + $visualData[$agent_id]['modules'][$module->name()]['availability'] = '100'; + } + + // Count events. + $sql = 'SELECT COUNT(*) as critical_events FROM tevento + WHERE id_agentmodule= '.$data_module_array['id_agente_modulo'].' + AND utimestamp >= '.$interval_range['start'].' + AND utimestamp <= '.$interval_range['end'].' + AND (event_type = "going_up_critical" OR event_type = "going_down_critical")'; + + $visualData[$agent_id]['modules'][$module->name()]['critical_events'] = db_get_sql($sql); + + $sql = 'SELECT COUNT(*) as critical_events FROM tevento + WHERE id_agentmodule= '.$data_module_array['id_agente_modulo'].' + AND utimestamp >= '.$interval_range['start'].' + AND utimestamp <= '.$interval_range['end'].' + AND (event_type = "going_up_warning" OR event_type = "going_down_warning")'; + + $visualData[$agent_id]['modules'][$module->name()]['warning_events'] = db_get_sql($sql); + } + + if ((bool) is_metaconsole() === true) { + metaconsole_restore_db(); + } + } catch (\Exception $e) { + echo 'Error: ['.$agent_id.']'.$e->getMessage(); + } + } + + $table = new \stdClass(); + + $table->width = '100%'; + $table->class = 'databox filters filter-table-adv'; + + $table->head = []; + $show_agents = $this->values['show_agents']; + if ($show_agents === 'on') { + $table->head[0] = __('Agent / Modules'); + } else { + $table->head[0] = __('Modules'); + } + + $table->head[1] = __('% Av.'); + $table->head[2] = __('MTBF'); + $table->head[3] = __('MTRS'); + $table->head[4] = __('Crit. Events'); + $table->head[5] = __('Warn. Events'); + $table->head[6] = __('Last change'); + $table->data = []; + $row = 0; + foreach ($visualData as $agent_id => $data) { + foreach ($data['modules'] as $module_name => $module_data) { + if (isset($module_data) === true) { + if ($show_agents === 'on') { + $table->data[$row][0] = $data['agent_alias'].' / '.$module_name; + } else { + $table->data[$row][0] = $module_name; + } + + $table->data[$row][1] = $module_data['availability'].'%'; + $table->data[$row][2] = $module_data['mtbf']; + $table->data[$row][3] = $module_data['mtrs']; + $table->data[$row][4] = $module_data['critical_events']; + $table->data[$row][5] = $module_data['warning_events']; + $table->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']); + $table->colspan[][0] = 0; + } + + $row++; + } + } + + $height = (count($table->data) * 32); + $style = 'min-width:400px; min-height:'.$height.'px;'; + $output = '
'; + $output .= html_print_table($table, true); + $output .= '
'; + + return $output; + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('Service Level Detail'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'service_level'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 800, + 'height' => 270, + ]; + + return $size; + } + + + /** + * Return array with the real id agent and server. + * + * @param string $id_agents_cache String with the agents cache id. + * + * @return string $agents_servers with the real id agent and server. + */ + public function getRealIdAgentNode($id_agents_cache) + { + $agents_servers = []; + $target_agents = explode(',', $id_agents_cache); + foreach ($target_agents as $agent_id) { + $id_agente = $agent_id; + $tmeta_agent = db_get_row_filter( + 'tmetaconsole_agent', + ['id_agente' => $id_agente] + ); + + $id_agente = $tmeta_agent['id_tagente']; + $tserver = $tmeta_agent['id_tmetaconsole_setup']; + $agents_servers[] = $tserver.'|'.$id_agente; + } + + return implode(',', $agents_servers); + } + + + /** + * Return string with the cache id agent in metaconsole. + * + * @param string $id_agents String with the agents and server id. + * + * @return string $cache_id_agents with the cache id agent. + */ + public function getIdCacheAgent($id_agents) + { + $target_agents = explode(',', $id_agents); + $cache_id_agents = []; + foreach ($target_agents as $agent_id) { + if (str_contains($agent_id, '|') === false) { + $cache_id_agents[] = $agent_id; + continue; + } + + $server_agent = explode('|', $agent_id); + $tmeta_agent = db_get_row_filter( + 'tmetaconsole_agent', + [ + 'id_tagente' => $server_agent[1], + 'id_tmetaconsole_setup' => $server_agent[0], + ] + ); + $cache_id_agents[] = $tmeta_agent['id_agente']; + } + + return implode(',', $cache_id_agents); + } + + +} From 3dff4c5083ce25cad4606133b5d967348d00fdd1 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 12 Sep 2023 16:09:02 +0200 Subject: [PATCH 06/28] #11494 create service leve module data function --- pandora_console/include/functions_modules.php | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index e82fca400b..fd8461156c 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4762,3 +4762,98 @@ function export_agents_module_csv($filters) return $result; } + + +/** + * Function to return Mean Time Between Failure, Mean Time To Solution (in seconds) + * and Availability of a module + * + * @param string $interval_start Start time of the interval. + * + * @param string $interval_end End time of the interval. + * + * @param string $id_agentmodule id_agentmodule of the module + * + * @return array Returns an array with the data + */ +function service_level_module_data($interval_start, $interval_end, $id_agentmodule) +{ + $data = []; + $data['mtbf'] = false; + $data['mtrs'] = false; + $data['availability'] = false; + + $interval_time = ($interval_end - $interval_start); + $current_time = time(); + $sql = 'SELECT utimestamp, event_type FROM tevento + WHERE id_agentmodule = '.$id_agentmodule.' + AND utimestamp >= '.$interval_start.' + AND utimestamp <= '.$interval_end.' + ORDER BY utimestamp DESC'; + + $events_time = db_get_all_rows_sql($sql); + if ($events_time !== false && count($events_time) > 0) { + $failed_event = []; + $normal_event = []; + foreach ($events_time as $event) { + if ($event['event_type'] === 'going_up_critical') { + $failed_event[] = $event['utimestamp']; + } + + if ($event['event_type'] === 'going_down_normal') { + $normal_event[] = $event['utimestamp']; + } + } + + $mtrs_array = []; + if (empty($normal_event) === true) { + $mtrs_array[] = ($current_time - $failed_event[0]); + } else if (empty($failed_event) === true) { + $mtrs_array[] = 0; + } else { + foreach ($normal_event as $key => $value) { + if (($failed_event[$key] - $normal_event[$key]) < 0) { + $mtrs_array[] = ($normal_event[$key] - $failed_event[$key]); + } else { + $mtrs_array[] = ($failed_event[$key] - $normal_event[$key]); + } + } + } + + $mtbf_array = []; + if (!empty($failed_event) === true) { + if (count($failed_event) > 1) { + for ($i = 1; $i <= array_key_last($failed_event); $i++) { + $mtbf_array[] = ($failed_event[($i - 1)] - $failed_event[$i]); + } + } else { + $mtbf_array[] = ($current_time - $failed_event[0]); + } + } else { + $mtbf_array[] = 0; + } + + $total_time_failed = array_sum($mtbf_array); + $total_time_ok = ($interval_time - $total_time_failed); + if (count($events_time) === 1) { + if ($events_time[0]['event_type'] === 'going_up_critical') { + $availability = '0'; + } + + if ($events_time[0]['event_type'] === 'going_down_normal') { + $availability = '100'; + } + } else { + $availability = round((($total_time_ok / $interval_time) * 100), 2); + } + + $mtbf = round(( $total_time_failed / count($mtbf_array))); + $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); + + $data['mtbf'] = $mtbf; + $data['mtrs'] = $mtrs; + $data['availability'] = $availability; + } + + return $data; +} From 1c996190f421032640809da0d53a48a6ff571565 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 13 Sep 2023 10:07:26 +0200 Subject: [PATCH 07/28] #11494 Fix service_level_module_data function --- pandora_console/include/functions_modules.php | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index fd8461156c..12d78ed969 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4776,19 +4776,37 @@ function export_agents_module_csv($filters) * * @return array Returns an array with the data */ -function service_level_module_data($interval_start, $interval_end, $id_agentmodule) +function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule) { $data = []; $data['mtbf'] = false; $data['mtrs'] = false; $data['availability'] = false; - $interval_time = ($interval_end - $interval_start); + $availability = 0; + + $uncompressed_data = db_uncompress_module_data( + $id_agentmodule, + $datetime_from, + $datetime_to + ); + + $first_utimestamp = 0; + foreach ($uncompressed_data as $data_module) { + foreach ($data_module['data'] as $subdata) { + if (!empty($subdata['datos'])) { + $first_utimestamp = $subdata['utimestamp']; + break; + } + } + } + + $interval_time = ($datetime_to - $datetime_from); $current_time = time(); $sql = 'SELECT utimestamp, event_type FROM tevento WHERE id_agentmodule = '.$id_agentmodule.' - AND utimestamp >= '.$interval_start.' - AND utimestamp <= '.$interval_end.' + AND utimestamp >= '.$datetime_from.' + AND utimestamp <= '.$datetime_to.' ORDER BY utimestamp DESC'; $events_time = db_get_all_rows_sql($sql); @@ -4836,17 +4854,14 @@ function service_level_module_data($interval_start, $interval_end, $id_agentmodu $total_time_failed = array_sum($mtbf_array); $total_time_ok = ($interval_time - $total_time_failed); if (count($events_time) === 1) { - if ($events_time[0]['event_type'] === 'going_up_critical') { - $availability = '0'; - } - - if ($events_time[0]['event_type'] === 'going_down_normal') { - $availability = '100'; + if ((string) $first_utimestamp !== '0') { + $availability = round((($total_time_ok / $interval_time) * 100), 2); } } else { $availability = round((($total_time_ok / $interval_time) * 100), 2); } + // hd($availability, true); $mtbf = round(( $total_time_failed / count($mtbf_array))); $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); From 0140183ae4f3a299302d892d0391da0e27932bd0 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 13 Sep 2023 10:15:34 +0200 Subject: [PATCH 08/28] #11494 Fix service level function and add widget icon --- pandora_console/images/widgets/service_level.png | Bin 0 -> 5801 bytes pandora_console/include/functions_modules.php | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 pandora_console/images/widgets/service_level.png diff --git a/pandora_console/images/widgets/service_level.png b/pandora_console/images/widgets/service_level.png new file mode 100644 index 0000000000000000000000000000000000000000..685744641f803c8408df788dd1d679f5191d6d92 GIT binary patch literal 5801 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 literal 0 HcmV?d00001 diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 12d78ed969..410cc036f7 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4768,9 +4768,9 @@ function export_agents_module_csv($filters) * Function to return Mean Time Between Failure, Mean Time To Solution (in seconds) * and Availability of a module * - * @param string $interval_start Start time of the interval. + * @param string $datetime_from Start time of the interval. * - * @param string $interval_end End time of the interval. + * @param string $datetime_to End time of the interval. * * @param string $id_agentmodule id_agentmodule of the module * From 750b318a2e012f9e96de748a0054ee687d46f5b9 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 13 Sep 2023 11:38:30 +0200 Subject: [PATCH 09/28] #11494 Fix service level detail function --- pandora_console/include/functions_modules.php | 20 +++++++++++++++++-- .../lib/Dashboard/Widgets/service_level.php | 17 +++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 410cc036f7..07690151e4 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4784,6 +4784,7 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $data['availability'] = false; $availability = 0; + $type = ''; $uncompressed_data = db_uncompress_module_data( $id_agentmodule, @@ -4796,6 +4797,10 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule foreach ($data_module['data'] as $subdata) { if (!empty($subdata['datos'])) { $first_utimestamp = $subdata['utimestamp']; + if (isset($subdata['type'])) { + $type = $subdata['type']; + } + break; } } @@ -4862,8 +4867,19 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule } // hd($availability, true); - $mtbf = round(( $total_time_failed / count($mtbf_array))); - $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); + if (count($mtbf_array) > 1) { + $mtbf = round(( $total_time_failed / count($mtbf_array))); + } else { + $mtbf = false; + } + + if (count($mtrs_array) === 1 && (string) $first_utimestamp !== '0' && $type === 0) { + $mtrs = round($total_time_failed / count($mtrs_array)); + } else if (count($mtrs_array) > 1 && (string) $first_utimestamp !== '0') { + $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); + } else { + $mtrs = false; + } $data['mtbf'] = $mtbf; $data['mtrs'] = $mtrs; diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_level.php b/pandora_console/include/lib/Dashboard/Widgets/service_level.php index 2d570685b7..5758e99cec 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_level.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_level.php @@ -1,10 +1,10 @@ name()]['mtrs'] = human_milliseconds_to_string(($module_data['mtrs'] * 100), 'short'); - $visualData[$agent_id]['modules'][$module->name()]['mtbf'] = human_milliseconds_to_string(($module_data['mtbf'] * 100), 'short'); - $visualData[$agent_id]['modules'][$module->name()]['availability'] = $module_data['availability']; - } else { - $visualData[$agent_id]['modules'][$module->name()]['mtrs'] = '-'; - $visualData[$agent_id]['modules'][$module->name()]['mtbf'] = '-'; - $visualData[$agent_id]['modules'][$module->name()]['availability'] = '100'; - } - + $visualData[$agent_id]['modules'][$module->name()]['mtrs'] = ($module_data['mtrs'] !== false) ? human_milliseconds_to_string(($module_data['mtrs'] * 100), 'short') : '-'; + $visualData[$agent_id]['modules'][$module->name()]['mtbf'] = ($module_data['mtbf'] !== false) ? human_milliseconds_to_string(($module_data['mtbf'] * 100), 'short') : '-'; + $visualData[$agent_id]['modules'][$module->name()]['availability'] = ($module_data['availability'] !== false) ? $module_data['availability'] : '100'; // Count events. $sql = 'SELECT COUNT(*) as critical_events FROM tevento WHERE id_agentmodule= '.$data_module_array['id_agente_modulo'].' From e727ea402b10e1f043768f5440a96a3dfe954d62 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 14 Sep 2023 15:28:54 +0200 Subject: [PATCH 10/28] #11494 Fix widget in metaconsole --- pandora_console/include/functions_modules.php | 77 ++++++++++++++++++- .../lib/Dashboard/Widgets/service_level.php | 38 ++++----- 2 files changed, 89 insertions(+), 26 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 07690151e4..aa179c03fc 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4782,9 +4782,27 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $data['mtbf'] = false; $data['mtrs'] = false; $data['availability'] = false; + $data['critical_events'] = false; + $data['warning_events'] = false; + $data['last_status_change'] = false; + $data['module_name'] = false; $availability = 0; $type = ''; + if ((bool) is_metaconsole() === true) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_id = []; + $server_id['id'] = explode('|', $id_agentmodule)[0]; + $id_agentmodule = explode('|', $id_agentmodule)[1]; + $server_name = db_get_row_filter('tmetaconsole_setup', $server_id, 'server_name'); + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + // Restore db connection. + metaconsole_restore_db(); + return $data; + } + } + } $uncompressed_data = db_uncompress_module_data( $id_agentmodule, @@ -4815,6 +4833,24 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule ORDER BY utimestamp DESC'; $events_time = db_get_all_rows_sql($sql); + + // Count events. + $sql = 'SELECT COUNT(*) as critical_events FROM tevento + WHERE id_agentmodule= '.$id_agentmodule.' + AND utimestamp >= '.$datetime_from.' + AND utimestamp <= '.$datetime_to.' + AND (event_type = "going_up_critical" OR event_type = "going_down_critical")'; + + $critical_events = db_get_sql($sql); + + $sql = 'SELECT COUNT(*) as warning_events FROM tevento + WHERE id_agentmodule= '.$id_agentmodule.' + AND utimestamp >= '.$datetime_from.' + AND utimestamp <= '.$datetime_to.' + AND (event_type = "going_up_warning" OR event_type = "going_down_warning")'; + + $warning_events = db_get_sql($sql); + if ($events_time !== false && count($events_time) > 0) { $failed_event = []; $normal_event = []; @@ -4844,6 +4880,7 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule } $mtbf_array = []; + if (!empty($failed_event) === true) { if (count($failed_event) > 1) { for ($i = 1; $i <= array_key_last($failed_event); $i++) { @@ -4866,9 +4903,8 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $availability = round((($total_time_ok / $interval_time) * 100), 2); } - // hd($availability, true); - if (count($mtbf_array) > 1) { - $mtbf = round(( $total_time_failed / count($mtbf_array))); + if ($critical_events > 1) { + $mtbf = round(( $total_time_failed / $critical_events)); } else { $mtbf = false; } @@ -4884,6 +4920,41 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $data['mtbf'] = $mtbf; $data['mtrs'] = $mtrs; $data['availability'] = $availability; + } else { + $data['mtbf'] = false; + $data['mtrs'] = false; + $data['availability'] = false; + } + + // Get last status change. + $sql = 'SELECT last_status_change FROM tagente_estado + WHERE id_agente_modulo = '.$id_agentmodule.' '; + + $last_status_change = db_get_sql($sql); + + // Get module name. + /* + $sql = 'SELECT nombre FROM tagente_modulo + WHERE id_agente_modulo = '.$id_agentmodule;*/ + + $sql = 'SELECT tagente_modulo.nombre as nombre, tagente.alias as alias + FROM tagente_modulo INNER JOIN tagente + ON tagente_modulo.id_agente = tagente.id_agente + WHERE id_agente_modulo = '.$id_agentmodule.' '; + $sql_query = db_get_all_rows_sql($sql); + + $data['critical_events'] = $critical_events; + $data['warning_events'] = $warning_events; + $data['last_status_change'] = $last_status_change; + $data['module_name'] = $sql_query[0]['nombre']; + if ((bool) is_metaconsole() === true) { + $data['agent_alias'] = $server_name['server_name'].' » '.$sql_query[0]['alias']; + } else { + $data['agent_alias'] = $sql_query[0]['alias']; + } + + if ((bool) is_metaconsole() === true) { + metaconsole_restore_db(); } return $data; diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_level.php b/pandora_console/include/lib/Dashboard/Widgets/service_level.php index 5758e99cec..4697f8459f 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_level.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_level.php @@ -461,7 +461,6 @@ class ServiceLevelWidget extends Widget $visualData[$agent_id]['agent_name'] = $agent->name(); $visualData[$agent_id]['agent_alias'] = $agent->alias(); $visualData[$agent_id]['modules'] = []; - if (empty($allModules) === false) { if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') { if (isset($reduceAllModules['modules_selected'][$tserver]) === true) { @@ -479,6 +478,11 @@ class ServiceLevelWidget extends Widget } $visualData[$agent_id]['modules'] = $allModules; + + if ((bool) is_metaconsole() === true) { + metaconsole_restore_db(); + } + foreach ($modules as $module) { if ($module === null) { continue; @@ -492,30 +496,19 @@ class ServiceLevelWidget extends Widget // Mean Time Between Failure. // Mean Time To Solution. // Availability. - $module_data = service_level_module_data($interval_range['start'], $interval_range['end'], $data_module_array['id_agente_modulo']); + if ((bool) is_metaconsole() === true) { + $module_id = $tserver.'|'.$data_module_array['id_agente_modulo']; + } else { + $module_id = $data_module_array['id_agente_modulo']; + } + + $module_data = service_level_module_data($interval_range['start'], $interval_range['end'], $module_id); $visualData[$agent_id]['modules'][$module->name()]['mtrs'] = ($module_data['mtrs'] !== false) ? human_milliseconds_to_string(($module_data['mtrs'] * 100), 'short') : '-'; $visualData[$agent_id]['modules'][$module->name()]['mtbf'] = ($module_data['mtbf'] !== false) ? human_milliseconds_to_string(($module_data['mtbf'] * 100), 'short') : '-'; $visualData[$agent_id]['modules'][$module->name()]['availability'] = ($module_data['availability'] !== false) ? $module_data['availability'] : '100'; - // Count events. - $sql = 'SELECT COUNT(*) as critical_events FROM tevento - WHERE id_agentmodule= '.$data_module_array['id_agente_modulo'].' - AND utimestamp >= '.$interval_range['start'].' - AND utimestamp <= '.$interval_range['end'].' - AND (event_type = "going_up_critical" OR event_type = "going_down_critical")'; - - $visualData[$agent_id]['modules'][$module->name()]['critical_events'] = db_get_sql($sql); - - $sql = 'SELECT COUNT(*) as critical_events FROM tevento - WHERE id_agentmodule= '.$data_module_array['id_agente_modulo'].' - AND utimestamp >= '.$interval_range['start'].' - AND utimestamp <= '.$interval_range['end'].' - AND (event_type = "going_up_warning" OR event_type = "going_down_warning")'; - - $visualData[$agent_id]['modules'][$module->name()]['warning_events'] = db_get_sql($sql); - } - - if ((bool) is_metaconsole() === true) { - metaconsole_restore_db(); + $visualData[$agent_id]['modules'][$module->name()]['critical_events'] = ($module_data['critical_events'] !== false) ? $module_data['critical_events'] : ''; + $visualData[$agent_id]['modules'][$module->name()]['warning_events'] = ($module_data['critical_events'] !== false) ? $module_data['critical_events'] : ''; + $visualData[$agent_id]['modules'][$module->name()]['last_status_change'] = ($module_data['last_status_change'] !== false) ? $module_data['last_status_change'] : ''; } } catch (\Exception $e) { echo 'Error: ['.$agent_id.']'.$e->getMessage(); @@ -558,7 +551,6 @@ class ServiceLevelWidget extends Widget $table->data[$row][4] = $module_data['critical_events']; $table->data[$row][5] = $module_data['warning_events']; $table->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']); - $table->colspan[][0] = 0; } $row++; From 0eab85abd0a99415e596dc268f59cb7033ece9f8 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 14 Sep 2023 15:34:59 +0200 Subject: [PATCH 11/28] #11494 Fix widget in metaconsole --- .../include/lib/Dashboard/Widgets/service_level.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_level.php b/pandora_console/include/lib/Dashboard/Widgets/service_level.php index 4697f8459f..b63ff36518 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_level.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_level.php @@ -507,8 +507,10 @@ class ServiceLevelWidget extends Widget $visualData[$agent_id]['modules'][$module->name()]['mtbf'] = ($module_data['mtbf'] !== false) ? human_milliseconds_to_string(($module_data['mtbf'] * 100), 'short') : '-'; $visualData[$agent_id]['modules'][$module->name()]['availability'] = ($module_data['availability'] !== false) ? $module_data['availability'] : '100'; $visualData[$agent_id]['modules'][$module->name()]['critical_events'] = ($module_data['critical_events'] !== false) ? $module_data['critical_events'] : ''; - $visualData[$agent_id]['modules'][$module->name()]['warning_events'] = ($module_data['critical_events'] !== false) ? $module_data['critical_events'] : ''; + $visualData[$agent_id]['modules'][$module->name()]['warning_events'] = ($module_data['warning_events'] !== false) ? $module_data['warning_events'] : ''; $visualData[$agent_id]['modules'][$module->name()]['last_status_change'] = ($module_data['last_status_change'] !== false) ? $module_data['last_status_change'] : ''; + $visualData[$agent_id]['modules'][$module->name()]['agent_alias'] = ($module_data['agent_alias'] !== false) ? $module_data['agent_alias'] : ''; + $visualData[$agent_id]['modules'][$module->name()]['module_name'] = ($module_data['module_name'] !== false) ? $module_data['module_name'] : ''; } } catch (\Exception $e) { echo 'Error: ['.$agent_id.']'.$e->getMessage(); @@ -540,9 +542,9 @@ class ServiceLevelWidget extends Widget foreach ($data['modules'] as $module_name => $module_data) { if (isset($module_data) === true) { if ($show_agents === 'on') { - $table->data[$row][0] = $data['agent_alias'].' / '.$module_name; + $table->data[$row][0] = $module_data['agent_alias'].' / '.$module_data['module_name']; } else { - $table->data[$row][0] = $module_name; + $table->data[$row][0] = $module_data['module_name']; } $table->data[$row][1] = $module_data['availability'].'%'; From 073639e100607741d26f919c21f529a0a935a119 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 2 Oct 2023 09:51:11 +0200 Subject: [PATCH 12/28] #12150 add log www-error.log --- pandora_console/extensions/pandora_logs.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/extensions/pandora_logs.php b/pandora_console/extensions/pandora_logs.php index e63b719cfe..202000e0bf 100644 --- a/pandora_console/extensions/pandora_logs.php +++ b/pandora_console/extensions/pandora_logs.php @@ -31,7 +31,7 @@ function view_logfile($file_name, $toggle=false) } else { $file_size = filesize($file_name); - if ($memory_limit < $file_size) { + if ($memory_limit < $file_size && $memory_limit !== '-1') { $code .= '

'.$file_name.' ('.__('File is too large than PHP memory allocated in the system.').')

'; $code .= '

'.__('The preview file is imposible.').'

'; } else if ($file_size > ($config['max_log_size'] * 1000)) { @@ -117,6 +117,7 @@ function pandoralogs_extension_main() view_logfile($config['homedir'].'/log/console.log', true); } + view_logfile('/var/log/php-fpm/www-error.log', true); view_logfile($logs_directory.'/pandora_server.log', true); view_logfile($logs_directory.'/pandora_server.error', true); From 172fd835476b4a6fb8751701e01f60474560cb52 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 16 Oct 2023 15:18:04 +0200 Subject: [PATCH 13/28] #11846 change list elements update post json --- .../visual_console_builder.elements.php | 88 +++++++++++++-- .../reporting/visual_console_builder.php | 105 ++++++++++++++++++ 2 files changed, 181 insertions(+), 12 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index 300ea33f40..c4f83e2d02 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -539,6 +539,7 @@ foreach ($layoutDatas as $layoutData) { $table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true); $table->data[($i + 1)][5] .= ''.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).''; $table->data[($i + 1)][5] .= html_print_input_hidden('updated_'.$idLayoutData, '0', true); + $table->data[($i + 1)][5] .= html_print_input_hidden('rowtype_'.$idLayoutData, $layoutData['type'], true); // Second row $table->data[($i + 2)]['icon'] = ''; @@ -789,14 +790,6 @@ if ($x > ini_get('max_input_vars')) { $pure = get_parameter('pure', 0); -if (is_metaconsole() === false) { - echo '
'; - html_print_input_hidden('action', 'update'); -} else { - echo ""; - html_print_input_hidden('action2', 'update'); -} - html_print_table($table); // Form for multiple delete. @@ -806,15 +799,14 @@ if (is_metaconsole() === false) { $url_multiple_delete = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&tab='.$activeTab.'&id_visual_console='.$visualConsole['id']; } -echo '
'; - $buttons = html_print_submit_button( __('Update'), 'go', false, [ - 'icon' => 'next', - 'form' => 'vc_elem_form', + 'icon' => 'next', + 'form' => 'vc_elem_form', + 'onclick' => 'submit_update_json()', ], true ); @@ -976,4 +968,76 @@ ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/'); return false; } + + function submit_update_json() { + var array_update = []; + $('input[id^=hidden-updated_]').each(function(){ + var id = $(this).attr('id').split('_')[1]; + + var label = $('#hidden-label_'+id).val(); + var image = $('#image_'+id).val(); + var width = $('#text-width_'+id).val(); + var height = $('#text-height_'+id).val(); + var pos_x = $('#text-left_'+id).val(); + var pos_y = $('#text-top_'+id).val(); + var parent = $('#parent_'+id).val(); + var agent = $('#hidden-agent_'+id).val(); + var module = $('#module_'+id).val(); + var period = $('#hidden-period_'+id).val(); + var map_linked = $('#map_linked_'+id).val(); + var id_server = $('#id_server_id_'+id).val(); + var rowtype = $('rowtype_'+id).val(); + var custom_graph = $('#custom_graph_'+id).val(); + + array_update.push({ + 'id': id, + 'label': label, + 'image': image, + 'width': width, + 'height': height, + 'pos_x': pos_x, + 'pos_y': pos_y, + 'parent': parent, + 'agent': agent, + 'module': module, + 'period': period, + 'map_linked': map_linked, + 'rowtype': rowtype, + 'custom_graph': custom_graph, + 'id_server': id_server, + }); + }); + + var background_width = $('#text-width').val(); + var background_height = $('#text-height').val(); + + if (background_height > 0 && background_width > 0){ + $.ajax({ + type: "POST", + url: "ajax.php", + data: { + page: "godmode/reporting/visual_console_builder", + action: "update_json", + tab: "list_elements", + array_update: JSON.stringify(array_update), + id_visual_console: "", + background: $('#background').val(), + background_width: $('#text-width').val(), + background_height: $('#text-height').val(), + }, + dataType: "json", + complete: function (data) { + location.reload(); + } + }); + } else { + confirmDialog({ + title: "", + message: "", + strOKButton: "", + hideCancelButton: true, + size: 300, + }); + } + } diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 986dcb423b..fc043228ed 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -78,6 +78,7 @@ $action = get_parameterBetweenListValues( 'update', 'delete', 'multiple_delete', + 'update_json', ], 'new' ); @@ -523,6 +524,110 @@ switch ($activeTab) { } break; + case 'update_json': + // Update background. + $background = get_parameter('background'); + $width = get_parameter('background_width'); + $height = get_parameter('background_height'); + + if ($width == 0 && $height == 0) { + $sizeBackground = getimagesize( + $config['homedir'].'/images/console/background/'.$background + ); + $width = $sizeBackground[0]; + $height = $sizeBackground[1]; + } + + db_process_sql_update( + 'tlayout', + [ + 'background' => $background, + 'width' => $width, + 'height' => $height, + ], + ['id' => $idVisualConsole] + ); + + // Return the updated visual console. + $visualConsole = db_get_row_filter( + 'tlayout', + ['id' => $idVisualConsole] + ); + + // Update elements in visual map. + $idsElements = db_get_all_rows_filter( + 'tlayout_data', + ['id_layout' => $idVisualConsole], + [ + 'id', + 'type', + ] + ); + + $array_update = json_decode(io_safe_output(get_parameter('array_update')), true); + + if (count($array_update)) { + foreach ($array_update as $row) { + $id = $row['id']; + $values = []; + $values['label'] = $row['label']; + $values['image'] = $row['image']; + $values['width'] = $row['width']; + $values['height'] = $row['height']; + $values['pos_x'] = $row['pos_x']; + $values['pos_y'] = $row['pos_y']; + + switch ($row['rowtype']) { + case NETWORK_LINK: + case LINE_ITEM: + continue 2; + + break; + + case SIMPLE_VALUE_MAX: + case SIMPLE_VALUE_MIN: + case SIMPLE_VALUE_AVG: + $values['period'] = $row['period']; + break; + + case MODULE_GRAPH: + $values['period'] = $row['period']; + unset($values['image']); + break; + + case GROUP_ITEM: + $values['id_group'] = $row['group']; + break; + + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: + case PERCENTILE_BUBBLE: + case PERCENTILE_BAR: + unset($values['height']); + break; + } + + if (defined('METACONSOLE')) { + $values['id_metaconsole'] = $row['id_server']; + } + + $values['id_agent'] = $row['agent']; + $values['id_agente_modulo'] = $row['module']; + $values['id_custom_graph'] = $row['custom_graph']; + $values['parent_item'] = $row['parent']; + $values['id_layout_linked'] = $row['map_linked']; + + if (enterprise_installed()) { + enterprise_visual_map_update_action_from_list_elements($row['rowtype'], $values, $id); + } + + db_process_sql_update('tlayout_data', $values, ['id' => $id]); + } + + return true; + } + break; + case 'delete': $id_element = get_parameter('id_element'); $result = db_process_sql_delete('tlayout_data', ['id' => $id_element]); From 14fff848760653ab06d9b61f2b65e99479dcf873 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 8 Nov 2023 11:56:32 +0100 Subject: [PATCH 14/28] queries remove field transactional_agent pandora_enterprise#12334 --- pandora_console/extras/mr/67.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..0a5fcd9fb0 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,13 @@ +START TRANSACTION; + +SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tmetaconsole_agent' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); +SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tmetaconsole_agent` DROP COLUMN `transactional_agent`', 'SELECT ""'); +prepare stmt from @sqlstmt; +execute stmt; + +SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tagente' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); +SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tagente` DROP COLUMN `transactional_agent`', 'SELECT ""'); +prepare stmt from @sqlstmt; +execute stmt; + +COMMIT; From 5eb5df61906cdf0f1e98aa6213af79660fa00eaf Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 10 Nov 2023 13:13:57 +0100 Subject: [PATCH 15/28] change url pandorarc name --- pandora_console/godmode/setup/setup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 0fd6bebff8..c0d59fbde9 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -184,7 +184,7 @@ $buttons['ITSM'] = [ $buttons['ehorus'] = [ 'active' => false, - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/RC.png', true, [ @@ -297,7 +297,7 @@ switch ($section) { $help_header = 'setup_flow_tab'; break; - case 'ehorus': + case 'pandorarc': $buttons['ehorus']['active'] = true; $subpage = __('Pandora RC'); $help_header = 'setup_ehorus_tab'; @@ -438,7 +438,7 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_visuals.php'; break; - case 'ehorus': + case 'pandorarc': include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; From c2bf6e6bf52614c88448dd83e4035cfb65c93b40 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 13 Nov 2023 17:34:38 +0100 Subject: [PATCH 16/28] fix pgrep process in ubuntu --- pandora_console/include/functions_cron_task.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_cron_task.php b/pandora_console/include/functions_cron_task.php index 9de0520ccd..40a6e159cc 100644 --- a/pandora_console/include/functions_cron_task.php +++ b/pandora_console/include/functions_cron_task.php @@ -459,17 +459,17 @@ function cron_task_start_gotty(bool $restart_mode=true) // Check prev process running and kill it (only if port changed in setup params). if (empty($config['restart_gotty_next_cron_port']) === false) { - config_update_value('restart_gotty_next_cron_port', ''); - - $prevProcessRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); + $prevProcessRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."' | grep -v 'pgrep'"); if (empty($prevProcessRunning) === false) { shell_exec("pkill -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); } + + config_update_value('restart_gotty_next_cron_port', ''); } // Check if gotty is running on the configured port. - $processRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['gotty_port']."'"); + $processRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['gotty_port']."' | grep -v 'pgrep'"); $start_proc = true; From 4579fe21d98e1215413afc262154542271e3deaa Mon Sep 17 00:00:00 2001 From: alejandro Date: Wed, 15 Nov 2023 14:24:42 +0100 Subject: [PATCH 17/28] update version in mr --- pandora_console/extras/mr/67.sql | 6 ++++++ pandora_console/pandoradb_data.sql | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..48d44b6255 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.vmware'; + +COMMIT; + diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 9ce5355361..6813173de7 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2653,7 +2653,7 @@ SET @short_name = 'pandorafms.vmware'; SET @name = 'VMware'; SET @section = 'app'; SET @description = 'Monitor ESXi hosts, datastores and VMs from a specific datacenter'; -SET @version = '1.1'; +SET @version = '1.2'; INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; From 4b0e134fba568048df1cb7f897f136033b1edca8 Mon Sep 17 00:00:00 2001 From: alejandro Date: Wed, 15 Nov 2023 15:13:08 +0100 Subject: [PATCH 18/28] update md5 hash --- .../extras/discovery/DiscoveryApplicationsMigrateCodes.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini index 6323aec140..1ba02194d2 100644 --- a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini +++ b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini @@ -1,4 +1,4 @@ -pandorafms.vmware=9959cc3e5cc6bfcfadd6d05b56d4a11b +pandorafms.vmware=54251ae54994c55b478867cd35a98e6c pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe pandorafms.mssql=1cc215409741d19080269ffba112810e pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6 From 804970719d502de1adb91f2b32a055a116830427 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 15 Nov 2023 16:32:02 +0100 Subject: [PATCH 19/28] #12385 Fixed group --- .../agentes/pandora_networkmap.view.php | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 5256c10871..3cbe53e815 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -1205,57 +1205,6 @@ if (is_ajax() === true) { return; } - if ($get_agents_in_group) { - $id = (int) get_parameter('id', 0); - $group = (int) get_parameter('group', -1); - - $return = []; - $return['correct'] = false; - - if ($group != -1) { - $where_id_agente = ' 1=1 '; - - $agents_in_networkmap = db_get_all_rows_filter( - 'titem', - [ - 'id_map' => $id, - 'deleted' => 0, - ] - ); - if ($agents_in_networkmap !== false) { - $ids = []; - foreach ($agents_in_networkmap as $agent) { - if ($agent['type'] == 0) { - $ids[] = $agent['source_data']; - } - } - - $where_id_agente = ' id_agente NOT IN ('.implode(',', $ids).')'; - } - - - $sql = 'SELECT id_agente, alias - FROM tagente - WHERE id_grupo = '.$group.' AND '.$where_id_agente.' - ORDER BY alias ASC'; - - $agents = db_get_all_rows_sql($sql); - - if ($agents !== false) { - $return['agents'] = []; - foreach ($agents as $agent) { - $return['agents'][$agent['id_agente']] = $agent['alias']; - } - - $return['correct'] = true; - } - } - - echo json_encode($return); - - return; - } - if ($get_agent_info) { $id_agent = (int) get_parameter('id_agent'); From 1a931c71b4114d4f69aa12bd42cf615d56de676e Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 16 Nov 2023 10:10:54 +0100 Subject: [PATCH 20/28] update vmwre md5 code --- .../extras/discovery/DiscoveryApplicationsMigrateCodes.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini index 1ba02194d2..c0cee7d03f 100644 --- a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini +++ b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini @@ -1,4 +1,4 @@ -pandorafms.vmware=54251ae54994c55b478867cd35a98e6c +pandorafms.vmware=248788e0fb2cd4e11623e4a52ee7d05b pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe pandorafms.mssql=1cc215409741d19080269ffba112810e pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6 From 81f938c5ca0abfc11633d64e71900c4c85fe963a Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 23 Nov 2023 09:12:49 +0100 Subject: [PATCH 21/28] #11494 Align text left --- pandora_console/include/lib/Dashboard/Widget.php | 1 + .../include/lib/Dashboard/Widgets/service_level.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index df084d26b5..281c6c8804 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -454,6 +454,7 @@ class Widget case 'service_level': $className .= '\ServiceLevelWidget'; + break; case 'security_hardening': if (\enterprise_installed() === false) { diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_level.php b/pandora_console/include/lib/Dashboard/Widgets/service_level.php index b63ff36518..7f3add7c08 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_level.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_level.php @@ -537,14 +537,17 @@ class ServiceLevelWidget extends Widget $table->head[5] = __('Warn. Events'); $table->head[6] = __('Last change'); $table->data = []; + $table->cellstyle = []; $row = 0; foreach ($visualData as $agent_id => $data) { foreach ($data['modules'] as $module_name => $module_data) { if (isset($module_data) === true) { if ($show_agents === 'on') { $table->data[$row][0] = $module_data['agent_alias'].' / '.$module_data['module_name']; + $table->cellstyle[$row][0] = 'text-align:left'; } else { $table->data[$row][0] = $module_data['module_name']; + $table->cellstyle[$row][0] = 'text-align:left'; } $table->data[$row][1] = $module_data['availability'].'%'; From deff8a3bce38b6ae67cab21d0985b4aed8642396 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Tue, 28 Nov 2023 10:21:15 -0600 Subject: [PATCH 22/28] Change some defaults on pandora_agent.conf --- pandora_agents/pc/Linux/pandora_agent.conf | 32 +++++++++++++++---- pandora_agents/pc/Win32/pandora_agent.conf | 26 ++++++++++++++- .../shellscript/linux/pandora_agent.conf | 27 ++++++++++++++-- .../shellscript/mac_osx/pandora_agent.conf | 31 ++++++++++++++---- pandora_agents/unix/Linux/pandora_agent.conf | 14 +++++--- 5 files changed, 109 insertions(+), 21 deletions(-) diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 4ad837f943..ee63d8b6a0 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -234,6 +234,21 @@ module_description Number of cron task files module_unit files module_end +# This module /var/log/syslog file, under the module name "syslog" +# And search for "ssh" string into it, sending only that information. +# module_begin +# module_name Syslog +# module_description Search for ssh string into /var/log/syslog file +# module_type log +# module_regexp /var/log/syslog +# module_pattern ssh +# module_end + +#Hardening plugin for security compliance analysis. Enable to use it. +#module_begin +#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150 +#module_absoluteinterval 7d +#module_end # Plugin example @@ -241,11 +256,6 @@ module_end module_plugin pandora_df -# This parses /var/log/syslog file, under the module name "syslog" -# And search for "ssh" string into it, sending only that information. - -module_plugin grep_log /var/log/syslog Syslog ssh - # Get disk space free in MB #module_begin #module_name disk_root_free @@ -270,7 +280,6 @@ module_plugin grep_log /var/log/syslog Syslog ssh #module_end # Plugin for inventory on the agent. - # module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users process ip route # Example of preconditions @@ -303,4 +312,13 @@ module_plugin grep_log /var/log/syslog Syslog ssh # This plugin runs several security checks in a Linux system -#module_plugin pandora_security_check \ No newline at end of file +#module_plugin pandora_security_check + +# Extraction module example +#module_begin +#module_name Collector +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* +#module_end \ No newline at end of file diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 621c1d24ac..9d938c256b 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2023 Pandora FMS -# Version 7.0NG.774 +# Version 7.0NG.774 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software # Foundation; either version 2 of the Licence or any later version @@ -219,6 +219,21 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs" # module_description Free space on drive D: (%) # module_end +# Hardening plugin for security compliance analysis. +# module_begin +# module_plugin "%PROGRAMFILES%\Pandora_Agent\util\pandora_hardening.exe -t 150" +# module_absoluteinterval 7d +# module_end + +# Logs extraction +#module_begin +#module_name X_Server_log +#module_description Logs extraction module +#module_type log +#module_regexp C:\server\logs\xserver.log +#module_pattern .* +#module_end + # Sample of Windows inventory module (ONLY ENTERPRISE)! #module_begin #module_name Inventory @@ -344,4 +359,13 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs" #module_condition (3,8) cmd.exe /c echo range >> c:\log.txt #module_exec echo 5 #module_description Postcondition test module +#module_end + +# Example of collector module +#module_begin +#module_name Collector +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* #module_end \ No newline at end of file diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 98c137741e..fa0e0f9ff8 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -157,12 +157,33 @@ module_exec last | head -1 module_description Last Login module_end -# Plugin example +#Hardening plugin for security compliance analysis. Enable to use it. +#module_begin +#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150 +#module_absoluteinterval 7d +#module_end -# This parses /var/log/syslog file, under the module name "syslog" +# This module parses /var/log/syslog file, under the module name "syslog" # And search for "ssh" string into it, sending only that information. -module_plugin grep_log /var/log/syslog Syslog ssh +module_begin +module_name Syslog +module_description Search for ssh string into /var/log/syslog file +module_type log +module_regexp /var/log/syslog +module_pattern ssh +module_end + +# Plugin example # Plugin for inventory on the agent. # module_plugin inventory 1 cpu ram video nic hd cdrom software + +# Extraction module example +#module_begin +#module_name Collector +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* +#module_end \ No newline at end of file diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index b4b3c35ac8..190f12a3da 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -372,13 +372,32 @@ module_end #module_description XGrid #module_end +#Hardening plugin for security compliance analysis. Enable to use it. +#module_begin +#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150 +#module_absoluteinterval 7d +#module_end + +# This module parses /var/log/syslog file, under the module name "syslog" +# And search for "ssh" string into it, sending only that information. +#module_begin +#module_name Syslog +#module_description Log collection modules +#module_type log +#module_regexp /var/log/syslog +#module_pattern ssh +#module_end + # Plugin example -# This parses /var/log/syslog file, under the module name "syslog" -# And search for "ssh" string into it, sending only that information. - -#module_plugin grep_log /var/log/syslog Syslog ssh - # Plugin for inventory on the agent. - # module_plugin inventory 1 cpu ram video nic hd cdrom software + +# Extraction module example +#module_begin +#module_name Collector +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* +#module_end \ No newline at end of file diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 10458ddba5..1a4678da28 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -271,11 +271,17 @@ module_plugin pandora_netusage module_plugin autodiscover --default # Plugin for inventory on the agent. -#module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route +# module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route # Log collection modules. This will collect log files for forensic analysis and store everything # This is for LOG monitoring. Different than log monitoring. -#module_plugin grep_log_module /var/log/messages Syslog \.\* +#module_begin +#module_name Syslog +#module_description Log collection modules +#module_type log +#module_regexp /var/log/messages +#module_pattern .* +#module_end # Another samples of monitoring modules @@ -317,9 +323,9 @@ module_plugin autodiscover --default #module_absoluteinterval 7d #module_end -# Logs extraction +# Extraction module example #module_begin -#module_name Syslog +#module_name Collector #module_description Logs extraction module #module_type log #module_regexp /var/log/logfile.log From 64b612faea0c5ff58e1dacd9e2e692cf2980e93e Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 29 Nov 2023 09:40:34 +0100 Subject: [PATCH 23/28] #11494 Add tip and fix MTRS bug --- pandora_console/include/functions_modules.php | 4 ++++ .../include/lib/Dashboard/Widgets/service_level.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 4104d2660f..12fc5ec828 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4871,6 +4871,10 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $mtrs_array[] = 0; } else { foreach ($normal_event as $key => $value) { + if (isset($failed_event[$key]) === false) { + $failed_event[$key] = end($failed_event); + } + if (($failed_event[$key] - $normal_event[$key]) < 0) { $mtrs_array[] = ($normal_event[$key] - $failed_event[$key]); } else { diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_level.php b/pandora_console/include/lib/Dashboard/Widgets/service_level.php index 7f3add7c08..8184495587 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_level.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_level.php @@ -533,8 +533,8 @@ class ServiceLevelWidget extends Widget $table->head[1] = __('% Av.'); $table->head[2] = __('MTBF'); $table->head[3] = __('MTRS'); - $table->head[4] = __('Crit. Events'); - $table->head[5] = __('Warn. Events'); + $table->head[4] = __('Crit. Events').ui_print_help_tip(__('Counted only critical events generated automatic by the module'), true); + $table->head[5] = __('Warn. Events').ui_print_help_tip(__('Counted only warning events generated automatic by the module'), true); $table->head[6] = __('Last change'); $table->data = []; $table->cellstyle = []; From 8940e2b9aa8fe73dc794e3175922fda40048c84a Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Wed, 29 Nov 2023 11:13:09 -0600 Subject: [PATCH 24/28] Automatically apply log collection --- pandora_agents/pc/Linux/pandora_agent.conf | 14 +++++++------- pandora_agents/pc/Win32/pandora_agent.conf | 9 --------- .../shellscript/linux/pandora_agent.conf | 1 - .../shellscript/mac_osx/pandora_agent.conf | 14 +++++++------- pandora_agents/unix/Linux/pandora_agent.conf | 14 +++++++------- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index ee63d8b6a0..e25a82a517 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -236,13 +236,13 @@ module_end # This module /var/log/syslog file, under the module name "syslog" # And search for "ssh" string into it, sending only that information. -# module_begin -# module_name Syslog -# module_description Search for ssh string into /var/log/syslog file -# module_type log -# module_regexp /var/log/syslog -# module_pattern ssh -# module_end +module_begin +module_name Syslog +module_description Search for ssh string into /var/log/syslog file +module_type log +module_regexp /var/log/syslog +module_pattern ssh +module_end #Hardening plugin for security compliance analysis. Enable to use it. #module_begin diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 9d938c256b..eb891d5866 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -225,15 +225,6 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs" # module_absoluteinterval 7d # module_end -# Logs extraction -#module_begin -#module_name X_Server_log -#module_description Logs extraction module -#module_type log -#module_regexp C:\server\logs\xserver.log -#module_pattern .* -#module_end - # Sample of Windows inventory module (ONLY ENTERPRISE)! #module_begin #module_name Inventory diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index fa0e0f9ff8..49e8866f9a 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -165,7 +165,6 @@ module_end # This module parses /var/log/syslog file, under the module name "syslog" # And search for "ssh" string into it, sending only that information. - module_begin module_name Syslog module_description Search for ssh string into /var/log/syslog file diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 190f12a3da..ba9c0079a3 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -380,13 +380,13 @@ module_end # This module parses /var/log/syslog file, under the module name "syslog" # And search for "ssh" string into it, sending only that information. -#module_begin -#module_name Syslog -#module_description Log collection modules -#module_type log -#module_regexp /var/log/syslog -#module_pattern ssh -#module_end +module_begin +module_name Syslog +module_description Log collection modules +module_type log +module_regexp /var/log/syslog +module_pattern ssh +module_end # Plugin example diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 1a4678da28..42fddd39f5 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -275,13 +275,13 @@ module_plugin autodiscover --default # Log collection modules. This will collect log files for forensic analysis and store everything # This is for LOG monitoring. Different than log monitoring. -#module_begin -#module_name Syslog -#module_description Log collection modules -#module_type log -#module_regexp /var/log/messages -#module_pattern .* -#module_end +module_begin +module_name Syslog +module_description Log collection modules +module_type log +module_regexp /var/log/messages +module_pattern .* +module_end # Another samples of monitoring modules From dbd7de857ba1899d3b4b6fb3a37ce180c5745caa Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Wed, 29 Nov 2023 11:44:02 -0600 Subject: [PATCH 25/28] Capture security and system events on windows. --- pandora_agents/pc/Win32/pandora_agent.conf | 15 +++++----- pandora_agents/win32/bin/pandora_agent.conf | 32 ++++++++++----------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index eb891d5866..b064eba730 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -147,22 +147,23 @@ module_max_critical 20 module_end # Log events + +# Get logs from System source. module_begin module_name System Events (TermService) -module_type async_string -module_logevent module_description Log Events coming from Terminal Service +module_type log +module_logevent module_source System -module_application TermService module_end +# Get logs from Security source. module_begin -module_name Security Events (Invalid Login) -module_type async_string -module_description Security log events for invalid login attempt +module_name Security Events +module_description Security log events +module_type log module_logevent module_source Security -module_eventcode 529 module_end # Check if Dhcp service is enabled diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index bae2841fd5..c0a1560b38 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -179,6 +179,22 @@ module_description Total number of TCP connections active module_group Networking module_end +# Get logs from System source. +module_begin +module_name Eventlog_System +module_type log +module_logevent +module_source System +module_end + +# Get logs from Security source. +module_begin +module_name Eventlog_Security +module_type log +module_logevent +module_source Security +module_end + # Example plugin to retrieve drive usage module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent_used.vbs" @@ -273,22 +289,6 @@ module_plugin "%PROGRAMFILES%\Pandora_Agent\util\autodiscover.exe" --default #module_type generic_data_string #module_end -# Get logs from System source. Need enterprise version. -#module_begin -#module_name Eventlog_System -#module_type log -#module_logevent -#module_source System -#module_end - -# Get logs from Security source. Need enterprise version. -#module_begin -#module_name Eventlog_Security -#module_type log -#module_logevent -#module_source Security -#module_end - # Get logs from Application source. Need enterprise version. #module_begin #module_name Eventlog_Application From 3c99a2e49a4fbfd09e5a27fd0d7f03a00d1f5f2b Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 1 Dec 2023 13:29:51 +0100 Subject: [PATCH 26/28] #11494 Fix Av. bug --- pandora_console/include/functions_modules.php | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 12fc5ec828..e85029064e 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4869,7 +4869,7 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $mtrs_array[] = ($current_time - $failed_event[0]); } else if (empty($failed_event) === true) { $mtrs_array[] = 0; - } else { + } else if (count($normal_event) >= count($failed_event)) { foreach ($normal_event as $key => $value) { if (isset($failed_event[$key]) === false) { $failed_event[$key] = end($failed_event); @@ -4881,6 +4881,16 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $mtrs_array[] = ($failed_event[$key] - $normal_event[$key]); } } + } else { + foreach ($normal_event as $key => $value) { + if (($failed_event[$key] - $normal_event[$key]) < 0) { + $mtrs_array[] = ($normal_event[$key] - $failed_event[$key]); + } else { + $mtrs_array[] = ($failed_event[$key] - $normal_event[$key]); + } + } + + $mtrs_array[] = ($current_time - end($failed_event)); } $mtbf_array = []; @@ -4891,16 +4901,16 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $mtbf_array[] = ($failed_event[($i - 1)] - $failed_event[$i]); } } else { - $mtbf_array[] = ($current_time - $failed_event[0]); + $mtbf_array[] = 0; } } else { $mtbf_array[] = 0; } - $total_time_failed = array_sum($mtbf_array); + $total_time_failed = array_sum($mtrs_array); $total_time_ok = ($interval_time - $total_time_failed); if (count($events_time) === 1) { - if ((string) $first_utimestamp !== '0') { + if ((int) $first_utimestamp !== 0) { $availability = round((($total_time_ok / $interval_time) * 100), 2); } } else { @@ -4908,14 +4918,14 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule } if ($critical_events > 1) { - $mtbf = round(( $total_time_failed / $critical_events)); + $mtbf = round(array_sum($mtbf_array) / count($mtbf_array)); } else { $mtbf = false; } - if (count($mtrs_array) === 1 && (string) $first_utimestamp !== '0' && $type === 0) { + if (count($mtrs_array) === 1 && (int) $first_utimestamp !== 0) { $mtrs = round($total_time_failed / count($mtrs_array)); - } else if (count($mtrs_array) > 1 && (string) $first_utimestamp !== '0') { + } else if (count($mtrs_array) > 1 && (int) $first_utimestamp !== 0) { $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); } else { $mtrs = false; From d601103df30d19373d7a0a08b9d619f634e16f07 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 5 Dec 2023 11:49:43 +0100 Subject: [PATCH 27/28] fix url --- pandora_console/godmode/menu.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 94509ab820..2376669cf4 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -476,8 +476,8 @@ if ($access_console_node === true) { } } - $sub2['godmode/setup/setup§ion=ehorus']['text'] = __('Pandora RC'); - $sub2['godmode/setup/setup§ion=ehorus']['refr'] = 0; + $sub2['godmode/setup/setup§ion=pandorarc']['text'] = __('Pandora RC'); + $sub2['godmode/setup/setup§ion=pandorarc']['refr'] = 0; $sub2['godmode/setup/setup§ion=ITSM']['text'] = __('ITSM'); $sub2['godmode/setup/setup§ion=ITSM']['refr'] = 0; From 21ea0f5196cab6e2de910f8e829ebca94c7c642c Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 5 Dec 2023 12:53:32 +0100 Subject: [PATCH 28/28] #11494 Fix MTRS --- pandora_console/include/functions_modules.php | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 13813d479c..ea776d6fe3 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4859,13 +4859,33 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule if ($events_time !== false && count($events_time) > 0) { $failed_event = []; $normal_event = []; - foreach ($events_time as $event) { - if ($event['event_type'] === 'going_up_critical') { + $events_time = array_reverse($events_time); + $mtrs_events = []; + foreach ($events_time as $key => $event) { + if ($event['event_type'] === 'going_up_critical' || $event['event_type'] === 'going_down_critical') { $failed_event[] = $event['utimestamp']; + $mtrs_events[]['failed_event'] = $event['utimestamp']; } - if ($event['event_type'] === 'going_down_normal') { + if ($event['event_type'] === 'going_up_normal' + || $event['event_type'] === 'going_down_normal' + || $event['event_type'] === 'going_up_warning' + || $event['event_type'] === 'going_down_warning' + ) { $normal_event[] = $event['utimestamp']; + $mtrs_events[]['normal_event'] = $event['utimestamp']; + } + } + + $process_mtrs_events = []; + + if (empty($mtrs_events) === false) { + $last_event_key = ''; + foreach ($mtrs_events as $key => $val) { + if (key($val) !== $last_event_key) { + $last_event_key = key($val); + $process_mtrs_events[] = $val; + } } } @@ -4874,28 +4894,21 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $mtrs_array[] = ($current_time - $failed_event[0]); } else if (empty($failed_event) === true) { $mtrs_array[] = 0; - } else if (count($normal_event) >= count($failed_event)) { - foreach ($normal_event as $key => $value) { - if (isset($failed_event[$key]) === false) { - $failed_event[$key] = end($failed_event); - } - - if (($failed_event[$key] - $normal_event[$key]) < 0) { - $mtrs_array[] = ($normal_event[$key] - $failed_event[$key]); - } else { - $mtrs_array[] = ($failed_event[$key] - $normal_event[$key]); - } - } } else { - foreach ($normal_event as $key => $value) { - if (($failed_event[$key] - $normal_event[$key]) < 0) { - $mtrs_array[] = ($normal_event[$key] - $failed_event[$key]); - } else { - $mtrs_array[] = ($failed_event[$key] - $normal_event[$key]); + $last_value = ''; + foreach ($process_mtrs_events as $key => $val) { + $current_value = $val[key($val)]; + if ($last_value !== '') { + $mtrs_array[] = ($current_value - $last_value); } + + $last_value = $current_value; } - $mtrs_array[] = ($current_time - end($failed_event)); + $last_mtrs_event = key(end($process_mtrs_events)); + if ($last_mtrs_event === 'failed_event') { + $mtrs_array[] = ($current_time - $last_value); + } } $mtbf_array = []; @@ -4903,7 +4916,7 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule if (!empty($failed_event) === true) { if (count($failed_event) > 1) { for ($i = 1; $i <= array_key_last($failed_event); $i++) { - $mtbf_array[] = ($failed_event[($i - 1)] - $failed_event[$i]); + $mtbf_array[] = ($failed_event[$i] - ($failed_event[($i - 1)])); } } else { $mtbf_array[] = 0;