From 04a45e84a87cccf2e47fcd975efbfc68c5cbff09 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 19 Jul 2023 12:50:39 +0200 Subject: [PATCH 01/22] #11547 Show a different 'about' depending on whether the user is admin --- pandora_console/include/functions_menu.php | 441 +++++++++++---------- 1 file changed, 223 insertions(+), 218 deletions(-) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index ff18544586..1912bd1190 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -950,11 +950,14 @@ if (is_ajax()) { $dialog = ' -
- - - - - - - - - - - - - - - - - + '; + if ($config['is_admin']['admin'] === true) { + $dialog .= '
+
-

- '.__('Database health status').'

-
-

'.$db_health->data->unknownAgents->name.'

-
-

'.$db_health->data->unknownAgents->value.'

-
-

'.$db_health->data->notInitAgents->name.'

-
-

'.$db_health->data->notInitAgents->value.'

-
-

'.$db_health->data->pandoraDbLastRun->name.'

-
-

'.$db_health->data->pandoraDbLastRun->value.'

-
+ + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - -
+

- '.__('Database health status').'

+
+

'.$db_health->data->unknownAgents->name.'

+
+

'.$db_health->data->unknownAgents->value.'

+
+

'.$db_health->data->notInitAgents->name.'

+
+

'.$db_health->data->notInitAgents->value.'

+
+

'.$db_health->data->pandoraDbLastRun->name.'

+
+

'.$db_health->data->pandoraDbLastRun->value.'

+
-

- '.__('Database status info').'

-
-

'.$db_info->data->dbSchemeFirstVersion->name.'

-
-

'.$db_info->data->dbSchemeFirstVersion->value.'

-
-

'.$db_info->data->dbSchemeVersion->name.'

-
-

'.$db_info->data->dbSchemeVersion->value.'

-
-

'.$db_info->data->dbSchemeBuild->name.'

-
-

'.$db_info->data->dbSchemeBuild->value.'

-
-

'.$db_info->data->dbSize->name.'

-
-

'.$db_info->data->dbSize->value.'

-
+

- '.__('Database status info').'

+
+

'.$db_info->data->dbSchemeFirstVersion->name.'

+
+

'.$db_info->data->dbSchemeFirstVersion->value.'

+
+

'.$db_info->data->dbSchemeVersion->name.'

+
+

'.$db_info->data->dbSchemeVersion->value.'

+
+

'.$db_info->data->dbSchemeBuild->name.'

+
+

'.$db_info->data->dbSchemeBuild->value.'

+
+

'.$db_info->data->dbSize->name.'

+
+

'.$db_info->data->dbSize->value.'

+
-

- '.__('Tables fragmentation in the %s database', $product_name).'

-
-

'.$db_fragmentation->data->tablesFragmentationMax->name.'

-
-

'.$db_fragmentation->data->tablesFragmentationMax->value.'

-
-

'.$db_fragmentation->data->tablesFragmentationValue->name.'

-
-

'.$db_fragmentation->data->tablesFragmentationValue->value.'

-
-

'.$db_fragmentation->data->tablesFragmentationStatus->name.'

-
-

'.$fragmentation_status.'

-
+ + +

- '.__('Tables fragmentation in the %s database', $product_name).'

+ + + + +

'.$db_fragmentation->data->tablesFragmentationMax->name.'

+ + +

'.$db_fragmentation->data->tablesFragmentationMax->value.'

+ + + + +

'.$db_fragmentation->data->tablesFragmentationValue->name.'

+ + +

'.$db_fragmentation->data->tablesFragmentationValue->value.'

+ + + + +

'.$db_fragmentation->data->tablesFragmentationStatus->name.'

+ + +

'.$fragmentation_status.'

+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

- '.__('System Info').'

+
+

'.$sys_info->data->cpuInfo->name.'

+
+

'.$sys_info->data->cpuInfo->value.'

+
+

'.$sys_info->data->ramInfo->name.'

+
+

'.$sys_info->data->ramInfo->value.'

+
+

'.$sys_info->data->osInfo->name.'

+
+

'.$sys_info->data->osInfo->value.'

+
+

'.$sys_info->data->hostnameInfo->name.'

+
+

'.$sys_info->data->hostnameInfo->value.'

+
+

'.$sys_info->data->ipInfo->name.'

+
+

'.$sys_info->data->ipInfo->value.'

+
+

'.$system_date->data->date->name.'

+
+

'.$system_date->data->date->value.'

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+

- '.__('PHP system').'

+
+

'.$php_sys->data->phpVersion->name.'

+
+

'.$php_sys->data->phpVersion->value.'

+
+

'.$php_sys->data->maxExecutionTime->name.'

+
+

'.$php_sys->data->maxExecutionTime->value.'

+
+

'.$php_sys->data->maxInputTime->name.'

+
+

'.$php_sys->data->maxInputTime->value.'

+
+

'.$php_sys->data->memoryLimit->name.'

+
+

'.$php_sys->data->memoryLimit->value.'

+
+

'.$php_sys->data->sessionLifetime->name.'

+
+

'.$php_sys->data->sessionLifetime->value.'

+
+
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- '.__('System Info').'

-
-

'.$sys_info->data->cpuInfo->name.'

-
-

'.$sys_info->data->cpuInfo->value.'

-
-

'.$sys_info->data->ramInfo->name.'

-
-

'.$sys_info->data->ramInfo->value.'

-
-

'.$sys_info->data->osInfo->name.'

-
-

'.$sys_info->data->osInfo->value.'

-
-

'.$sys_info->data->hostnameInfo->name.'

-
-

'.$sys_info->data->hostnameInfo->value.'

-
-

'.$sys_info->data->ipInfo->name.'

-
-

'.$sys_info->data->ipInfo->value.'

-
-

'.$system_date->data->date->name.'

-
-

'.$system_date->data->date->value.'

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- '.__('PHP system').'

-
-

'.$php_sys->data->phpVersion->name.'

-
-

'.$php_sys->data->phpVersion->value.'

-
-

'.$php_sys->data->maxExecutionTime->name.'

-
-

'.$php_sys->data->maxExecutionTime->value.'

-
-

'.$php_sys->data->maxInputTime->name.'

-
-

'.$php_sys->data->maxInputTime->value.'

-
-

'.$php_sys->data->memoryLimit->name.'

-
-

'.$php_sys->data->memoryLimit->value.'

-
-

'.$php_sys->data->sessionLifetime->name.'

-
-

'.$php_sys->data->sessionLifetime->value.'

-
-
- - '; + '; + } echo $dialog; } From 85194fe2be4acb5de34c064884654ae2074a149a Mon Sep 17 00:00:00 2001 From: rafael Date: Fri, 21 Jul 2023 11:23:31 +0200 Subject: [PATCH 02/22] 11757 adding inventory demo data script to load util --- .../util/load/generate_inventory_data.sh | 66 +++++ .../load/templates/inventory_linux.template | 192 +++++++++++++ .../load/templates/inventory_windows.template | 257 ++++++++++++++++++ 3 files changed, 515 insertions(+) create mode 100755 pandora_server/util/load/generate_inventory_data.sh create mode 100644 pandora_server/util/load/templates/inventory_linux.template create mode 100644 pandora_server/util/load/templates/inventory_windows.template diff --git a/pandora_server/util/load/generate_inventory_data.sh b/pandora_server/util/load/generate_inventory_data.sh new file mode 100755 index 0000000000..b91ac24af7 --- /dev/null +++ b/pandora_server/util/load/generate_inventory_data.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# (c) 2023 Pandora FMS + +if [ ! -e pandora_xml_stress.agents ] +then + echo "Error, cant find pandora_xml_stress.agets file" + exit +fi + +linux_inventory=1 +windows_inventory=1 + +# Variables +agent_count=5 + +data_in=/var/spool/pandora/data_in/ +description='Demo data Agent' +group='Servers' +current_date=`date +"%Y/%m/%d %H:%M:%S"` +current_utimestamp=`date +%s` + +if [ $linux_inventory -eq 1 ] ; then + + if [ ! -e templates/inventory_linux.template ]; then + echo "Error, cant find inventory linux template" + exit + fi + + echo "Enable linux invetory: adding invetory data to ${agent_count} linux agent" + + for agent_name in $(cat pandora_xml_stress.agents | head ${agent_conunt}); do + echo " - Adding invetory data to ${agent_name} linux agent" + ip_add="10.0.0.$(( RANDOM % 255 + 1 ))" + rand_number=$(( RANDOM % 10 + 1 )) + cat "templates/inventory_linux.template" \ + | sed -e "s/{{description}}/${description}/g" \ + -e "s/{{group}}/${group}/g" \ + -e "s/{{agent_name}}/${agent_name}/g" \ + -e "s|{{date}}|${current_date}|g" \ + -e "s|{{ip_address}}|${ip_add}|g" \ + -e "s|{{rand_number}}|${rand_number}|g" \ + > /${data_in}/${agent_name}.${current_utimestamp}.data + done +fi + +if [ $windows_inventory -eq 1 ]; then + if [ ! -e templates/inventory_windows.template ]; then + echo "Error, cant find inventory Windows template" + exit + fi + echo "Enable Windows invetory: adding invetory data to ${agent_count} Windows agent" + + for agent_name in $(cat pandora_xml_stress.agents | tail ${agent_conunt}); do + echo " - Adding invetory data to ${agent_name} windows agent" + ip_add="172.16.5.$(( RANDOM % 255 + 1 ))" + rand_number=$(( RANDOM % 100 + 1 )) + cat "templates/inventory_windows.template" \ + | sed -e "s/{{description}}/${description}/g" \ + -e "s/{{group}}/${group}/g" \ + -e "s/{{agent_name}}/${agent_name}/g" \ + -e "s|{{date}}|${current_date}|g" \ + -e "s|{{rand_number}}|${rand_number}|g" \ + -e "s|{{ip_address}}|${ip_add}|g" \ + > /${data_in}/${agent_name}.${current_utimestamp}.data + done +fi \ No newline at end of file diff --git a/pandora_server/util/load/templates/inventory_linux.template b/pandora_server/util/load/templates/inventory_linux.template new file mode 100644 index 0000000000..3e1cb25627 --- /dev/null +++ b/pandora_server/util/load/templates/inventory_linux.template @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pandora_server/util/load/templates/inventory_windows.template b/pandora_server/util/load/templates/inventory_windows.template new file mode 100644 index 0000000000..127ca1dfba --- /dev/null +++ b/pandora_server/util/load/templates/inventory_windows.template @@ -0,0 +1,257 @@ + + + + + + CPU + + + + + + + + + + + HD + + + + + + + + + Video + + + + + + + + + NIC + + + + + + + + + Monitors + + + + + + + + RAM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Users + + + + + + + + product_ID + + + + + + + + + From 53bf10acc0d0c52ac1c4bdc5d6c800787df5dc42 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 14 Aug 2023 14:54:15 +0200 Subject: [PATCH 03/22] #11819 wizard visual console update --- .../reporting/visual_console_builder.php | 22 ++++- .../visual_console_builder.wizard.php | 84 +++++++++++++++++- .../include/functions_visual_map.php | 88 ++++++++++++------- pandora_console/include/styles/pandora.css | 4 + 4 files changed, 161 insertions(+), 37 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index c7da988cd0..986dcb423b 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -555,6 +555,7 @@ switch ($activeTab) { $type = (int) get_parameter('type', STATIC_GRAPH); $image = get_parameter('image'); $range = (int) get_parameter('range', 50); + $range_vertical = (int) get_parameter('range_vertical', 50); $width = (int) get_parameter('width', 0); $height = (int) get_parameter('height', 0); $period = (int) get_parameter('period', 0); @@ -567,6 +568,9 @@ switch ($activeTab) { $label_type = get_parameter('label_type', 'agent_module'); $enable_link = get_parameter('enable_link', 'enable_link'); $show_on_top = get_parameter('show_on_top', 0); + $pos_x = get_parameter('pos_x', 0); + $pos_y = get_parameter('pos_y', 0); + $max_elements_row = (int) get_parameter('max_elements_row', 0); // This var switch between creation of items, item_per_agent = 0 => item per module; item_per_agent <> 0 => item per agent $item_per_agent = get_parameter('item_per_agent', 0); @@ -611,6 +615,7 @@ switch ($activeTab) { $image, $idVisualConsole, $range, + $range_vertical, $width, $height, $period, @@ -626,7 +631,10 @@ switch ($activeTab) { $kind_relationship, $item_in_the_map, $fontf, - $fonts + $fonts, + $pos_x, + $pos_y, + $max_elements_row ); $statusProcessInDB = [ @@ -668,6 +676,7 @@ switch ($activeTab) { $image, $idVisualConsole, $range, + $range_vertical, $width, $height, $period, @@ -683,7 +692,10 @@ switch ($activeTab) { $kind_relationship, $item_in_the_map, $fontf, - $fonts + $fonts, + $pos_x, + $pos_y, + $max_elements_row ); } else { $id_modules = []; @@ -722,6 +734,7 @@ switch ($activeTab) { $image, $idVisualConsole, $range, + $range_vertical, $width, $height, $period, @@ -737,7 +750,10 @@ switch ($activeTab) { $kind_relationship, $item_in_the_map, $fontf, - $fonts + $fonts, + $pos_x, + $pos_y, + $max_elements_row ); } } diff --git a/pandora_console/godmode/reporting/visual_console_builder.wizard.php b/pandora_console/godmode/reporting/visual_console_builder.wizard.php index 6e644f0f6d..6a54b2c049 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.wizard.php +++ b/pandora_console/godmode/reporting/visual_console_builder.wizard.php @@ -144,22 +144,28 @@ $table->data['all_0'][0] = html_print_label_input_block( $table->rowstyle['staticgraph'] = 'display: none;'; +$table->colspan['staticgraph'][0] = 2; $table->data['staticgraph'][0] = html_print_label_input_block( __('Image'), - html_print_select( + '
'.html_print_select( $images_list, 'image', '', '', '', '', - true - ) + true, + false, + true, + '', + false, + 'width: 49%' + ).'
' ); $table->rowstyle['all_1'] = 'display: none;'; $table->data['all_1'][0] = html_print_label_input_block( - __('Range between elements (px)'), + __('Horizontal range between elements (px)'), html_print_input_text( 'range', 50, @@ -170,6 +176,18 @@ $table->data['all_1'][0] = html_print_label_input_block( ) ); +$table->data['all_1'][1] = html_print_label_input_block( + __('Vertical range between elements (px)'), + html_print_input_text( + 'range_vertical', + 50, + '', + 5, + 5, + true + ) +); + $input_size = __('Width').': '; $input_size .= html_print_input_text('width', 0, '', 5, 5, true); $input_size .= __('Height').': '; @@ -425,6 +443,16 @@ if (is_metaconsole() === false) { ); } +$table->data['all_4_01'][0] = html_print_label_input_block( + __('Filter agents'), + html_print_input_text('filter_agents', '', '', false, 255, true) +); + +$table->data['all_4_01'][1] = html_print_label_input_block( + __('Filter modules'), + html_print_input_text('filter_modules', '', '', false, 255, true) +); + $table->rowstyle['all_4'] = 'display: none;'; $table->data['all_4'][0] = html_print_label_input_block( __('Agents').ui_print_help_tip( @@ -549,6 +577,16 @@ $table->data['all_8'][1] = html_print_label_input_block( ).'' ); +$table->data['all_10'][0] = html_print_label_input_block( + __('Max. elements for row'), + html_print_input_text('max_elements_row', 0, '', false, 255, true) +); + +$table->data['all_10'][1] = html_print_label_input_block( + __('Position'), + '
X'.html_print_input_text('pos_x', 0, '', false, 255, true, false, false, '', 'w50p').'Y'.html_print_input_text('pos_y', 0, '', false, 255, true, false, false, '', 'w50p').'
' +); + if (is_metaconsole() === true) { $pure = get_parameter('pure', 0); @@ -831,6 +869,44 @@ function item_per_agent_change(itemPerAgent) { function metaconsole_init() { $("#groups").change(); } + +$('#text-filter_agents').on('keyup',function(){ + if ($(this).val() !== ''){ + findInSelect('id_agents',$(this).val()); + } else { + $('#id_agents option').each(function(){ + $(this).removeClass('invisible'); + }); + } +}); + +$('#text-filter_modules').on('keyup',function(){ + if ($(this).val() !== ''){ + findInSelect('module',$(this).val()); + } else { + $('#module option').each(function(){ + $(this).removeClass('invisible'); + }); + } +}); + +function findInSelect(selectid, find){ + var select = $('#'+selectid+' option'); + select.each(function(){ + var regex = new RegExp(find, "gi"); + if ($(this).html().match(regex) === null) { + $(this).addClass('invisible'); + } else { + $(this).removeClass('invisible'); + } + }) +} + +$('#image').on('change', function(){ + var img = $(this).val(); + $('#image_prev').html(''); +}) +