From 138fa636ad247a2d4e7817e07844a9fb309f5dd0 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 4 Jul 2023 11:06:49 +0200 Subject: [PATCH 01/97] #10637 Change group view --- pandora_console/include/styles/pandora.css | 4 + .../operation/agentes/group_view.php | 276 ++++++++++++++---- 2 files changed, 230 insertions(+), 50 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 06a3640c7c..c94cf12660 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12289,3 +12289,7 @@ tr[id^="network_component-plugin-wmi-fields-dynamicMacroRow-"] input, tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input { width: 100% !important; } + +.group_view_table > tbody > tr > td { + width: 350px !important; +} diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 34c3fc6936..204f7d937e 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -8,7 +8,7 @@ * @version 1.0.0 * @license See below * - * ______ ___ _______ _______ ________ + * ______ ___ _______ _______ ________ * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| @@ -175,7 +175,182 @@ if ($total_agentes > 0) { $total_not_init = format_numeric((($agents_notinit * 100) / $total_agentes), 2); } -echo ''; +$all_group_id = []; +foreach ($result_groups as $group) { + if ($group['_id_'] !== '0') { + $all_group_id[] = $group['_id_']; + } +} + +$out = ''; +$out .= '
'; +$out .= ''; +$out .= ''; +$out .= ''; +$out .= ''; +$out .= ''; +$out .= ''; +$out .= ''; + +$description = ''; +$odd = false; +$graph_width = 180; +$graph_height = 200; + +foreach ($result_groups as $group) { + if ($group['_id_'] !== '0') { + $description = db_get_value('description', 'tgrupo', 'id_grupo', $group['_id_']); + $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group['_id_']); + $icon = html_print_image( + 'images/'.$icon_url, + true, + [ + 'title' => $group['_name_'], + 'class' => 'main_menu_icon invert_filter', + ] + ); + + $where_event = 'WHERE te.id_grupo = '.$group['_id_']; + $where_os = 'WHERE ta.id_grupo = '.$group['_id_']; + } else { + $description = __('Data view of all groups'); + $icon = ''; + $where_event = 'WHERE te.id_grupo in ('.implode(', ', $all_group_id).')'; + $where_os = 'WHERE ta.id_grupo in ('.implode(', ', $all_group_id).')'; + } + + $group_events = db_get_all_rows_sql( + 'SELECT COUNT(te.id_evento) as count_events, ta.alias + FROM tevento as te + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente '.$where_event.' GROUP BY te.id_agente' + ); + + $group_os = db_get_all_rows_sql( + 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo + FROM tconfig_os as os + INNER JOIN tagente as ta ON ta.id_os = os.id_os '.$where_os.' GROUP by os.name' + ); + + if ($odd === false) { + $out .= ''; + } + + $out .= ''; + $out .= ''; + + if ($odd === true) { + $out .= ''; + $odd = false; + } else { + $odd = true; + } +} + +$out .= ''; +$out .= ''; +$out .= ''; +$out .= '
'.__('Summary of the status groups').'
'; + $out .= '
+ '.$group['_name_'].'   '.$icon.''; + + $out .= ''; + $out .= ''; + $out .= ''; + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
+
+ '.__('Description').''.$description.'
+
'; + if ($group['_id_'] === '0') { + $out .= tactical_groups_get_stats_alerts($all_group_id); + } else { + $out .= tactical_groups_get_stats_alerts($group['_id_']); + } + + $out .= '
'; + if ($group['_id_'] === '0') { + $out .= tactical_groups_get_agents_and_monitoring($all_group_id); + } else { + $out .= tactical_groups_get_agents_and_monitoring($group['_id_']); + } + + $out .= ''; + if ($group['_id_'] === '0') { + $out .= groups_get_stats_modules_status($all_group_id); + } else { + $out .= groups_get_stats_modules_status($group['_id_']); + } + + $out .= '
'.__('Events per agent').''; + + $data = []; + $options = []; + $labels = []; + foreach ($group_events as $value) { + $data[$value['alias']] = $value['count_events']; + $labels[] = io_safe_output($value['alias']); + } + + $options = [ + 'width' => $graph_width, + 'height' => $graph_height, + 'legend' => ['display' => false], + 'labels' => $labels, + ]; + + $out .= '
'.'
'.pie_graph($data, $options).'
'; + $out .= '
'; + $out .= '
'.__('Distribution by so').''; + + $data = []; + $options = []; + $labels = []; + foreach ($group_os as $value) { + $data[$value['name_os']] = $value['count_os']; + $labels[] = io_safe_output($value['name_os']); + } + + $options = [ + 'width' => $graph_width, + 'height' => $graph_height, + 'legend' => ['display' => false], + 'labels' => $labels, + ]; + + $out .= '
'.'
'.pie_graph($data, $options).'
'; + $out .= '
'; + $out .= '
'; + + if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) { + $out .= ''.html_print_image( + 'images/force@svg.svg', + true, + [ + 'border' => '0', + 'title' => __('Force'), + 'class' => 'main_menu_icon invert_filter', + ] + ).''; + } + + $out .= '
'; + $out .= '
'; + $out .= '
'; + +echo $out; +/* + echo ''; echo ''; echo ''; echo "'; @@ -203,15 +378,15 @@ echo '
".__('Summary of the status groups').'
'; echo ''; echo ''; echo ''; -echo '
'; + echo ''; -if ($count == 1) { + if ($count == 1) { if ($result_groups[0]['_id_'] == 0) { unset($result_groups[0]); } -} + } -if (empty($result_groups) === false) { + if (empty($result_groups) === false) { $pagination = ui_pagination( $count, false, @@ -359,10 +534,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_']."'>"; } else { - $link = ""; + $link = ""; } if ($data['_id_'] == 0) { @@ -379,10 +554,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_UNKNOWN."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_unknown != 0)) { @@ -399,10 +574,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NOT_INIT."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_notinit != 0)) { @@ -419,10 +594,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NORMAL."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_ok != 0)) { @@ -439,10 +614,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_WARNING."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_warning != 0)) { @@ -459,10 +634,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_CRITICAL."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_critical != 0)) { @@ -478,11 +653,11 @@ if (empty($result_groups) === false) { // Monitors unknown echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_unknown != 0)) { @@ -498,11 +673,11 @@ if (empty($result_groups) === false) { // Monitors not init echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_not_init != 0)) { @@ -518,11 +693,11 @@ if (empty($result_groups) === false) { // Monitors OK echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_ok != 0)) { @@ -538,11 +713,11 @@ if (empty($result_groups) === false) { // Monitors Warning echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_warning != 0)) { @@ -558,11 +733,11 @@ if (empty($result_groups) === false) { // Monitors Critical echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_critical != 0)) { @@ -578,11 +753,11 @@ if (empty($result_groups) === false) { // Alerts fired echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($all_alerts_fired != 0)) { @@ -599,6 +774,7 @@ if (empty($result_groups) === false) { } echo ''; -} else { + } else { ui_print_info_message(__('There are no defined agents')); -} + } +*/ From 6d848b9fd321c686c7d3e60c41b0783c2fae06c1 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 7 Jul 2023 12:25:49 +0200 Subject: [PATCH 02/97] #11216 Duplicate widget --- .../include/javascript/pandora_dashboards.js | 64 +++++++++++++++++++ .../include/lib/Dashboard/Manager.php | 45 +++++++++++++ pandora_console/views/dashboard/cell.php | 12 ++++ 3 files changed, 121 insertions(+) diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 5b36832b29..0d76c1a618 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -269,6 +269,10 @@ function initialiceLayout(data) { $("#configure-widget-" + id).click(function() { getSizeModalConfiguration(id, widgetId); }); + + $("#copy-widget-" + id).click(function() { + duplicateWidget(id, widgetId); + }); }, error: function(error) { console.error(error); @@ -299,6 +303,31 @@ function initialiceLayout(data) { return false; } + function duplicateWidget(original_cellId, original_widgetId) { + let duplicate_cellId = insertCellLayoutForDuplicate(); + + $.ajax({ + method: "post", + url: data.url, + data: { + page: data.page, + method: "duplicateWidget", + dashboardId: data.dashboardId, + widgetId: original_widgetId, + cellId: original_cellId, + duplicateCellId: duplicate_cellId + }, + dataType: "json", + success: function(success) { + console.log(success); + }, + error: function(error) { + console.log(error); + return []; + } + }); + } + function saveLayout() { var items = $(".grid-stack > .grid-stack-item:visible") .map(function(i, el) { @@ -394,6 +423,37 @@ function initialiceLayout(data) { }); } + function insertCellLayoutForDuplicate() { + let duplicateCellId = 0; + $.ajax({ + async: false, + method: "post", + url: data.url, + data: { + page: data.page, + method: "insertCellLayout", + dashboardId: data.dashboardId, + auth_class: data.auth.class, + auth_hash: data.auth.hash, + id_user: data.auth.user + }, + dataType: "json", + success: function(data) { + // By default x and y = 0 + // width and height = 4 + // position auto = true. + if (data.cellId !== 0) { + addCell(data.cellId, 0, 0, 4, 4, true, 0, 2000, 0, 2000, 0, true); + duplicateCellId = data.cellId; + } + }, + error: function(error) { + console.error(error); + } + }); + return duplicateCellId; + } + function configurationWidget(cellId, widgetId, size) { load_modal({ target: $("#modal-config-widget"), @@ -722,6 +782,10 @@ function initialiceLayout(data) { getSizeModalConfiguration(cellId, widgetId); }); + $("#copy-widget-" + cellId).click(function() { + duplicateWidget(cellId, widgetId); + }); + saveLayout(); } }); diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 9d2c0d4356..40b6d2d1a0 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -160,6 +160,13 @@ class Manager implements PublicLogin */ private $publicLink; + /** + * Duplicate Id Cell. + * + * @var integer + */ + private $duplicateCellId; + /** * Allowed methods to be called using AJAX request. * @@ -181,6 +188,7 @@ class Manager implements PublicLogin 'formSlides', 'callWidgetMethod', 'getSizeModalConfiguration', + 'duplicateWidget', ]; @@ -283,6 +291,7 @@ class Manager implements PublicLogin $this->widgetId = (int) $extradata['widgetId']; } else { $this->cellId = (int) \get_parameter('cellId', []); + $this->duplicateCellId = (int) \get_parameter('duplicateCellId', []); $this->offset = (int) \get_parameter('offset', 0); $this->dashboardId = (int) \get_parameter('dashboardId', 0); @@ -597,6 +606,42 @@ class Manager implements PublicLogin } + /** + * Duplicate widget. + * + * @return integer + */ + public function duplicateWidget():int + { + $original_widget = []; + + $original_cellId = $this->cellId; + foreach ($this->cells as $cells) { + if ($cells['id'] == $original_cellId) { + $original_widget['id_widget'] = $cells['id_widget']; + $original_widget['options'] = $cells['options']; + break; + } + } + + $options = json_decode($original_widget['options'], true); + $options['title'] = __('Copy of %s', $options['title']); + $options_json = json_encode($options); + + $values = [ + 'options' => $options_json, + 'id_widget' => $original_widget['id_widget'], + ]; + $res = \db_process_sql_update( + 'twidget_dashboard', + $values, + ['id' => $this->duplicateCellId] + ); + return $res; + + } + + /** * Copy Dashboard and asociate widgets. * diff --git a/pandora_console/views/dashboard/cell.php b/pandora_console/views/dashboard/cell.php index ae8545e2ce..919ce9e07e 100644 --- a/pandora_console/views/dashboard/cell.php +++ b/pandora_console/views/dashboard/cell.php @@ -47,6 +47,18 @@ $output .= '
'; if ($manageDashboards !== 0 || $writeDashboards !== 0) { if ((int) $cellData['id_widget'] !== 0) { + $output .= ''; + $output .= html_print_image( + 'images/copy.svg', + true, + [ + 'width' => '16px', + 'title' => __('Copy widget'), + 'class' => 'invert_filter', + ] + ); + $output .= ' '; + $output .= ''; $output .= html_print_image( 'images/configuration@svg.svg', From 1c411483906dc141eb18e8a8ab0d284ded2fca9c Mon Sep 17 00:00:00 2001 From: Calvo Date: Thu, 13 Jul 2023 14:54:32 +0200 Subject: [PATCH 03/97] Fix cron and periodically module planned downtimes --- pandora_server/lib/PandoraFMS/Core.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index c6e87003f7..011c9cfb57 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2385,7 +2385,8 @@ sub pandora_planned_downtime_cron_start($$) { $dbh, $downtime->{'id'}); } elsif (($downtime->{'type_downtime'} eq "disable_agents") - || ($downtime->{'type_downtime'} eq "disable_agents_alerts")) { + || ($downtime->{'type_downtime'} eq "disable_agents_alerts") + || ($downtime->{'type_downtime'} eq "disable_agent_modules")) { pandora_planned_downtime_set_disabled_elements($pa_config, $dbh, $downtime); } @@ -2436,7 +2437,8 @@ sub pandora_planned_downtime_cron_stop($$) { $dbh, $downtime->{'id'}); } elsif (($downtime->{'type_downtime'} eq "disable_agents") - || ($downtime->{'type_downtime'} eq "disable_agents_alerts")) { + || ($downtime->{'type_downtime'} eq "disable_agents_alerts") + || ($downtime->{'type_downtime'} eq "disable_agent_modules")) { pandora_planned_downtime_unset_disabled_elements($pa_config, $dbh, $downtime); } @@ -2828,7 +2830,8 @@ sub pandora_planned_downtime_monthly_start($$) { pandora_planned_downtime_set_quiet_elements($pa_config, $dbh, $downtime->{'id'}); } elsif (($downtime->{'type_downtime'} eq "disable_agents") - || ($downtime->{'type_downtime'} eq "disable_agents_alerts")) { + || ($downtime->{'type_downtime'} eq "disable_agents_alerts") + || ($downtime->{'type_downtime'} eq "disable_agent_modules")) { pandora_planned_downtime_set_disabled_elements($pa_config, $dbh, $downtime); } @@ -2906,7 +2909,8 @@ sub pandora_planned_downtime_monthly_stop($$) { $dbh, $downtime->{'id'}); } elsif (($downtime->{'type_downtime'} eq "disable_agents") - || ($downtime->{'type_downtime'} eq "disable_agents_alerts")) { + || ($downtime->{'type_downtime'} eq "disable_agents_alerts") + || ($downtime->{'type_downtime'} eq "disable_agent_modules")) { pandora_planned_downtime_unset_disabled_elements($pa_config, $dbh, $downtime); @@ -3016,7 +3020,8 @@ sub pandora_planned_downtime_weekly_start($$) { $dbh, $downtime->{'id'}); } elsif (($downtime->{'type_downtime'} eq "disable_agents") - || ($downtime->{'type_downtime'} eq "disable_agents_alerts")) { + || ($downtime->{'type_downtime'} eq "disable_agents_alerts") + || ($downtime->{'type_downtime'} eq "disable_agent_modules")) { pandora_planned_downtime_set_disabled_elements($pa_config, $dbh, $downtime); } @@ -3131,7 +3136,8 @@ sub pandora_planned_downtime_weekly_stop($$) { $dbh, $downtime->{'id'}); } elsif (($downtime->{'type_downtime'} eq "disable_agents") - || ($downtime->{'type_downtime'} eq "disable_agents_alerts")) { + || ($downtime->{'type_downtime'} eq "disable_agents_alerts") + || ($downtime->{'type_downtime'} eq "disable_agent_modules")) { pandora_planned_downtime_unset_disabled_elements($pa_config, $dbh, $downtime); } From 42540065cd9b51a8413e2903a4ba218677d5e912 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 17 Jul 2023 08:30:47 +0200 Subject: [PATCH 04/97] #11490 new widget group status map --- .../images/widgets/groups_status_map.png | Bin 0 -> 7087 bytes .../include/graphs/functions_d3.php | 6 +- pandora_console/include/graphs/pandora.d3.js | 41 +- .../include/lib/Dashboard/Widget.php | 4 + .../Dashboard/Widgets/groups_status_map.php | 401 ++++++++++++++++++ 5 files changed, 435 insertions(+), 17 deletions(-) create mode 100644 pandora_console/images/widgets/groups_status_map.png create mode 100644 pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php diff --git a/pandora_console/images/widgets/groups_status_map.png b/pandora_console/images/widgets/groups_status_map.png new file mode 100644 index 0000000000000000000000000000000000000000..622fa7575807c939a81ab49f85c7555dc1d9e6ba GIT binary patch literal 7087 zcmV;g8&KqlP)RlvZrtCE#GQo`NA)|w5y=s3UB7fdOqWMaMRn|vFJ(fl-ngfY6={Qn855EdG9mqc z-(;e{JQ<5tZOVuh=4+$`!pt{c8zD^caSb247g@7t+Kdff{K%!Uva+~v)%%m@3-RoT z#!Y!|{=7HFSP4>x4lx%d{B!XPl7^6yD+D2eTwF_l%jdtgMX@{)$$)TedPZx;N(Wh4reMOzglob)h;u}#n=+yq zmi3orO4HC-0j7a^k|S9C{?xfrB2uSzMV_{5?#S2>J$?LmS( za)=}kLY^pjNMG)4CG89vryLB3L^c6H`Y`;PWy|3uLBqsN1UFV&D;L5n77I^BeVUQs zW4z6_=OHd4d>00Iq_&;WkY*&?U{|H>4rggygfj-t@(6Pw4lhWFc0xj>aatFYHGX(( zF(*igkkt#PzWd9m6ORi86crVrwHx>L@(&HG62j%;S|vhW9P&seYh5Iw-?V8H3TxgO zO`SCCXuEdpn7_ZZqNfN!l5pAX0N=;Q2TgpgFHbshdOMVyoQwwcu6{|+pFdCYnGPa~ z1Vu$f8HMzl7o0~|u3X_kQ)Vse&nFy2WM6a#xajopLyh-*o%VJ2?%kQ6e)>r>_1(4I z9pOshc7nElwlrbu_AeGn5y|^MiLz%MX#kR7@960|7@RZg6Axh6{MtFa>SHk%r_>CPRy0&iv)QhK*|^z z!1&~Ziv-RIN=?rUX3Qn62~f?DGzPA(b4LgaVm7RvD}G6wXhurOt_yNRll$wT%vrN$ ziLzU@YUS|#5+Z_CihA$n!4;g4ZM#k)=H7Va?B!cr4=#MEh0KLjfAxfE1dbaw&}_3imEM+?RE?w(GlY15|s z$52U~xfE2tewf|ZZrudYv=f<(6%B+I$i?kG69frb7h^F8RFs!iU|8@cpC3Ul4SQ5n zRI4@~L=#5Eqxk+qHe_8o6JqeuSt1^a7He^jp=_($wB}#KlE=OAIT1>R);Dh4KoJq* z;oh7%b5MAjK77x5ZkM<={$S zc6Fp=(4lkyBUHey=%j-VKqey_La1~AL+~NA6C})pxU12P6yH(WsUW#&m>eS|%Gfmq zCBrDCLo%Wi4C(9ywQBJYnlxz=hXeCQmbJ|rVXnAs-#HZB`H?w`KX`vFAW3lmhKI~H zBAnJ5=xdatl?El_HDD_IOgI|*!S{&!l#{O@5UTz7HlfbFn2=D(4^F%x%n}-L_SGla zm_T`65F~JYP`In<3UN;!jZSNPd3c}mLLMSP!VDNRQf4+v2y+&vX|`zmh{tTRGYPUo zK@vPs5|q$dtqt87E{hnrNPyB7jV8y@@Y)%6kvpwM7Hj^mLNSxBd)QIAe7kk!hf{K7I6UO$k_>(Qf!W%vuP_ffJ6=Sn@; zFQ8J>55@@BOk5E;%3rx4<=C0ir(G_j$HFg&coi4&){hc#>p)0P@N ztd+etKdceCjR=o+xJeq!onV?NH3pVM7a!?`It|jHwQv2zEsp{<;KJMro~NIF8fENC z=eH|3U=9A+4d-gW1L4(9uBpL9Q0{@HSMK2^S2hgcI&fiOAqs04QEiFb1d=-Y!lbY%1U(S&K;DOm&g4}eVL zLdssL9*f={SG^r7&2W%*%b;7=e;Xv-DFwbAd-Ta>gQ8-iqob`2>ILwk;N7@&>lV6s z^CtI~ot=$>gM;~eKVLmMd-g2q)TP_bf6Pw(6Q3c7OnGO`pI|>#0CF02%OIzmaAwNe zt9rmh8dm#BjdknR4Rz_#h5rK{P;)UIJ2H>NJ+|oZ>AcvNU;kjHE8a@;Re6V`!d{!T zIt~U~*f?nxpPo2#*dFR6NNkp-8KeRQdfR{pdn>p!VxZNPlU_T;*wysbne7qeRG_x zj>^$0G6qVW39W32%vH8on;bW9z;yaDy3psUlG<}>4DQ{+unXuz-q5ioJaLcqJ9g&C zcSI{|Oj_D*|1w$^?TDzh;Q@^K;^@(daT(AB* zt8B=cC2vfvEH4>0fBt;>!v)iL*|75Y=9_QM+qZ9@b@0enl3GW_6!DoJMDA6@b!ye- zj7YqAUEc#=|@kTIDtY!Yz{DmC3wpuNZhA@YtHsBckEPat&P%9cQtAn zlD>Z7A#e!>LoWT6!yCDIhs}NH)cG4696a7OZdm^~>=W^b9z?(n)p{kgY^J@;@ z9kKPANqyS$YW{HY3Ll4!uJ_(s&=!tX@IVhDsu%Bitou+1%E*2;qPao_uA+ zc^+?x054UHftMYc)|Kmd+};f^mV2yLE1Eg8dN~^Qc&^^49+~`f{5ZXC`Rp-rH15C@ zE$2F82;FbrKSk|=O($p1JMX-MzS+MC72GtVtSnnoBQ)6Uk#)x_p3n(Hk81|LBhC!@ z{`>FIqe;=I;^D2RMRyJQ;)^eZ^7**0udkh}C7-D<;;}LCK_s%E>736J`(uwCHx?yL zHX#3c6uPj7=J!QOlQdOTFPTDT;OWEnJ~d?oUv@$(eYpX?^uwiS!KxI*;JM_Qf3GK~ zs1@!Mg!tLncRa2ckBxyL3Vhjx4iUV@IFgu{i2rzha$%Mze)HxHk7uoJcL3SHX9es? zPkrsNKaXC%_p49;+5hq6Mb|FXa9oE+PDjo`uVHtd^{v@|Tp%jqSBIZ7+;02(%JzS9vCfWzo_#E6lR zFxG-03OwMd;_LxKp8U(WBxg9T>vmfmLPijuG-KKGa~CXL1l#Gbt?uZ7 zcLcWOVT&I8-5ucpT!~yluUgFzhNCCEwHe1ZC-hGolbd~W5`5X=g9zUd=ze|u{LjZd z_Uts=v_vmEp_hj4)QnCUsW3#m&r}67ooU39&nJ6@6#m zdV|uEqIh>4AV8-k&0Fjk@?46@wF7vWOeWg|N20tmNgOZacu8?xHZyRRKY1>T&^hcv zu?Hl&UM$+`MBnfGCJuXWyiN>~@FG0zLK$9hQeJjM7~ry*#lVIh5$nE{!b#| zkrFj|*(rblE{%~RlETWX#5E$#cPH%$FI9}mtFecsy_ufy^4OUC3iWEmQ(hh$Q)csQ zv@d2iA)fN`$e0_F-pfthMd)hqs}k;ne^Q)sC;dsDFoYv( zB&{Yd!c!Q!G^SI>j%e-LwL%)V;xRFuej@~G@*+Hip-W>jGBQ{^$)dDct>_FNFo83B z@ZjxqE|mUTv0?>k(Y8w(fvd@j@DzrMwlp@aSunJ+qFgkdDlaYSHfq$!&cN)GPd-8Q z!Ww@pWDN24oqFx;+4u2lLb#f|gnVI3gDYBhT(*FL@NgrfH5v^*o?=Bk+qz?4pGNOIyiZawo-AJ*}3DmYib$_0Ds0MoD4d zU}yFz3i8wI{3@|aBf_qYT3V0Y8qKn9jVyL+WNX{4QEEg@)2W%b>0U*CR;|fkHCYV! zat#Ca#x4+7jJbcLUu zeolV}-3>Na%|R5S3H)#L0CQv`c!sgGwN$6kl?0&r#lwfUS8@HoCRLTnS@zj~f@sz^ zoYJtilaDqT|5Gv6N)U<9yy%ihMcRomEI0T1xSCBSGb*{_TkkgepHfYZu>nL&kK*V@Xca|~3h z=Kpp|LnDh{l{rh!k)D){Y~{dJBo?E!4Z~Pu^9k{T(DM?YX)UYu)%^O`r+Sx4xrqut zJw2T+tZLYfp={UCN(mmMy;A}-OIL;JbIuPRKAa&E_{vF3`vsq+xm#z?(h!B=O6QZu z_a~N@7WOk%l!L1!g}p-Hw8jUp0XR)`)1^>X%{at(X+b!o+ zMR?bRFo3C#&kS`c2VJr zb?eZIl`EMllc}m+c(axFT!7qRb6;@F@u9BQ@u4niHp^-nf409fqmkYgbYJvvDCEke zll69OTes9=F-I+0v`9ld+#C^{IQu&~_VaJ3cWfKfF}kTEG#(B&uTGgV#j4fnE+suX zCdHK_8Bcg0BD9rdv!CntGX=l&!c?qVF@aP~!%{=$XVWJe)+pS99plp;m*h|8BJo z`w-rqgtU+LHnsY*eeK}xa!(kkMGLp(eY0i7*Z2nye5F@t6B)3_y8F<1q@gMPM-fP# zTzKHeOWgi!{Jp!SVw+9gI(om^4_eBW8|dDS_jYTt<4(u)j9LyUP5)KnbBY zaNt9~>x+-SnLK&2Vd~VWoCsrO721FFB7!p#{hFo8{(iyVHf;J3=Nzv@hF5TCEsZOvZk(+>{N1+q z;C{)MU$*TA`xx}7erNz!n9!ZM^PD+z20b}=5Nh4J6^e>(!=Jr^Q*+mE7og5C>lC zmDz+ZJ=CJM2|Dzj_f04~uoc?z)z_SJgB-0824`(zV`EWd>zFsZaWq&c%T?T^uZ=4P zYUCFczeqR8Y*#$w-!62(CUfU#->Ihd-@CvE91MRt$W@ZsioA+qp$3 zJJ)t$C1DJ@fKDV`TVb7ebNqusF5n^U0AV4(kXY&S&DYMu7G;q1J^nv@C zFI~MOI?FG`fi#@Ggi5+_{sQ-Xaa1vvuI3rpMTi@7GCC}@cGT6xW|SpIQ-rA=~mWiz<#5Jz5742M5{MknKo@&%cP_v z4O}k^Pww4P1fw)Koj9O3ETf4ZxV{-a;Bx+@(A9;7g&}``@%JjCaVS^WoA6}~N%0*- z-y2xs!8%y6E?3P~Gqviy$qOuuB}7AMOw~GXdxNo9@NO@~5}R7IiTU^75#x`FHB%?$ zwb9!8m9t+oo6SKlzA|SSEQ>2q7w%Xvn<|DKK6Ho{Ug04}3+G?KA-G8s$BP^J`T3}< ztPDj)M#`}e!QgW7xITRtoxxA>mGH2o^6Bzfuj1)Z$qN%_e=1_ALc%NE+Ny<9=adxW zKRPyL-cqF%1Gd1e>jA+HK7>QZu=eHb(d+dH3g6iS7059B3cN#9kOeY9wmUb!gKc0V z*a|i~6i~wquXJl+;Z2UzP#**<#rP7OZPTVr{}?Z+w838FTIu>4@NU$o5%(w8r4iX( zyE^|>7WnYL^wLX~iVEYe6DBYCYfXP=pixB2bRtvD&?}WAI10R{Cdxt~!4YM+sc6*m zFU%|}DSCYL=+P)8B}H^&5%4DG8kEX`?rZ7Nr6?^e4Fv>+?0kOg^ml7oDMY5H_7XnQ z&?}YW&H-AfLc%l@+P#(HnXo8|e{f=KS#iNo{H>wzS{OBO;6P1$e7wU|1sE(GJa`c8 z*|W!b;J^VE|Iid05L|C-!V}4B@eMOYLRp@~)v{NrgI6lY8!ZV|id#od&^!`<~eJYOrKj^ke?LYw!O7Mc(^7nH-{^? z2I01yN_PuV?gyuZJnrUZTdrkY)CL9D+xfSt@6QzGk+@VZ0{0}8)2krA+TMC$4UrPP zl*;$Ga^QjryioY`rmbJ8HfJg@vZ%zQ%!J7=47L>J=k1XG;zwQ8OPN*GSRNNB+#CXL zi#tM{;pUbruNdG{KfJM4?)H+ps+Tj{rFmZY=17GoP2a{pKU3v;La&saYIwD!SDmOF zGrn-}b_t6VEx@T(19+iVfWJY}TZC!inl3q|RTKs!ICe{OwPm9?UaWeBb z8vayLt&}zV2q#`si;xPht9nWGbd-jA(NezpLi|I0zK)Pw!2^RskNWxOnr+^^`Mz|K zutflSIAp8fsi&T@R8*Snwu$SiUarcM`)Cig%vR&AIUkzR-sX2?@mmV;B?@ z4_^|u4V3W&k;41+_*?_Qsa6Tnfq{XNnGWC(9)MRJFDfe3;9X8OykW%h=O?|rp_+sE ze_ho}tfhU5KV<+}_v?Jlq1~TH<=(m7Jm>bcM4guEgKzfdR~GOOO@JdgYThz>roqRz zv`4SRpBq2a`o8!p*EPNP^Ess6ym_*1|ISVAPafUB9$%`A@CF&@7K@!f?7U{cVFT_1 zgI}k{H@36*a@rp!Ok4bSqNCbjUDV6&WE(O1!I@A}68ArJdL~q;&V$p`!qV_=T=8jY zsTvRNA&{1cdg&V9Lm*WF4_zPJ;2|xP8m3jd!NZaK2Y25%Dj9pY*YCcu7b%8tw?^sl ztx@I&w?@_atx@8tkx#*WYi0PpHS7@n;J!8aB60~8PtjeXtA}8BQz4CSDzrSfsZdzL Z{}0?nkoxL(+8zJ^002ovPDHLkV1hziu^s>b literal 0 HcmV?d00001 diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 0cba3c045d..5c8bb9578e 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -83,7 +83,7 @@ function d3_relationship_graph($elements, $matrix, $width=700, $return=false) } -function d3_tree_map_graph($data, $width=700, $height=700, $return=false) +function d3_tree_map_graph($data, $width=700, $height=700, $return=false, $id_container='tree_map') { global $config; @@ -91,7 +91,7 @@ function d3_tree_map_graph($data, $width=700, $height=700, $return=false) $data = json_encode($data); } - $output = "
"; + $output = '
"; $output .= include_javascript_d3(true); $output .= ''; $output .= ""; if (!$return) { diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 0c39ca55aa..bc72722b2f 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -404,13 +404,19 @@ function treeMap(recipient, data, width, height) { var isIE = true; var chartWidth = width; var chartHeight = height; - var consoleStyle = document.getElementById("hidden-selected_style_theme") - .value; - $("#tooltip").css( + const uniqueId = generateUniqueId(); + if (document.getElementById("hidden-selected_style_theme") !== null) { + var consoleStyle = document.getElementById("hidden-selected_style_theme") + .value; + } else { + var consoleStyle = ""; + } + + $("#tooltip_" + uniqueId).css( "color", consoleStyle === "pandora_black" ? "rgb(240, 240, 240)" : "rgb(0, 0, 0)" ); - $("#tooltip").css( + $("#tooltip_" + uniqueId).css( "background-color", consoleStyle === "pandora_black" ? "rgb(0, 0, 0)" : "rgb(240, 240, 240)" ); @@ -543,7 +549,7 @@ function treeMap(recipient, data, width, height) { .append("rect") .classed("background", true) .style("fill", function(d) { - return color(d.name); + return d.color ? d.color : color(d.name); }); childEnterTransition @@ -743,11 +749,11 @@ function treeMap(recipient, data, width, height) { } function move_tooltip(d) { - x = d3.event.pageX + 10; - y = d3.event.pageY + 10; + x = d3.event.layerX + 15; + y = d3.event.layerY + 15; - $("#tooltip").css("left", x + "px"); - $("#tooltip").css("top", y + "px"); + $("#tooltip_" + uniqueId).css("left", x + "px"); + $("#tooltip_" + uniqueId).css("top", y + "px"); } function over_user(d) { @@ -769,17 +775,17 @@ function treeMap(recipient, data, width, height) { } function create_tooltip(d, x, y) { - if ($("#tooltip").length == 0) { + if ($("#tooltip_" + uniqueId).length == 0) { $(recipient).append( $("
") - .attr("id", "tooltip") + .attr("id", "tooltip_" + uniqueId) .html(d.tooltip_content) ); } else { - $("#tooltip").html(d.tooltip_content); + $("#tooltip_" + uniqueId).html(d.tooltip_content); } - $("#tooltip").attr( + $("#tooltip_" + uniqueId).attr( "style", "background: #fff;" + "color: #111;" + @@ -809,7 +815,14 @@ function treeMap(recipient, data, width, height) { } function hide_tooltip() { - $("#tooltip").hide(); + $("#tooltip_" + uniqueId).hide(); + } + + function generateUniqueId() { + const timestamp = new Date().getTime(); + const randomNum = Math.floor(Math.random() * 10000); + const uniqueId = `${timestamp}-${randomNum}`; + return uniqueId; } } diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 245c9f0481..46e26c557c 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -300,6 +300,10 @@ class Widget $className .= '\GroupsStatusWidget'; break; + case 'groups_status_map': + $className .= '\GroupsStatusMapWidget'; + break; + case 'maps_made_by_user': $className .= '\MapsMadeByUser'; break; diff --git a/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php b/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php new file mode 100644 index 0000000000..ec21deb601 --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php @@ -0,0 +1,401 @@ +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 = __('Group status map'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'groups_status_map'; + } + + $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['groups']) === true) { + $values['groupId'] = $decoder['groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['groupRecursion']) === true) { + $values['groupRecursion'] = $decoder['groupRecursion']; + } + + 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(); + $values['groupId'] = explode(',', $values['groupId']); + // Restrict access to group. + $inputs[] = [ + 'label' => __('Groups'), + 'arguments' => [ + 'type' => 'select_groups', + 'name' => 'groupId', + 'returnAllGroup' => true, + 'privilege' => 'AR', + 'multiple' => true, + 'selected' => $values['groupId'], + 'return' => true, + ], + ]; + + $inputs[] = [ + 'label' => __('Group recursion'), + 'arguments' => [ + 'name' => 'groupRecursion', + 'id' => 'groupRecursion', + 'type' => 'switch', + 'value' => $values['groupRecursion'], + ], + ]; + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost():array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + $values['groupId'] = \get_parameter('groupId', 0); + $values['groupRecursion'] = \get_parameter_switch('groupRecursion', 0); + + return $values; + } + + + /** + * Draw widget. + * + * @return string; + */ + public function load() + { + global $config; + + $size = parent::getSize(); + include_once $config['homedir'].'/include/graphs/functions_d3.php'; + include_once $config['homedir'].'/include/functions_reporting.php'; + include_once $config['homedir'].'/include/functions_graph.php'; + $groups_array = (empty($this->values['groupId']) === false) ? explode(',', $this->values['groupId']) : []; + + if ((bool) $this->values['groupRecursion'] === true && in_array('0', $groups_array) === false) { + foreach ($groups_array as $key => $group) { + $children = groups_get_children($group, false, 'AR', false); + foreach ($children as $key => $child) { + $groups_array[] = $child['id_grupo']; + } + } + } + + $where = ''; + if (in_array('0', $groups_array) === false && count($groups_array) > 0) { + $where = ' WHERE g.id_grupo IN ('.implode(',', $groups_array).') '; + } + + $sql = 'SELECT g.id_grupo, g.nombre, estado, count(*) AS total_modules + FROM tagente a + LEFT JOIN tgrupo g ON g.id_grupo = a.id_grupo + LEFT JOIN tagente_modulo m ON a.id_agente = m.id_agente + LEFT JOIN tagente_estado es ON es.id_agente_modulo = m.id_agente_modulo + '.$where.' + GROUP BY a.id_grupo, estado'; + $rows = db_process_sql($sql); + + $level1 = [ + 'name' => __('Module status map'), + 'children' => [], + ]; + $names = []; + foreach ($rows as $key => $row) { + $color = ''; + $name_status = ''; + switch ($row['estado']) { + case '1': + $color = '#e63c52'; + $name_status = __('Critical'); + break; + + case '2': + $color = '#FFB900'; + $name_status = __('Warning'); + break; + + case '0': + $color = '#82b92e'; + $name_status = __('Normal'); + break; + + case '3': + $color = '#B2B2B2'; + $name_status = __('Unknown'); + break; + + case '4': + $color = '#4a83f3'; + $name_status = __('No data'); + break; + + default: + $color = '#B2B2B2'; + $name_status = __('Unknown'); + continue; + } + + $level1['children'][$row['id_grupo']][] = [ + 'id' => uniqid(), + 'name' => $row['estado'], + 'value' => $row['total_modules'], + 'color' => $color, + 'tooltip_content' => $row['total_modules'].__(' Modules(%s)', $name_status), + ]; + $names[$row['id_grupo']] = $row['nombre']; + } + + $level2 = [ + 'name' => __('Module status map'), + 'children' => [], + ]; + foreach ($level1['children'] as $key => $group) { + $level2['children'][] = [ + 'id' => uniqid(), + 'name' => $names[$key], + 'children' => $group, + ]; + } + + $id_container = 'tree_map_'.uniqid(); + $output = d3_tree_map_graph($level2, $size['width'], $size['height'], true, $id_container); + return $output; + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('Group status map'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'groups_status_map'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 330, + ]; + + return $size; + } + + +} From 04a45e84a87cccf2e47fcd975efbfc68c5cbff09 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 19 Jul 2023 12:50:39 +0200 Subject: [PATCH 05/97] #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 06/97] 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 28b8eeca61fa8fa21149114d8205192e8c28189c Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Thu, 10 Aug 2023 09:13:48 +0200 Subject: [PATCH 07/97] 11423-Graph analytics (WIP) --- .../include/styles/graph_analytics.css | 81 +++++ pandora_console/include/styles/pandora.css | 1 + pandora_console/operation/menu.php | 6 + .../operation/reporting/graph_analytics.php | 299 ++++++++++++++++++ 4 files changed, 387 insertions(+) create mode 100644 pandora_console/include/styles/graph_analytics.css create mode 100644 pandora_console/operation/reporting/graph_analytics.php diff --git a/pandora_console/include/styles/graph_analytics.css b/pandora_console/include/styles/graph_analytics.css new file mode 100644 index 0000000000..d2169913f6 --- /dev/null +++ b/pandora_console/include/styles/graph_analytics.css @@ -0,0 +1,81 @@ +/* .options-graph-analytics { + position: sticky; + top: 110px; + width: -webkit-fill-available; + width: -moz-available; + height: 18px; + margin: -25px -25px 25px -25px; + padding: 10px 20px; + z-index: 1; + font-weight: bold; + display: flex; + min-width: fit-content; + background-color: var(--secondary-color); + border: 1px solid #e5e9ed; +} */ + +div#menu_tab ul li, +div#menu_tab ul li span { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-items: center; + font-size: 14px; + cursor: pointer; +} + +div#menu_tab ul.mn li.nomn.tab_operation img { + margin-right: 3px; +} + +div#menu_tab ul li:hover, +div#menu_tab ul li span:hover { + box-shadow: none; +} + +div.main-div { + display: flex; + flex-direction: row; + flex-wrap: nowrap; +} + +div.padding-div { + margin: 0; + padding: 10px; +} + +div.filters-div { + min-width: 400px; + border-right: 1px solid var(--border-dark-color); +} + +div.graphs-div { + width: 100%; +} + +.handle-graph { + cursor: grab; +} + +#sortable-graphs { + display: flex; + flex-direction: column; + flex-wrap: nowrap; + justify-content: center; +} + +#sortable-graphs .drop-zone-sortable { + background-color: (--primary-color); + width: 100%; + height: 20px; + border: 2px dashed var(--border-dark-color); + border-radius: 6px; +} + +.interval-div { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: center; + margin-bottom: 10px; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index c1d700d749..02797a7deb 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -32,6 +32,7 @@ --secondary-color: #ffffff; --input-border: #c0ccdc; --border-color: #eee; + --border-dark-color: #e1e1e1; --text-color: #333; } diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 19d12e5a03..e64dbe30c7 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -471,6 +471,12 @@ if ($access_console_node === true) { 'godmode/reporting/graph_builder', ]; + + // Graph analytics. + $sub['operation/reporting/graph_analytics']['text'] = __('Graph analytics'); + $sub['operation/reporting/graph_analytics']['id'] = 'Graph_analytics'; + + if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, 'RW') || check_acl($config['id_user'], 0, 'RM') diff --git a/pandora_console/operation/reporting/graph_analytics.php b/pandora_console/operation/reporting/graph_analytics.php new file mode 100644 index 0000000000..533082c4b3 --- /dev/null +++ b/pandora_console/operation/reporting/graph_analytics.php @@ -0,0 +1,299 @@ + ''.html_print_image( + 'images/change-active.svg', + true, + [ + 'title' => $title_tab, + 'class' => 'invert_filter main_menu_icon', + ] + ).$title_tab.'', +]; + +$title_tab = __('New'); +$tab_new = [ + 'text' => ''.html_print_image( + 'images/plus-black.svg', + true, + [ + 'title' => $title_tab, + 'class' => 'invert_filter main_menu_icon', + ] + ).$title_tab.'', +]; + +$title_tab = __('Save'); +$tab_save = [ + 'text' => ''.html_print_image( + 'images/save_mc.png', + true, + [ + 'title' => $title_tab, + 'class' => 'invert_filter main_menu_icon', + ] + ).$title_tab.'', +]; + +$title_tab = __('Load'); +$tab_load = [ + 'text' => ''.html_print_image( + 'images/logs@svg.svg', + true, + [ + 'title' => $title_tab, + 'class' => 'invert_filter main_menu_icon', + ] + ).$title_tab.'', +]; + +$title_tab = __('Share'); +$tab_share = [ + 'text' => ''.html_print_image( + 'images/responses.svg', + true, + [ + 'title' => $title_tab, + 'class' => 'invert_filter main_menu_icon', + ] + ).$title_tab.'', +]; + +$title_tab = __('Export to custom graph'); +$tab_export = [ + 'text' => ''.html_print_image( + 'images/module-graph.svg', + true, + [ + 'title' => $title_tab, + 'class' => 'invert_filter main_menu_icon', + ] + ).$title_tab.'', +]; + +ui_print_standard_header( + __('Graph analytics'), + 'images/menu/reporting.svg', + false, + '', + false, + [ + $tab_export, + $tab_share, + $tab_load, + $tab_save, + $tab_new, + $tab_start_realtime, + ], + [ + [ + 'link' => '', + 'label' => __('Reporting'), + ], + ] +); + +// Header options. +// $options_content = 'Sample text'; +// html_print_div( +// [ +// 'class' => 'options-graph-analytics', +// 'content' => $options_content, +// ] +// ); +// Content. +$left_content = ''; +$right_content = ''; + +$left_content .= ' +
+
+ 6 + +
+
+ +
+
+ 7 + +
+
+'; + +$intervals = []; +$intervals[SECONDS_1HOUR] = human_time_description_raw(SECONDS_1HOUR, true, 'large'); +$intervals[SECONDS_6HOURS] = human_time_description_raw(SECONDS_6HOURS, true, 'large'); +$intervals[SECONDS_12HOURS] = human_time_description_raw(SECONDS_12HOURS, true, 'large'); +$intervals[SECONDS_1DAY] = human_time_description_raw(SECONDS_1DAY, true, 'large'); +$intervals[SECONDS_2DAY] = human_time_description_raw(SECONDS_2DAY, true, 'large'); +$intervals[SECONDS_1WEEK] = human_time_description_raw(SECONDS_1WEEK, true, 'large'); + +$right_content .= '
'.html_print_select( + $intervals, + 'interval', + SECONDS_12HOURS, + '', + '', + 0, + true, + false, + false, + '' +).'
'; + +$right_content .= ' +
+
+ 1 + +
+
+ 2 + +
+
+ 3 + +
+
+ 4 + +
+
+ 5 + +
+
+'; + +$filters_div = html_print_div( + [ + 'class' => 'padding-div filters-div', + 'content' => $left_content, + ], + true +); + +$graphs_div = html_print_div( + [ + 'class' => 'padding-div graphs-div', + 'content' => $right_content, + ], + true +); + +html_print_div( + [ + 'class' => 'white_box main-div', + 'content' => $filters_div.$graphs_div, + ] +); + + +?> + + \ No newline at end of file From df91ea25b5eb46539b327c35fc6d70fed643aa91 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 11 Aug 2023 09:18:50 +0200 Subject: [PATCH 08/97] #10622 massive policies alerts and external --- .../massive/massive_add_policies_alerts.php | 284 ++++++++++++++++ ...ve_add_policies_alerts_action_external.php | 288 ++++++++++++++++ .../massive_delete_policies_alerts.php | 320 ++++++++++++++++++ ...delete_policies_alerts_action_external.php | 320 ++++++++++++++++++ .../godmode/massive/massive_operations.php | 66 ++++ pandora_console/godmode/menu.php | 2 + 6 files changed, 1280 insertions(+) create mode 100644 pandora_console/godmode/massive/massive_add_policies_alerts.php create mode 100644 pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php create mode 100644 pandora_console/godmode/massive/massive_delete_policies_alerts.php create mode 100644 pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php diff --git a/pandora_console/godmode/massive/massive_add_policies_alerts.php b/pandora_console/godmode/massive/massive_add_policies_alerts.php new file mode 100644 index 0000000000..0b38c96b1b --- /dev/null +++ b/pandora_console/godmode/massive/massive_add_policies_alerts.php @@ -0,0 +1,284 @@ +id = 'add_table'; +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->data = []; +$table->style = []; +$table->style[0] = 'font-weight: bold; vertical-align:top'; +$table->style[2] = 'font-weight: bold; vertical-align:top'; +$table->size = []; +$table->size[0] = '50%'; +$table->size[1] = '50%'; + +$table->data = []; + +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AW', + true, + 'id_group', + 0, + '', + 'All', + 0, + true, + false, + true, + '', + false, + 'width:100%;' + ) +); + +$table->data[0][1] = html_print_label_input_block( + __('Group recursion'), + html_print_checkbox('recursion', 1, $recursion, true, false, '', true) +); + +$arr_policies = policies_get_policies(); +$policies = []; +foreach ($arr_policies as $row) { + $policies[$row['id']] = $row['name']; +} + +$table->data[1][0] = html_print_label_input_block( + __('Policies'), + html_print_select( + $policies, + 'id_policies[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); + +$table->data[1][1] = html_print_label_input_block( + __('Alerts'), + html_print_select( + [], + 'id_alerts[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); +$actions = alerts_get_alert_actions(); +$table->data[2][0] = html_print_label_input_block( + __('Action'), + html_print_select( + $actions, + 'action[]', + '', + '', + '', + '', + true, + true, + true, + 'w100p', + false, + 'width:100%' + ) +); + +$table->data[2][1] = html_print_label_input_block( + __('Number of matching alerts'), + '
'.html_print_input_text('fires_min', 0, '', false, 10, true, false, false, '', 'w30p').''.__('to').''.html_print_input_text('fires_max', 0, '', false, 10, true, false, false, '', 'w30p').'
' +); + +echo '
'; +html_print_table($table); + +attachActionButton('add', 'add', $table->width, false, $SelectAction); + +echo '
'; + +?> + + diff --git a/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php b/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php new file mode 100644 index 0000000000..437f3a5903 --- /dev/null +++ b/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php @@ -0,0 +1,288 @@ + '0'] + ); + foreach ($array_alerts as $row) { + $alerts[$row['id']] = io_safe_output(alerts_get_alert_template_name($row['id_alert_template']).' - '.$row['name_extern_module']); + } + } + + echo json_encode($alerts, true); + return; + } +} + +$add = (bool) get_parameter_post('add'); + +if ($add) { + $array_alerts = (array) get_parameter('id_alerts'); + $array_actions = (array) get_parameter('action'); + $fires_min = (int) get_parameter('fires_min', 0); + $fires_max = (int) get_parameter('fires_max', 0); + + if (empty($array_alerts) === false) { + foreach ($array_alerts as $id_alert) { + foreach ($array_actions as $action) { + $id_policy_alert = db_get_value('id_policy_alert', 'tpolicy_alerts_actions', 'id', $action); + $result = policies_add_action_alert($id_alert, $action, $fires_min, $fires_max); + } + } + + ui_print_result_message($result, __('Add action successfuly'), __('Could not be added'), ''); + } +} + + +$table = new stdClass(); +$table->id = 'add_table'; +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->data = []; +$table->style = []; +$table->style[0] = 'font-weight: bold; vertical-align:top'; +$table->style[2] = 'font-weight: bold; vertical-align:top'; +$table->size = []; +$table->size[0] = '50%'; +$table->size[1] = '50%'; + +$table->data = []; + +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AW', + true, + 'id_group', + 0, + '', + 'All', + 0, + true, + false, + true, + '', + false, + 'width:180px;' + ) +); + +$table->data[0][1] = html_print_label_input_block( + __('Group recursion'), + html_print_checkbox('recursion', 1, $recursion, true, false, '', true) +); + +$arr_policies = policies_get_policies(); +$policies = []; +foreach ($arr_policies as $row) { + $policies[$row['id']] = $row['name']; +} + +$table->data[1][0] = html_print_label_input_block( + __('Policies'), + html_print_select( + $policies, + 'id_policies[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); + +$table->data[1][1] = html_print_label_input_block( + __('Alerts'), + html_print_select( + [], + 'id_alerts[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); +$actions = alerts_get_alert_actions(); +$table->data[2][0] = html_print_label_input_block( + __('Action'), + html_print_select( + $actions, + 'action[]', + '', + '', + '', + '', + true, + true, + true, + 'w100p', + false, + 'width:100%' + ) +); + +$table->data[2][1] = html_print_label_input_block( + __('Number of matching alerts'), + '
'.html_print_input_text('fires_min', 0, '', false, 10, true, false, false, '', 'w30p').''.__('to').''.html_print_input_text('fires_max', 0, '', false, 10, true, false, false, '', 'w30p').'
' +); + +echo '
'; +html_print_table($table); + +attachActionButton('add', 'add', $table->width, false, $SelectAction); + +echo '
'; + +?> + + diff --git a/pandora_console/godmode/massive/massive_delete_policies_alerts.php b/pandora_console/godmode/massive/massive_delete_policies_alerts.php new file mode 100644 index 0000000000..8bf7453d57 --- /dev/null +++ b/pandora_console/godmode/massive/massive_delete_policies_alerts.php @@ -0,0 +1,320 @@ + $alert] + ); + foreach ($array_actions as $row) { + $action = db_get_row_filter( + 'talert_actions', + ['id' => $row['id_alert_action']] + ); + $actions[$row['id']] = $action['name']; + } + } + + echo json_encode($actions, true); + return; + } +} + +$delete = (bool) get_parameter_post('delete'); + +if ($delete) { + $array_actions = get_parameter('id_actions'); + foreach ($array_actions as $id_action) { + $result = policies_delete_action_alert($id_action); + } + + ui_print_result_message($result, __('Added action successfuly'), __('Could not be added'), ''); +} + + +$table = new stdClass(); +$table->id = 'add_table'; +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->data = []; +$table->style = []; +$table->style[0] = 'font-weight: bold; vertical-align:top'; +$table->style[2] = 'font-weight: bold; vertical-align:top'; +$table->size = []; +$table->size[0] = '50%'; +$table->size[1] = '50%'; + +$table->data = []; + +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AW', + true, + 'id_group', + 0, + '', + 'All', + 0, + true, + false, + true, + '', + false, + 'width:180px;' + ) +); + +$table->data[0][1] = html_print_label_input_block( + __('Group recursion'), + html_print_checkbox('recursion', 1, $recursion, true, false, '', true) +); + +$arr_policies = policies_get_policies(); +$policies = []; +foreach ($arr_policies as $row) { + $policies[$row['id']] = $row['name']; +} + +$table->data[1][0] = html_print_label_input_block( + __('Policies'), + html_print_select( + $policies, + 'id_policies[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); + +$table->data[1][1] = html_print_label_input_block( + __('Alerts'), + html_print_select( + [], + 'id_alerts[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); + +$table->data[2][0] = html_print_label_input_block( + __('Actions'), + html_print_select( + [], + 'id_actions[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); + +echo '
'; +html_print_table($table); + +attachActionButton('delete', 'delete', $table->width, false, $SelectAction); + +echo '
'; + +?> + + diff --git a/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php b/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php new file mode 100644 index 0000000000..f9888786ef --- /dev/null +++ b/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php @@ -0,0 +1,320 @@ + '0']) as $row) { + $alerts[$row['id']] = io_safe_output(alerts_get_alert_template_name($row['id_alert_template']).' - '.$row['name_extern_module']); + } + } + + echo json_encode($alerts, true); + return; + } + + if ($load_actions_alerts) { + $array_alerts = get_parameter('id_alerts', []); + + $actions = []; + foreach ($array_alerts as $alert) { + $array_actions = db_get_all_rows_filter( + 'tpolicy_alerts_actions', + ['id_policy_alert' => $alert] + ); + foreach ($array_actions as $row) { + $action = db_get_row_filter( + 'talert_actions', + ['id' => $row['id_alert_action']] + ); + $actions[$row['id']] = $action['name']; + } + } + + echo json_encode($actions, true); + return; + } +} + +$delete = (bool) get_parameter_post('delete'); + +if ($delete) { + $array_actions = get_parameter('id_actions'); + foreach ($array_actions as $id_action) { + $result = policies_delete_action_alert($id_action); + } + + ui_print_result_message($result, __('Added action successfuly'), __('Could not be added'), ''); +} + + +$table = new stdClass(); +$table->id = 'add_table'; +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->data = []; +$table->style = []; +$table->style[0] = 'font-weight: bold; vertical-align:top'; +$table->style[2] = 'font-weight: bold; vertical-align:top'; +$table->size = []; +$table->size[0] = '50%'; +$table->size[1] = '50%'; + +$table->data = []; + +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AW', + true, + 'id_group', + 0, + '', + 'All', + 0, + true, + false, + true, + '', + false, + 'width:180px;' + ) +); + +$table->data[0][1] = html_print_label_input_block( + __('Group recursion'), + html_print_checkbox('recursion', 1, $recursion, true, false, '', true) +); + +$arr_policies = policies_get_policies(); +$policies = []; +foreach ($arr_policies as $row) { + $policies[$row['id']] = $row['name']; +} + +$table->data[1][0] = html_print_label_input_block( + __('Policies'), + html_print_select( + $policies, + 'id_policies[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); + +$table->data[1][1] = html_print_label_input_block( + __('Alerts'), + html_print_select( + [], + 'id_alerts[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); + +$table->data[2][0] = html_print_label_input_block( + __('Actions'), + html_print_select( + [], + 'id_actions[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;' + ) +); + +echo '
'; +html_print_table($table); + +attachActionButton('delete', 'delete', $table->width, false, $SelectAction); + +echo '
'; + +?> + + diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 534a881d91..5f1c38b3a9 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -64,6 +64,16 @@ $options_alerts = [ 'standby_alerts' => __('Bulk alert setting standby'), ]; +$options_alerts_policies = [ + 'add_policies_alerts' => __('Bulk policie alert action add'), + 'delete_policies_alerts' => __('Bulk policie alert action delete'), +]; + +$options_policies_alerts_externals = [ + 'add_policies_alerts_action_external' => __('Bulk policie external alert action add'), + 'delete_policies_alerts_action_external' => __('Bulk policie external alert action delete'), +]; + $options_agents = [ 'edit_agents' => __('Bulk agent edit'), 'delete_agents' => __('Bulk agent delete'), @@ -119,6 +129,10 @@ if ($satellite_options != ENTERPRISE_NOT_HOOK) { if (in_array($option, array_keys($options_alerts)) === true) { $tab = 'massive_alerts'; +} else if (in_array($option, array_keys($options_alerts_policies)) === true) { + $tab = 'massive_policies_alerts'; +} else if (in_array($option, array_keys($options_policies_alerts_externals)) === true) { + $tab = 'massive_policies_alerts_external'; } else if (in_array($option, array_keys($options_agents)) === true) { $tab = 'massive_agents'; } else if (in_array($option, array_keys($options_users)) === true) { @@ -173,6 +187,14 @@ switch ($tab) { $options = $options_alerts; break; + case 'massive_policies_alerts': + $options = $options_alerts_policies; + break; + + case 'massive_policies_alerts_external': + $options = $options_policies_alerts_externals; + break; + case 'massive_agents': $options = $options_agents; break; @@ -223,6 +245,30 @@ $alertstab = [ 'active' => $tab == 'massive_alerts', ]; +$policiesalertstab = [ + 'text' => ''.html_print_image( + 'images/policies_mc.png', + true, + [ + 'title' => __('Policies alerts'), + 'class' => 'invert_filter main_menu_icon', + ] + ).'', + 'active' => $tab == 'massive_policies_alerts', +]; + +$policiesalertsexternaltab = [ + 'text' => ''.html_print_image( + 'images/alerts_extern.png', + true, + [ + 'title' => __('Policies external alerts'), + 'class' => 'invert_filter main_menu_icon', + ] + ).'', + 'active' => $tab == 'massive_policies_alerts_external', +]; + $userstab = [ 'text' => ''.html_print_image( 'images/user.svg', @@ -298,6 +344,8 @@ if (check_acl($config['id_user'], 0, 'UM')) { } $onheader['massive_alerts'] = $alertstab; +$onheader['massive_policies_alerts'] = $policiesalertstab; +$onheader['massive_policies_alerts_external'] = $policiesalertsexternaltab; $onheader['policies'] = $policiestab; $onheader['snmp'] = $snmptab; $onheader['satellite'] = $satellitetab; @@ -318,6 +366,8 @@ if (is_metaconsole() === false) { $pluginstab, $userstab, $alertstab, + $policiesalertstab, + $policiesalertsexternaltab, $policiestab, $snmptab, $satellitetab, @@ -490,6 +540,22 @@ switch ($option) { include_once $config['homedir'].'/godmode/massive/massive_standby_alerts.php'; break; + case 'add_policies_alerts': + include_once $config['homedir'].'/godmode/massive/massive_add_policies_alerts.php'; + break; + + case 'delete_policies_alerts': + include_once $config['homedir'].'/godmode/massive/massive_delete_policies_alerts.php'; + break; + + case 'add_policies_alerts_action_external': + include_once $config['homedir'].'/godmode/massive/massive_add_policies_alerts_action_external.php'; + break; + + case 'delete_policies_alerts_action_external': + include_once $config['homedir'].'/godmode/massive/massive_delete_policies_alerts_action_external.php'; + break; + case 'add_profiles': include_once $config['homedir'].'/godmode/massive/massive_add_profiles.php'; break; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 3f8ade2b1a..411d9fc7c0 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -309,6 +309,8 @@ if ($access_console_node === true) { } $sub2['godmode/massive/massive_operations&tab=massive_alerts']['text'] = __('Alerts operations'); + $sub2['godmode/massive/massive_operations&tab=massive_policies_alerts']['text'] = __('Policies alerts'); + $sub2['godmode/massive/massive_operations&tab=massive_policies_alerts_external']['text'] = __('Policies External alerts'); enterprise_hook('massivepolicies_submenu'); enterprise_hook('massivesnmp_submenu'); enterprise_hook('massivesatellite_submenu'); From 5ed9206f3684806a4348d4481edb45f8149bcc9e Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Fri, 11 Aug 2023 13:50:32 +0200 Subject: [PATCH 09/97] 11423-Graph analytics. Drag&Drop (WIP) --- .../include/styles/graph_analytics.css | 125 +++++++++- .../operation/reporting/graph_analytics.php | 231 ++++++++++-------- 2 files changed, 242 insertions(+), 114 deletions(-) diff --git a/pandora_console/include/styles/graph_analytics.css b/pandora_console/include/styles/graph_analytics.css index d2169913f6..c73b875b2a 100644 --- a/pandora_console/include/styles/graph_analytics.css +++ b/pandora_console/include/styles/graph_analytics.css @@ -44,12 +44,40 @@ div.padding-div { padding: 10px; } -div.filters-div { +div.filters-div-main { min-width: 400px; border-right: 1px solid var(--border-dark-color); } -div.graphs-div { +div.filters-div-main.filters-div-main-collapsed { + width: 20px; + min-width: 20px; +} + +div.filters-div-main.filters-div-main-collapsed + *:not(.filters-div-header):not(.filters-div-header > img) { + display: none; +} + +div.filters-div-main > .filters-div-header { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: space-between; +} + +div.filters-div-main > .filters-div-header > img { + width: 20px; + cursor: pointer; +} + +div.filters-div { + display: flex; + flex-direction: column; + flex-wrap: nowrap; +} + +div.graphs-div-main { width: 100%; } @@ -57,21 +85,13 @@ div.graphs-div { cursor: grab; } -#sortable-graphs { +#droppable-graphs { display: flex; flex-direction: column; flex-wrap: nowrap; justify-content: center; } -#sortable-graphs .drop-zone-sortable { - background-color: (--primary-color); - width: 100%; - height: 20px; - border: 2px dashed var(--border-dark-color); - border-radius: 6px; -} - .interval-div { display: flex; flex-direction: row; @@ -79,3 +99,86 @@ div.graphs-div { justify-content: center; margin-bottom: 10px; } + +/* Draggable */ +.draggable.ui-draggable-dragging { + width: 100px; +} + +.draggable { + width: 100px; + height: 20px; + background: red; +} + +.draggable2 { + background: blue; +} + +.draggable3 { + background: green; +} + +.droppable { + width: 100%; + /* height: 20px; */ + margin-bottom: 5px; + display: flex; +} + +#droppable-graphs .droppable-zone { + background-color: #0077ff80; + border: 2px dashed #0077ff; + border-radius: 6px; + width: 100%; + height: 20px; +} + +#droppable-graphs .drops-hover { + background-color: #82b92e80; + border: 2px dashed #82b92e; +} + +#droppable-graphs .droppable.droppable-default-zone:not(.droppable-new) { + height: 70px; + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + visibility: hidden; +} + +#droppable-graphs .droppable.droppable-default-zone.droppable-new { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; +} + +#droppable-graphs + .droppable.droppable-default-zone.droppable-new + > span.drop-here { + display: none; +} + +#droppable-graphs .droppable.droppable-default-zone > span.drop-here { + font-size: 15pt; + font-weight: bold; + color: #0077ff; +} + +#droppable-graphs + .droppable.droppable-default-zone.droppable-new.ui-droppable-active + > span.drop-here { + display: initial; +} + +#droppable-graphs .droppable.droppable-default-zone.ui-droppable-active { + visibility: visible; +} + +#droppable-graphs + .droppable.droppable-default-zone.ui-droppable-active.drops-hover + > span.drop-here { + color: #82b92e; +} diff --git a/pandora_console/operation/reporting/graph_analytics.php b/pandora_console/operation/reporting/graph_analytics.php index 533082c4b3..8f90479ee0 100644 --- a/pandora_console/operation/reporting/graph_analytics.php +++ b/pandora_console/operation/reporting/graph_analytics.php @@ -145,28 +145,24 @@ $left_content = ''; $right_content = ''; $left_content .= ' -
-
- 6 - -
+
+
+
- -
-
- 7 - -
+
+
+
+
'; $intervals = []; -$intervals[SECONDS_1HOUR] = human_time_description_raw(SECONDS_1HOUR, true, 'large'); -$intervals[SECONDS_6HOURS] = human_time_description_raw(SECONDS_6HOURS, true, 'large'); -$intervals[SECONDS_12HOURS] = human_time_description_raw(SECONDS_12HOURS, true, 'large'); -$intervals[SECONDS_1DAY] = human_time_description_raw(SECONDS_1DAY, true, 'large'); -$intervals[SECONDS_2DAY] = human_time_description_raw(SECONDS_2DAY, true, 'large'); -$intervals[SECONDS_1WEEK] = human_time_description_raw(SECONDS_1WEEK, true, 'large'); +$intervals[SECONDS_1HOUR] = _('Last ').human_time_description_raw(SECONDS_1HOUR, true, 'large'); +$intervals[SECONDS_6HOURS] = _('Last ').human_time_description_raw(SECONDS_6HOURS, true, 'large'); +$intervals[SECONDS_12HOURS] = _('Last ').human_time_description_raw(SECONDS_12HOURS, true, 'large'); +$intervals[SECONDS_1DAY] = _('Last ').human_time_description_raw(SECONDS_1DAY, true, 'large'); +$intervals[SECONDS_2DAY] = _('Last ').human_time_description_raw(SECONDS_2DAY, true, 'large'); +$intervals[SECONDS_1WEEK] = _('Last ').human_time_description_raw(SECONDS_1WEEK, true, 'large'); $right_content .= '
'.html_print_select( $intervals, @@ -182,33 +178,16 @@ $right_content .= '
'.html_print_select( ).'
'; $right_content .= ' -
-
- 1 - -
-
- 2 - -
-
- 3 - -
-
- 4 - -
-
- 5 - -
+
+
'.__('Drop here').'
'; - +//
+//
+//
$filters_div = html_print_div( [ - 'class' => 'padding-div filters-div', + 'class' => 'padding-div filters-div-main', 'content' => $left_content, ], true @@ -216,7 +195,7 @@ $filters_div = html_print_div( $graphs_div = html_print_div( [ - 'class' => 'padding-div graphs-div', + 'class' => 'padding-div graphs-div-main', 'content' => $right_content, ], true @@ -233,67 +212,113 @@ html_print_div( ?> \ No newline at end of file From de0fdd58afc02c2914eac9887ae75c365bcdb648 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 14 Aug 2023 08:00:24 +0200 Subject: [PATCH 10/97] #10622 fix string policie to policies --- pandora_console/godmode/massive/massive_operations.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 5f1c38b3a9..b91f1dfa94 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -65,13 +65,13 @@ $options_alerts = [ ]; $options_alerts_policies = [ - 'add_policies_alerts' => __('Bulk policie alert action add'), - 'delete_policies_alerts' => __('Bulk policie alert action delete'), + 'add_policies_alerts' => __('Bulk policies alert action add'), + 'delete_policies_alerts' => __('Bulk policies alert action delete'), ]; $options_policies_alerts_externals = [ - 'add_policies_alerts_action_external' => __('Bulk policie external alert action add'), - 'delete_policies_alerts_action_external' => __('Bulk policie external alert action delete'), + 'add_policies_alerts_action_external' => __('Bulk policies external alert action add'), + 'delete_policies_alerts_action_external' => __('Bulk policies external alert action delete'), ]; $options_agents = [ From 53bf10acc0d0c52ac1c4bdc5d6c800787df5dc42 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 14 Aug 2023 14:54:15 +0200 Subject: [PATCH 11/97] #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(''); +}) + '; +} + +// Store servers timezone offset to be retrieved from js. +set_js_value('timezone_offset', date('Z', time())); + +extensions_add_operation_menu_option( + __('Realtime graphs'), + 'estado', + null, + 'v1r1', + 'view' +); +extensions_add_main_function('pandora_realtime_graphs'); ?> \ No newline at end of file From 5ee4dbee87a7ae9c5f2f74ed78ee2995c0fdaffa Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 16 Aug 2023 16:11:35 +0200 Subject: [PATCH 14/97] #11490 added new widget group status map --- .../include/graphs/functions_d3.php | 14 ++- pandora_console/include/graphs/pandora.d3.js | 46 ++++++--- .../Dashboard/Widgets/groups_status_map.php | 95 +++++++++++++++---- pandora_console/include/styles/dashboards.css | 10 ++ .../operation/netflow/nf_live_view.php | 2 +- 5 files changed, 129 insertions(+), 38 deletions(-) diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 53d913e651..5bfd03d244 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -83,7 +83,7 @@ function d3_relationship_graph($elements, $matrix, $width=700, $return=false, $h } -function d3_tree_map_graph($data, $width=700, $height=700, $return=false, $id_container='tree_map') +function d3_tree_map_graph($data, $width=700, $height=700, $return=false, $id_container='tree_map', $child_links=false) { global $config; @@ -139,8 +139,18 @@ function d3_tree_map_graph($data, $width=700, $height=700, $return=false, $id_co } '; $output .= ""; + if ($child_links === true) { + $output .= html_print_input_image( + 'resize_parent', + '/images/normal_screen.png', + 1, + 'background-color: white !important; padding: 4px !important;', + true, + ['class' => 'resize_button invisible'] + ); + } if (!$return) { echo $output; diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 36fb0fff2d..d8a36cff00 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -402,7 +402,7 @@ function chordDiagram(recipient, elements, matrix, width, height) { // } // ] // }; -function treeMap(recipient, data, width, height) { +function treeMap(recipient, data, width, height, childLinks = false) { //var isIE = BrowserDetect.browser == 'Explorer'; var isIE = true; var chartWidth = width; @@ -437,6 +437,9 @@ function treeMap(recipient, data, width, height) { var transitionDuration = 500; var root; var node; + var resize_button = $(recipient) + .parent() + .find(".resize_button"); var treemap = d3.layout .treemap() @@ -474,6 +477,7 @@ function treeMap(recipient, data, width, height) { .attr("class", "cell parent") .on("click", function(d) { zoom(d); + resize_button.show(); }) .append("svg") .attr("class", "clip") @@ -527,6 +531,10 @@ function treeMap(recipient, data, width, height) { // remove transition parentCells.exit().remove(); + $(resize_button).on("click", function() { + zoom(root); + $(this).hide(); + }); // create children cells var childrenCells = chart .selectAll("g.cell.child") @@ -540,14 +548,22 @@ function treeMap(recipient, data, width, height) { .append("g") .attr("class", "cell child") .on("click", function(d) { - zoom(node === d.parent ? root : d.parent); + if (childLinks) { + if (node === d.parent) { + window.location.href = d.link; + } else { + resize_button.show(); + zoom(d.parent); + } + } else { + zoom(node === d.parent ? root : d.parent); + } }) - .on("mouseover", over_user) - .on("mouseout", out_user) - .on("mousemove", move_tooltip) .append("svg") .attr("class", "clip"); - + $(recipient).on("mouseover", over_user); + $(recipient).on("mouseout", out_user); + $(recipient).on("mousemove", move_tooltip); childEnterTransition .append("rect") .classed("background", true) @@ -752,9 +768,8 @@ function treeMap(recipient, data, width, height) { } function move_tooltip(d) { - x = d3.event.layerX + 15; - y = d3.event.layerY + 15; - + x = d.offsetX + 40; + y = d.offsetY + 40; $("#tooltip_" + uniqueId).css("left", x + "px"); $("#tooltip_" + uniqueId).css("top", y + "px"); } @@ -782,10 +797,10 @@ function treeMap(recipient, data, width, height) { $(recipient).append( $("
") .attr("id", "tooltip_" + uniqueId) - .html(d.tooltip_content) + .html(d.target.__data__.tooltip_content) ); } else { - $("#tooltip_" + uniqueId).html(d.tooltip_content); + $("#tooltip_" + uniqueId).html(d.target.__data__.tooltip_content); } $("#tooltip_" + uniqueId).attr( @@ -811,10 +826,11 @@ function treeMap(recipient, data, width, height) { } function show_tooltip(d) { - x = d3.event.pageX + 10; - y = d3.event.pageY + 10; - - create_tooltip(d, x, y); + x = d.offsetX + 10; + y = d.offsetY + 10; + if (d.target.__data__) { + create_tooltip(d, x, y); + } } function hide_tooltip() { diff --git a/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php b/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php index ec21deb601..36a836b91c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php @@ -278,25 +278,72 @@ class GroupsStatusMapWidget extends Widget } } - $where = ''; - if (in_array('0', $groups_array) === false && count($groups_array) > 0) { - $where = ' WHERE g.id_grupo IN ('.implode(',', $groups_array).') '; + if (is_metaconsole() === true) { + $where = ''; + if (in_array('0', $groups_array) === false && count($groups_array) > 0) { + // Names are used instead of ids because it can't be the same id as in node. + $names = []; + foreach ($groups_array as $key => $group) { + $names[] = '\''.groups_get_name($group).'\''; + } + + $where = ' WHERE g.nombre IN ('.implode(',', $names).') '; + } + + $servers = metaconsole_get_servers(); + $rows = []; + if (isset($servers) === true && is_array($servers) === true + ) { + foreach ($servers as $server) { + if (metaconsole_connect($server) == NOERR) { + $sql = 'SELECT g.id_grupo, g.nombre, estado, count(*) AS total_modules + FROM tagente a + LEFT JOIN tgrupo g ON g.id_grupo = a.id_grupo + LEFT JOIN tagente_modulo m ON a.id_agente = m.id_agente + LEFT JOIN tagente_estado es ON es.id_agente_modulo = m.id_agente_modulo + '.$where.' + GROUP BY a.id_grupo, estado'; + $result = db_process_sql($sql); + if ($result !== false) { + $rows = array_merge_recursive($result, $rows); + } + } + + metaconsole_restore_db(); + } + } + } else { + $where = ''; + if (in_array('0', $groups_array) === false && count($groups_array) > 0) { + $where = ' WHERE g.id_grupo IN ('.implode(',', $groups_array).') '; + } + + $sql = 'SELECT g.id_grupo, g.nombre, estado, count(*) AS total_modules + FROM tagente a + LEFT JOIN tgrupo g ON g.id_grupo = a.id_grupo + LEFT JOIN tagente_modulo m ON a.id_agente = m.id_agente + LEFT JOIN tagente_estado es ON es.id_agente_modulo = m.id_agente_modulo + '.$where.' + GROUP BY a.id_grupo, estado'; + + $rows = db_process_sql($sql); } - $sql = 'SELECT g.id_grupo, g.nombre, estado, count(*) AS total_modules - FROM tagente a - LEFT JOIN tgrupo g ON g.id_grupo = a.id_grupo - LEFT JOIN tagente_modulo m ON a.id_agente = m.id_agente - LEFT JOIN tagente_estado es ON es.id_agente_modulo = m.id_agente_modulo - '.$where.' - GROUP BY a.id_grupo, estado'; - $rows = db_process_sql($sql); + if ($rows === false || (is_array($rows) === true && count($rows) === 0)) { + $output = ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('No data found.'), + ] + ); + return $output; + } $level1 = [ 'name' => __('Module status map'), 'children' => [], ]; - $names = []; + foreach ($rows as $key => $row) { $color = ''; $name_status = ''; @@ -324,38 +371,46 @@ class GroupsStatusMapWidget extends Widget case '4': $color = '#4a83f3'; $name_status = __('No data'); + $row['estado'] = 6; break; default: + $row['estado'] = 6; $color = '#B2B2B2'; $name_status = __('Unknown'); continue; } - $level1['children'][$row['id_grupo']][] = [ + if (empty($level1['children'][$row['nombre']][$row['estado']]['value']) === false) { + $total = ($row['total_modules'] + $level1['children'][$row['nombre']][$row['estado']]['value']); + } else { + $total = $row['total_modules']; + } + + $level1['children'][$row['nombre']][$row['estado']] = [ 'id' => uniqid(), 'name' => $row['estado'], - 'value' => $row['total_modules'], + 'value' => $total, 'color' => $color, - 'tooltip_content' => $row['total_modules'].__(' Modules(%s)', $name_status), + 'tooltip_content' => $total.__(' Modules(%s)', $name_status), + 'link' => 'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group='.$row['id_grupo'].'&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status='.$row['estado'].'&sort_field=&sort=none&pure=', ]; - $names[$row['id_grupo']] = $row['nombre']; } $level2 = [ - 'name' => __('Module status map'), + 'name' => __('Group status map'), 'children' => [], ]; - foreach ($level1['children'] as $key => $group) { + foreach ($level1['children'] as $name => $group) { $level2['children'][] = [ 'id' => uniqid(), - 'name' => $names[$key], + 'name' => $name, 'children' => $group, ]; } $id_container = 'tree_map_'.uniqid(); - $output = d3_tree_map_graph($level2, $size['width'], $size['height'], true, $id_container); + $output = d3_tree_map_graph($level2, $size['width'], $size['height'], true, $id_container, true); return $output; } diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 285e8fa481..05ba550030 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -937,3 +937,13 @@ div.basic-chart-title span { font-size: 20px; font-weight: bold; } + +input.resize_button { + position: absolute; + background-color: white !important; + padding: 4px !important; + border-radius: 20px; + width: 28px; + bottom: 3%; + right: 6%; +} diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 33a39eaa3a..1b992c7e21 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -696,7 +696,7 @@ if (empty($draw) === false) { $config['style'] ); - $netflowContainerClass = ($chart_type === 'netflow_data' || $chart_type === 'netflow_summary' || $chart_type === 'netflow_top_N') ? '' : 'white_box'; + $netflowContainerClass = ($chart_type === 'netflow_data' || $chart_type === 'netflow_summary' || $chart_type === 'netflow_top_N') ? '' : 'white_box relative'; // Draw the netflow chart. html_print_div( From 484570aa4c689bbfd26bf6b8a8e99bbe262361d0 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 17 Aug 2023 09:41:46 +0200 Subject: [PATCH 15/97] #11490 fixed grouped by id in widget status map --- .../Dashboard/Widgets/groups_status_map.php | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php b/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php index 36a836b91c..7a591851e0 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/groups_status_map.php @@ -281,13 +281,7 @@ class GroupsStatusMapWidget extends Widget if (is_metaconsole() === true) { $where = ''; if (in_array('0', $groups_array) === false && count($groups_array) > 0) { - // Names are used instead of ids because it can't be the same id as in node. - $names = []; - foreach ($groups_array as $key => $group) { - $names[] = '\''.groups_get_name($group).'\''; - } - - $where = ' WHERE g.nombre IN ('.implode(',', $names).') '; + $where = ' WHERE g.id_grupo IN ('.implode(',', $groups_array).') '; } $servers = metaconsole_get_servers(); @@ -344,6 +338,7 @@ class GroupsStatusMapWidget extends Widget 'children' => [], ]; + $names = []; foreach ($rows as $key => $row) { $color = ''; $name_status = ''; @@ -381,13 +376,13 @@ class GroupsStatusMapWidget extends Widget continue; } - if (empty($level1['children'][$row['nombre']][$row['estado']]['value']) === false) { - $total = ($row['total_modules'] + $level1['children'][$row['nombre']][$row['estado']]['value']); + if (empty($level1['children'][$row['id_grupo']][$row['estado']]['value']) === false) { + $total = ($row['total_modules'] + $level1['children'][$row['id_grupo']][$row['estado']]['value']); } else { $total = $row['total_modules']; } - $level1['children'][$row['nombre']][$row['estado']] = [ + $level1['children'][$row['id_grupo']][$row['estado']] = [ 'id' => uniqid(), 'name' => $row['estado'], 'value' => $total, @@ -395,16 +390,17 @@ class GroupsStatusMapWidget extends Widget 'tooltip_content' => $total.__(' Modules(%s)', $name_status), 'link' => 'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group='.$row['id_grupo'].'&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status='.$row['estado'].'&sort_field=&sort=none&pure=', ]; + $names[$row['id_grupo']] = $row['nombre']; } $level2 = [ 'name' => __('Group status map'), 'children' => [], ]; - foreach ($level1['children'] as $name => $group) { + foreach ($level1['children'] as $id_grupo => $group) { $level2['children'][] = [ 'id' => uniqid(), - 'name' => $name, + 'name' => $names[$id_grupo], 'children' => $group, ]; } From 35a7c409bf3f381e5de93c2028e4bcbf9905df9c Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 21 Aug 2023 13:03:44 +0200 Subject: [PATCH 16/97] #11873 Fixed Scheduled Downtime quiet mode for modules --- .../agentes/planned_downtime.editor.php | 6 +-- .../include/functions_planned_downtimes.php | 54 ++++++++----------- pandora_server/lib/PandoraFMS/Core.pm | 31 +++++------ 3 files changed, 36 insertions(+), 55 deletions(-) diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index 79516b3670..75ef5bb65b 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -1558,7 +1558,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad) $all_modules = true; } - if ($all_common_modules === true) { + if ($all_common_modules === true || $all_modules === true) { $module_names = explode(',', get_parameter('all_common_modules')); } @@ -1602,7 +1602,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad) foreach ($agents as $agent_id) { $agent_id = (int) $agent_id; // Check module belongs to the agent. - if ($modules_selection_mode == 'all' && $all_modules === false) { + if ($modules_selection_mode == 'all' && ($all_modules === false || $all_modules === true)) { $check = false; foreach ($module_names as $module_name) { $check_module = modules_get_agentmodule_id( @@ -1666,7 +1666,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad) ); } - if ($result !== false && (bool) $all_modules === false) { + if ($result !== false && ((bool) $all_modules === false || (bool) $all_modules === true)) { foreach ($module_names as $module_name) { $module = modules_get_agentmodule_id( $module_name, diff --git a/pandora_console/include/functions_planned_downtimes.php b/pandora_console/include/functions_planned_downtimes.php index e577f50e97..772611fa29 100644 --- a/pandora_console/include/functions_planned_downtimes.php +++ b/pandora_console/include/functions_planned_downtimes.php @@ -620,45 +620,33 @@ function planned_downtimes_stop($downtime) $count = 0; foreach ($agents as $agent) { - if ($agent['all_modules']) { + $modules = db_get_all_rows_filter( + 'tplanned_downtime_modules', + [ + 'id_agent' => $agent['id_agent'], + 'id_downtime' => $id_downtime, + ] + ); + if (empty($modules)) { + $modules = []; + } + + foreach ($modules as $module) { $result = db_process_sql_update( - 'tagente', - ['quiet' => 0], - ['id_agente' => $agent['id_agent']] + 'tagente_modulo', + [ + 'quiet' => 0, + 'quiet_by_downtime' => 0, + ], + [ + 'quiet_by_downtime' => 1, + 'id_agente_modulo' => $module['id_agent_module'], + ] ); if ($result) { $count++; } - } else { - $modules = db_get_all_rows_filter( - 'tplanned_downtime_modules', - [ - 'id_agent' => $agent['id_agent'], - 'id_downtime' => $id_downtime, - ] - ); - if (empty($modules)) { - $modules = []; - } - - foreach ($modules as $module) { - $result = db_process_sql_update( - 'tagente_modulo', - [ - 'quiet' => 0, - 'quiet_by_downtime' => 0, - ], - [ - 'quiet_by_downtime' => 1, - 'id_agente_modulo' => $module['id_agent_module'], - ] - ); - - if ($result) { - $count++; - } - } } } break; diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 89ae55f6c1..284f224023 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2660,30 +2660,23 @@ sub pandora_planned_downtime_set_quiet_elements($$$) { WHERE id_downtime = ' . $downtime_id); foreach my $downtime_agent (@downtime_agents) { - if ($downtime_agent->{'all_modules'}) { - db_do ($dbh, 'UPDATE tagente - SET quiet = 1 - WHERE id_agente = ?', $downtime_agent->{'id_agent'}); - } - else { - my @downtime_modules = get_db_rows($dbh, 'SELECT * + my @downtime_modules = get_db_rows($dbh, 'SELECT * FROM tplanned_downtime_modules WHERE id_agent = ' . $downtime_agent->{'id_agent'} . ' AND id_downtime = ' . $downtime_id); - foreach my $downtime_module (@downtime_modules) { - # If traversed module was already quiet, do not set quiet_by_downtime flag. - # quiet_by_downtime is used to avoid setting the module back to quiet=0 when downtime is over for those modules that were quiet before the downtime. - db_do ($dbh, 'UPDATE tagente_modulo - SET quiet_by_downtime = 1 - WHERE quiet = 0 && id_agente_modulo = ?', - $downtime_module->{'id_agent_module'}); + foreach my $downtime_module (@downtime_modules) { + # If traversed module was already quiet, do not set quiet_by_downtime flag. + # quiet_by_downtime is used to avoid setting the module back to quiet=0 when downtime is over for those modules that were quiet before the downtime. + db_do ($dbh, 'UPDATE tagente_modulo + SET quiet_by_downtime = 1 + WHERE quiet = 0 && id_agente_modulo = ?', + $downtime_module->{'id_agent_module'}); - db_do ($dbh, 'UPDATE tagente_modulo - SET quiet = 1 - WHERE id_agente_modulo = ?', - $downtime_module->{'id_agent_module'}); - } + db_do ($dbh, 'UPDATE tagente_modulo + SET quiet = 1 + WHERE id_agente_modulo = ?', + $downtime_module->{'id_agent_module'}); } } } From 563323d0beec26c8c728c3c7776b37a64e8c7bda Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 21 Aug 2023 13:05:39 +0200 Subject: [PATCH 17/97] #11852 warning time lapse more than 30 days --- .../godmode/reporting/graph_builder.main.php | 11 ++- .../reporting_builder.item_editor.php | 70 ++++++++++++++++--- .../include/class/CustomNetScan.class.php | 12 +++- pandora_console/include/functions_html.php | 11 ++- pandora_console/include/javascript/pandora.js | 36 ++++++++++ .../lib/Dashboard/Widgets/BasicChart.php | 2 + .../lib/Dashboard/Widgets/BlockHistogram.php | 3 +- .../lib/Dashboard/Widgets/DataMatrix.php | 4 ++ .../lib/Dashboard/Widgets/custom_graph.php | 2 + .../Widgets/graph_module_histogram.php | 2 + .../include/lib/Dashboard/Widgets/netflow.php | 2 + .../lib/Dashboard/Widgets/single_graph.php | 2 + .../lib/Dashboard/Widgets/sla_percent.php | 2 + .../include/lib/Dashboard/Widgets/top_n.php | 2 + .../models/VisualConsole/Items/BasicChart.php | 2 + .../VisualConsole/Items/ModuleGraph.php | 2 + pandora_console/operation/agentes/graphs.php | 20 +++++- .../operation/reporting/graph_viewer.php | 20 +++++- 18 files changed, 185 insertions(+), 20 deletions(-) diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index 4233e4f9f4..7ed4e20eb5 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -190,14 +190,21 @@ $output .= html_print_label_input_block( html_print_extended_select_for_time( 'period', $period, - '', + 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', '', '0', false, true, false, false, - 'w100p' + 'w100p', + false, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')' ) ); $output .= ""; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 397e533366..adb54f89fe 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1421,10 +1421,21 @@ $class = 'databox filters'; html_print_extended_select_for_time( 'period', $period, - '', + 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', '', '0', - 10 + 10, + false, + false, + true, + '', + false, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')' ); ?> @@ -1444,10 +1455,21 @@ $class = 'databox filters'; html_print_extended_select_for_time( 'period_range', $period_range, - '', + 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', '', '0', - 10 + 10, + false, + false, + true, + '', + false, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'period_range\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')' ); ?> @@ -1487,10 +1509,21 @@ $class = 'databox filters'; html_print_extended_select_for_time( 'period1', $period_pg, - '', + 'check_period_warning(this)', '', '0', - 10 + 10, + false, + false, + true, + '', + false, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'period\')' ); ?> @@ -1506,10 +1539,21 @@ $class = 'databox filters'; html_print_extended_select_for_time( 'period2', $projection_period, - '', + 'check_period_warning(this)', '', '0', - 10 + 10, + false, + false, + true, + '', + false, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'period\')' ); ?> @@ -3440,7 +3484,7 @@ $class = 'databox filters'; html_print_extended_select_for_time( 'lapse', $lapse, - '', + 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', __('None'), '0', 10, @@ -3448,7 +3492,13 @@ $class = 'databox filters'; '', '', '', - !$lapse_calc + !$lapse_calc, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'lapse\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')' ); ?> diff --git a/pandora_console/include/class/CustomNetScan.class.php b/pandora_console/include/class/CustomNetScan.class.php index 409f5636cf..ec4351e831 100644 --- a/pandora_console/include/class/CustomNetScan.class.php +++ b/pandora_console/include/class/CustomNetScan.class.php @@ -542,13 +542,21 @@ class CustomNetScan extends Wizard 'extra' => ''.html_print_extended_select_for_time( 'interval', $this->task['interval_sweep'], - '', + 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', '', '0', false, true, false, - false + false, + '', + false, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'interval\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')' ).'', ]; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 0d74ec9005..26fd12e75e 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2166,7 +2166,8 @@ function html_print_extended_select_for_time( $style_icon='', $no_change=false, $allow_zero=0, - $units=null + $units=null, + $script_input='' ) { global $config; $admin = is_user_admin($config['id_user']); @@ -2256,7 +2257,7 @@ function html_print_extended_select_for_time( echo '
'; echo '
'; - html_print_input_text($uniq_name.'_text', $selected, '', $size, 255, false, $readonly, false, '', $class); + html_print_input_text($uniq_name.'_text', $selected, '', $size, 255, false, $readonly, false, '', $class, $script_input); html_print_input_hidden($name, $selected, false, $uniq_name); html_print_select( @@ -5771,7 +5772,11 @@ function html_print_input($data, $wrapper='div', $input_only=false) ((isset($data['class']) === true) ? $data['class'] : ''), ((isset($data['readonly']) === true) ? $data['readonly'] : false), ((isset($data['custom_fields']) === true) ? $data['custom_fields'] : false), - ((isset($data['style_icon']) === true) ? $data['style_icon'] : '') + ((isset($data['style_icon']) === true) ? $data['style_icon'] : ''), + ((isset($data['no_change']) === true) ? $data['no_change'] : ''), + ((isset($data['allow_zero']) === true) ? $data['allow_zero'] : ''), + ((isset($data['units']) === true) ? $data['units'] : null), + ((isset($data['script_input']) === true) ? $data['script_input'] : '') ); break; diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 738deb0834..b13301d77f 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -2487,3 +2487,39 @@ function menuActionButtonResizing() { "width: calc(100% - " + $("#menu_full").width() + "px);" ); } + +function check_period_warning(time, title, message) { + var period = time.value; + var times = 0; + if (period >= 2592000 && period < 7776000) { + WarningPeriodicityModal(title, message); + } else if (period >= 7776000 && period < 15552000) { + do { + WarningPeriodicityModal(title, message); + times = times + 1; + } while (times < 2); + } else if (period >= 15552000) { + do { + WarningPeriodicityModal(title, message); + times = times + 1; + } while (times < 3); + } +} + +function check_period_warning_manual(input_name, title, message) { + var period = { + value: + $("#text-" + input_name + "_text").val() * + $("#" + input_name + "_units option:selected").val() + }; + check_period_warning(period, title, message); +} + +function WarningPeriodicityModal(title, message) { + confirmDialog({ + title: title, + message: message, + strCancelButton: "Ok", + hideOkButton: 1 + }); +} diff --git a/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php b/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php index 85665e7e4c..c3b9ddf9ad 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php +++ b/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php @@ -421,6 +421,8 @@ class BasicChart extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php b/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php index 2d26760c76..a3ff215c76 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php +++ b/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php @@ -304,7 +304,8 @@ class BlockHistogram extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', - + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php index 10ddd2bc9c..e4905688df 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php +++ b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php @@ -308,6 +308,8 @@ class DataMatrix extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; @@ -324,6 +326,8 @@ class DataMatrix extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'slice\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php index 52425947de..377ca145a0 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php @@ -392,6 +392,8 @@ class CustomGraphWidget extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php index 09e46c36d5..b0382ba273 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php +++ b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php @@ -367,6 +367,8 @@ class GraphModuleHistogramWidget extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/lib/Dashboard/Widgets/netflow.php b/pandora_console/include/lib/Dashboard/Widgets/netflow.php index be603e452b..13a15bf6a0 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/netflow.php +++ b/pandora_console/include/lib/Dashboard/Widgets/netflow.php @@ -205,6 +205,8 @@ class Netflow extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; $chart_types = netflow_get_chart_types(); diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php index 2cdcf65fb3..72ad55309b 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php @@ -352,6 +352,8 @@ class SingleGraphWidget extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php index 6ec96f9ef8..4dfefbf292 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php +++ b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php @@ -381,6 +381,8 @@ class SLAPercentWidget extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n.php b/pandora_console/include/lib/Dashboard/Widgets/top_n.php index 98fb8c5135..5a603501c0 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n.php @@ -260,6 +260,8 @@ class TopNWidget extends Widget 'nothing' => __('None'), 'nothing_value' => 0, 'style_icon' => 'flex-grow: 0', + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/BasicChart.php b/pandora_console/include/rest-api/models/VisualConsole/Items/BasicChart.php index 8e9a20ce1d..77229f096a 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/BasicChart.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/BasicChart.php @@ -317,6 +317,8 @@ final class BasicChart extends Item 'value' => $values['period'], 'nothing' => __('None'), 'nothing_value' => 0, + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php index 96c2e54771..17244a7a17 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php @@ -633,6 +633,8 @@ final class ModuleGraph extends Item 'value' => $values['period'], 'nothing' => __('None'), 'nothing_value' => 0, + 'script' => 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + 'script_input' => 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', ], ]; diff --git a/pandora_console/operation/agentes/graphs.php b/pandora_console/operation/agentes/graphs.php index 14b13c6893..c1c3705acd 100644 --- a/pandora_console/operation/agentes/graphs.php +++ b/pandora_console/operation/agentes/graphs.php @@ -233,7 +233,25 @@ $table->data[2][2] .= html_print_image( $table->data[3][1] = __('Time range'); -$table->data[3][2] = html_print_extended_select_for_time('period', $period, '', '', 0, 7, true); +$table->data[3][2] = html_print_extended_select_for_time( + 'period', + $period, + 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + '', + 0, + 7, + true, + false, + true, + '', + false, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')' +); $table->data[4][2] = __('Show events'); $table->data[4][3] = html_print_checkbox('draw_events', 1, (bool) $draw_events, true); diff --git a/pandora_console/operation/reporting/graph_viewer.php b/pandora_console/operation/reporting/graph_viewer.php index bba28e6a7e..3d01d6b5c1 100644 --- a/pandora_console/operation/reporting/graph_viewer.php +++ b/pandora_console/operation/reporting/graph_viewer.php @@ -344,7 +344,25 @@ if ($view_graph) { $searchForm .= ""; $searchForm .= html_print_label_input_block( __('Time range'), - html_print_extended_select_for_time('period', (string) $period, '', '', 0, 10, true, 'width:100%') + html_print_extended_select_for_time( + 'period', + (string) $period, + 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', + '', + 0, + 10, + true, + 'width:100%', + true, + '', + false, + false, + '', + false, + 0, + null, + 'check_period_warning_manual(\'period\', \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')' + ) ); $searchForm .= ''; $searchForm .= ''; From 6a903f9dc342b303db97a51e13b4294123debf69 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 21 Aug 2023 13:29:36 +0200 Subject: [PATCH 18/97] #11819 vertical range for new rows only --- .../include/functions_visual_map.php | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index aedc47aed4..1b6a4e7bfa 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -2576,10 +2576,8 @@ function visual_map_process_wizard_add( $id_agents = (array) $id_agents; $error = false; - $initial_x = $pos_x; - $initial_y = $pos_y; $elements_row = 1; - $total_rows = 1; + $initial_x = $pos_x; foreach ($id_agents as $id_agent) { $value_height = $height; $value_image = $image; @@ -2631,12 +2629,10 @@ function visual_map_process_wizard_add( if (($max_elements_row === $elements_row) && $max_elements_row !== 0) { $elements_row = 1; - $pos_x = ($initial_x + ($range * $total_rows)); - $pos_y = ($initial_y + ($range_vertical * $total_rows)); - $total_rows++; + $pos_x = $initial_x; + $pos_y = ($range_vertical + $pos_y); } else { $pos_x = ($pos_x + $range); - $pos_y = ($pos_y + $range_vertical); $elements_row++; } } @@ -2705,10 +2701,8 @@ function visual_map_process_wizard_add_modules( $id_modules = (array) $id_modules; $error = false; - $initial_x = $pos_x; - $initial_y = $pos_y; $elements_row = 1; - $total_rows = 1; + $initial_x = $pos_x; foreach ($id_modules as $id_module) { if ($id_server != 0) { $connection = db_get_row_filter( @@ -2832,12 +2826,10 @@ function visual_map_process_wizard_add_modules( if (($max_elements_row === $elements_row) && $max_elements_row !== 0) { $elements_row = 1; - $pos_x = ($initial_x + ($range * $total_rows)); - $pos_y = ($initial_y + ($range_vertical * $total_rows)); - $total_rows++; + $pos_x = $initial_x; + $pos_y = ($range_vertical + $pos_y); } else { $pos_x = ($pos_x + $range); - $pos_y = ($pos_y + $range_vertical); $elements_row++; } } @@ -2948,10 +2940,8 @@ function visual_map_process_wizard_add_agents( $id_agents = (array) $id_agents; $error = false; - $initial_x = $pos_x; - $initial_y = $pos_y; $elements_row = 1; - $total_rows = 1; + $initial_x = $pos_x; $relationship = true; $relationships_agents = []; // Check if the set a none relationship @@ -3082,12 +3072,10 @@ function visual_map_process_wizard_add_agents( if (($max_elements_row === $elements_row) && $max_elements_row !== 0) { $elements_row = 1; - $pos_x = ($initial_x + ($range * $total_rows)); - $pos_y = ($initial_y + ($range_vertical * $total_rows)); - $total_rows++; + $pos_x = $initial_x; + $pos_y = ($range_vertical + $pos_y); } else { $pos_x = ($pos_x + $range); - $pos_y = ($pos_y + $range_vertical); $elements_row++; } From 631a247f1922bc6a18129db44a7e712e96ba80ee Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 21 Aug 2023 14:50:51 +0200 Subject: [PATCH 19/97] #10622 fix style policy alerts external --- pandora_console/godmode/massive/massive_add_policies_alerts.php | 2 +- .../massive/massive_add_policies_alerts_action_external.php | 2 +- .../godmode/massive/massive_delete_policies_alerts.php | 2 +- .../massive/massive_delete_policies_alerts_action_external.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/massive/massive_add_policies_alerts.php b/pandora_console/godmode/massive/massive_add_policies_alerts.php index 0b38c96b1b..3c280ac0be 100644 --- a/pandora_console/godmode/massive/massive_add_policies_alerts.php +++ b/pandora_console/godmode/massive/massive_add_policies_alerts.php @@ -93,7 +93,7 @@ if ($add) { } } - ui_print_result_message($result, __('Add action successfuly'), __('Could not be added'), ''); + ui_print_result_message($result, __('Add action successfully'), __('Could not be added'), ''); } } diff --git a/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php b/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php index 437f3a5903..177af408f1 100644 --- a/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php +++ b/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php @@ -97,7 +97,7 @@ if ($add) { } } - ui_print_result_message($result, __('Add action successfuly'), __('Could not be added'), ''); + ui_print_result_message($result, __('Add action successfully'), __('Could not be added'), ''); } } diff --git a/pandora_console/godmode/massive/massive_delete_policies_alerts.php b/pandora_console/godmode/massive/massive_delete_policies_alerts.php index 8bf7453d57..d4976f83a1 100644 --- a/pandora_console/godmode/massive/massive_delete_policies_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_policies_alerts.php @@ -108,7 +108,7 @@ if ($delete) { $result = policies_delete_action_alert($id_action); } - ui_print_result_message($result, __('Added action successfuly'), __('Could not be added'), ''); + ui_print_result_message($result, __('Deleted action successfully'), __('Could not be deleted'), ''); } diff --git a/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php b/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php index f9888786ef..840326bd5a 100644 --- a/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php +++ b/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php @@ -108,7 +108,7 @@ if ($delete) { $result = policies_delete_action_alert($id_action); } - ui_print_result_message($result, __('Added action successfuly'), __('Could not be added'), ''); + ui_print_result_message($result, __('Deleted action successfully'), __('Could not be deleted'), ''); } From ce1c8cdbb7b84afff7a579baa9f847ef73439232 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Tue, 22 Aug 2023 10:04:33 +0200 Subject: [PATCH 20/97] 11423-Graph analytics. Before Share & Export --- pandora_console/extras/mr/66.sql | 12 + pandora_console/include/functions.php | 111 +- pandora_console/include/functions_graph.php | 20 + .../include/graphs/flot/pandora.flot.js | 74 +- .../include/graphs/functions_flot.php | 22 +- .../include/styles/graph_analytics.css | 99 +- .../operation/reporting/graph_analytics.php | 1158 ++++++++++++----- pandora_console/pandoradb.sql | 12 + 8 files changed, 1087 insertions(+), 421 deletions(-) create mode 100644 pandora_console/extras/mr/66.sql diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql new file mode 100644 index 0000000000..909edd7ca7 --- /dev/null +++ b/pandora_console/extras/mr/66.sql @@ -0,0 +1,12 @@ +START TRANSACTION; + +CREATE TABLE IF NOT EXISTS `tgraph_analytics_filter` ( +`id` INT NOT NULL auto_increment, +`filter_name` VARCHAR(45) NULL, +`user_id` VARCHAR(255) NULL, +`graph_modules` TEXT NULL, +`interval` INT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +COMMIT; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 4fa87f70cb..0895325ef5 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -270,7 +270,8 @@ function format_for_graph( $dec_point='.', $thousands_sep=',', $divider=1000, - $sufix='' + $sufix='', + $two_lines=false ) { // Exception to exclude modules whose unit is already formatted as KB (satellite modules) if (!empty($sufix) && $sufix == 'KB') { @@ -297,6 +298,10 @@ function format_for_graph( } // This will actually do the rounding and the decimals. + if ($two_lines === true) { + return remove_right_zeros(format_numeric($number, $decimals)).'
'.$shorts[$pos].$sufix; + } + return remove_right_zeros(format_numeric($number, $decimals)).$shorts[$pos].$sufix; } @@ -4046,25 +4051,49 @@ function series_type_graph_array($data, $show_elements_graph) } } else { $name_legend = ''; - if (isset($show_elements_graph['fullscale']) === true - && (int) $show_elements_graph['fullscale'] === 1 - ) { - $name_legend .= 'Tip: '; - } else { - $name_legend .= 'Avg: '; - } - if ($value['unit']) { - $name_legend .= $value['agent_alias']; - $name_legend .= ' / '; - $name_legend .= $value['module_name']; - $name_legend .= ' / '; - $name_legend .= __('Unit ').' '; - $name_legend .= $value['unit'].': '; + if ($show_elements_graph['graph_analytics'] === true) { + $name_legend .= '
'; + $name_legend .= '
'; + $name_legend .= ''; + $name_legend .= format_for_graph( + end(end($value['data'])), + 1, + $config['decimal_separator'], + $config['thousand_separator'], + 1000, + '', + true + ); + $name_legend .= ''; + $name_legend .= ''.$value['unit'].''; + $name_legend .= '
'; + $name_legend .= '
'; + $name_legend .= ''.$value['agent_alias'].''; + $name_legend .= ''.$value['module_name'].''; + $name_legend .= '
'; + $name_legend .= '
'; } else { - $name_legend .= $value['agent_alias']; - $name_legend .= ' / '; - $name_legend .= $value['module_name'].': '; + if (isset($show_elements_graph['fullscale']) === true + && (int) $show_elements_graph['fullscale'] === 1 + ) { + $name_legend .= 'Tip: '; + } else { + $name_legend .= 'Avg: '; + } + + if ($value['unit']) { + $name_legend .= $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name']; + $name_legend .= ' / '; + $name_legend .= __('Unit ').' '; + $name_legend .= $value['unit'].': '; + } else { + $name_legend .= $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name'].': '; + } } } } @@ -4085,28 +4114,30 @@ function series_type_graph_array($data, $show_elements_graph) $value['max'] = 0; } - $data_return['legend'][$key] .= ''.__('Min').' '.remove_right_zeros( - number_format( - $value['min'], - $config['graph_precision'], - $config['csv_decimal_separator'], - $config['csv_decimal_separator'] == ',' ? '.' : ',' - ) - ).' '.$value['unit'].' '.__('Max').' '.remove_right_zeros( - number_format( - $value['max'], - $config['graph_precision'], - $config['csv_decimal_separator'], - $config['csv_decimal_separator'] == ',' ? '.' : ',' - ) - ).' '.$value['unit'].' '._('Avg.').' '.remove_right_zeros( - number_format( - $value['avg'], - $config['graph_precision'], - $config['csv_decimal_separator'], - $config['csv_decimal_separator'] == ',' ? '.' : ',' - ) - ).' '.$value['unit'].' '.$str; + if (isset($show_elements_graph['graph_analytics']) === false) { + $data_return['legend'][$key] .= ''.__('Min').' '.remove_right_zeros( + number_format( + $value['min'], + $config['graph_precision'], + $config['csv_decimal_separator'], + $config['csv_decimal_separator'] == ',' ? '.' : ',' + ) + ).' '.$value['unit'].' '.__('Max').' '.remove_right_zeros( + number_format( + $value['max'], + $config['graph_precision'], + $config['csv_decimal_separator'], + $config['csv_decimal_separator'] == ',' ? '.' : ',' + ) + ).' '.$value['unit'].' '._('Avg.').' '.remove_right_zeros( + number_format( + $value['avg'], + $config['graph_precision'], + $config['csv_decimal_separator'], + $config['csv_decimal_separator'] == ',' ? '.' : ',' + ) + ).' '.$value['unit'].' '.$str; + } if ($show_elements_graph['compare'] == 'overlapped' && $key == 'sum2' diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 1892b0cd31..6fa1e2a8d5 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5540,3 +5540,23 @@ function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWate $options ); } + + +function graph_analytics_filter_select() +{ + global $config; + + $result = []; + + if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user'], 0, 'RM') === 1) { + $filters = db_get_all_rows_sql('SELECT id, filter_name FROM tgraph_analytics_filter WHERE user_id = "'.$config['id_user'].'"'); + + if ($filters !== false) { + foreach ($filters as $filter) { + $result[$filter['id']] = $filter['filter_name']; + } + } + } + + return $result; +} diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 93c7a9fb06..37162f5a37 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -995,6 +995,9 @@ function pandoraFlotSlicebar( } } +// Set array for realtime graphs +var realtimeGraphs = []; + // eslint-disable-next-line no-unused-vars function pandoraFlotArea( graph_id, @@ -1007,6 +1010,21 @@ function pandoraFlotArea( params, events_array ) { + // Realtime graphs. + if (typeof params.realtime !== "undefined") { + realtimeGraphs.push({ + graph_id, + values, + legend, + series_type, + color, + date_array, + data_module_graph, + params, + events_array + }); + } + //diferents vars var unit = params.unit ? params.unit : ""; var homeurl = params.homeurl; @@ -2462,15 +2480,23 @@ function pandoraFlotArea( if (Object.keys(update_legend).length == 0) { label_aux = legend[series.label]; - $("#legend_" + graph_id + " .legendLabel") - .eq(i) - .html( - label_aux + - " value = " + - number_format(y, 0, "", short_data, divisor) + - " " + - unit - ); + if (params.graph_analytics === true) { + var numberParams = {}; + numberParams.twoLines = true; + $("#legend_" + graph_id + " .legendLabel .square-value") + .eq(i) + .html(number_format(y, 0, "", 1, divisor, numberParams)); + } else { + $("#legend_" + graph_id + " .legendLabel") + .eq(i) + .html( + label_aux + + " value = " + + number_format(y, 0, "", short_data, divisor) + + " " + + unit + ); + } } else { $.each(update_legend, function(index, value) { if (typeof value[x - 1] !== "undefined") { @@ -2844,12 +2870,16 @@ function pandoraFlotArea( // Add bottom margin in the legend // Estimated height of 24 (works fine with this data in all browsers) $("#legend_" + graph_id).css("margin-bottom", "10px"); - parent_height = parseInt( - $("#menu_" + graph_id) - .parent() - .css("height") - .split("px")[0] - ); + + if (typeof params.realtime === "undefined" || params.realtime === false) { + parent_height = parseInt( + $("#menu_" + graph_id) + .parent() + .css("height") + .split("px")[0] + ); + } + adjust_menu(graph_id, plot, parent_height, width, show_legend); } } @@ -2987,7 +3017,14 @@ function check_adaptions(graph_id) { }); } -function number_format(number, force_integer, unit, short_data, divisor) { +function number_format( + number, + force_integer, + unit, + short_data, + divisor, + params +) { divisor = typeof divisor !== "undefined" ? divisor : 1000; var decimals = 2; @@ -3029,6 +3066,11 @@ function number_format(number, force_integer, unit, short_data, divisor) { number = 0; } + if (typeof params !== "undefined") { + if (typeof params.twoLines !== "undefined" && params.twoLines === true); + return number + "
" + shorts[pos] + unit; + } + return number + " " + shorts[pos] + unit; } diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 6b64cae989..84fafbb1ea 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -262,8 +262,14 @@ function flot_area_graph( (empty($params['line_width']) === true) ? $config['custom_graph_width'] : $params['line_width'], true ); + + $timestamp_top_fixed = ''; + if (isset($params['timestamp_top_fixed']) === true && empty($params['timestamp_top_fixed']) === false) { + $timestamp_top_fixed = $params['timestamp_top_fixed']; + } + $return .= "
"; $legend_top = 10; diff --git a/pandora_console/include/styles/graph_analytics.css b/pandora_console/include/styles/graph_analytics.css index 96dd1abc45..c9ae76fe8f 100644 --- a/pandora_console/include/styles/graph_analytics.css +++ b/pandora_console/include/styles/graph_analytics.css @@ -31,6 +31,17 @@ div.box-flat.white_table_graph > div[id^="tgl_div_"] > div.white-box-content { justify-content: flex-start; } +div.box-flat.white_table_graph + > div[id^="tgl_div_"] + > div.white-box-content + > [data-id-agent], +div.box-flat.white_table_graph + > div[id^="tgl_div_"] + > div.white-box-content + > [data-id-group] { + cursor: pointer; +} + div#menu_tab ul li, div#menu_tab ul li span { display: flex; @@ -158,7 +169,7 @@ div.graphs-div-main { /* Draggable */ .draggable.ui-draggable-dragging { - width: 100%; + width: 20%; } .draggable { @@ -166,15 +177,13 @@ div.graphs-div-main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - width: 100px; - height: 20px; - background: #9efcab; -} -/* !Remove and set width 100% in .draggable */ -#droppable-graphs .draggable { - width: 20px; } +#droppable-graphs * { + cursor: default; +} + +/* Droppable */ .droppable { width: 100%; /* height: 20px; */ @@ -187,7 +196,10 @@ div.graphs-div-main { border: 2px dashed #0077ff; border-radius: 6px; width: 100%; - height: 20px; +} + +#droppable-graphs .droppable-zone > div { + opacity: 0.5; } #droppable-graphs .drops-hover { @@ -238,3 +250,72 @@ div.graphs-div-main { > span.drop-here { color: #82b92e; } + +#droppable-graphs .parent_graph { + padding-top: 40px; +} + +#droppable-graphs .timestamp_graph { + top: 15px; +} + +#droppable-graphs .menu_graph { + left: 85%; + display: flex; + flex-direction: column; + justify-content: center; +} + +div.timestamp-top-fixed { + top: 15px !important; +} + +div.graph-analytics-legend-main { + display: flex; +} + +div.graph-analytics-legend-square { + width: 30px; + height: 30px; + max-width: 30px; + margin-right: 5px; + padding-right: 3px; + display: flex; + flex-direction: column; + align-items: flex-end; + flex-wrap: nowrap; + justify-content: center; +} + +div.graph-analytics-legend-square > span { + text-align: right; + color: #fff; + line-height: 9pt; +} + +div.graph-analytics-legend-square > span.square-unit { + width: 30px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +div.graph-analytics-legend { + display: flex; + flex-direction: column; + flex-wrap: nowrap; +} + +div.graph-analytics-legend > span { + line-height: 12pt; +} + +div.graph-analytics-legend > span:last-child { + font-weight: normal; + font-size: 8pt; + margin-left: 5px; +} + +#droppable-graphs td.legendColorBox { + display: none; +} diff --git a/pandora_console/operation/reporting/graph_analytics.php b/pandora_console/operation/reporting/graph_analytics.php index 7e68c92777..1b6751fa1a 100644 --- a/pandora_console/operation/reporting/graph_analytics.php +++ b/pandora_console/operation/reporting/graph_analytics.php @@ -34,12 +34,15 @@ check_login(); ui_require_css_file('graph_analytics'); require_once 'include/functions_custom_graphs.php'; -// Get parameters. -$x = get_parameter('x'); - // Ajax. if (is_ajax()) { $search_left = get_parameter('search_left'); + $search_right = get_parameter('search_right'); + $get_graphs = get_parameter('get_graphs'); + $save_filter = get_parameter('save_filter'); + $load_filter = get_parameter('load_filter'); + $update_filter = get_parameter('update_filter'); + $get_new_values = get_parameter('get_new_values'); if (empty($search_left) === false) { $output = []; @@ -114,13 +117,367 @@ if (is_ajax()) { return; } + if (empty($search_right) === false) { + $output = []; + $search = io_safe_input(get_parameter('free_search')); + $agent = get_parameter('search_agent'); + $group = get_parameter('search_group'); + + $search_sql = ' AND (tam.nombre LIKE "%%'.$search.'%%" OR tam.descripcion LIKE "%%'.$search.'%%")'; + + // Agent. + if (empty($agent) === false) { + $sql = sprintf( + 'SELECT tam.id_agente_modulo, tam.nombre, tam.descripcion + FROM tagente_modulo tam + WHERE (tam.id_agente = %s) + %s + ORDER BY tam.nombre', + $agent, + $search_sql + ); + + $output['modules'] = db_get_all_rows_sql($sql); + } + + // Group. + if (empty($group) === false) { + $sql = sprintf( + 'SELECT tam.id_agente_modulo, tam.nombre, tam.descripcion + FROM tagente_modulo tam + INNER JOIN tagente ta ON ta.id_agente = tam.id_agente + WHERE (ta.id_grupo = %s) + %s + ORDER BY tam.nombre', + $group, + $search_sql + ); + + $output['modules'] = db_get_all_rows_sql($sql); + } + + // Return. + echo json_encode($output); + return; + } + + // Graph. + if (empty($get_graphs) === false) { + $interval = (int) get_parameter('interval'); + $modules = $get_graphs; + + $params = [ + 'period' => $interval, + 'width' => '100%', + 'graph_width' => '85%', + 'height' => 100, + 'date' => time(), + 'percentil' => null, + 'fullscale' => 1, + 'type_graph' => 'line', + 'timestamp_top_fixed' => 'timestamp-top-fixed', + 'graph_analytics' => true, + 'realtime' => true, + ]; + + $params_combined = [ + 'stacked' => 2, + 'labels' => [], + 'modules_series' => $modules, + 'id_graph' => null, + 'return' => 1, + 'graph_analytics' => true, + ]; + + $graph_return = graphic_combined_module( + $modules, + $params, + $params_combined + ); + + $graph_return .= " + + "; + + echo $graph_return; + return; + } + + // Save filter. + if (empty($save_filter) === false) { + $graphs = get_parameter('graphs'); + $interval = (int) get_parameter('interval'); + + if (empty($save_filter) === true) { + echo __('Empty name'); + return; + } + + if (empty($graphs) === true) { + echo __('Empty graphs'); + return; + } + + $id_filter = db_process_sql_insert( + 'tgraph_analytics_filter', + [ + 'filter_name' => $save_filter, + 'user_id' => $config['id_user'], + 'graph_modules' => json_encode($graphs), + 'interval' => $interval, + ] + ); + + if ($id_filter > 0) { + echo 'saved'; + return; + } else { + echo __('Empty graphs'); + return; + } + } + + // Update filter. + if (empty($update_filter) === false) { + $graphs = get_parameter('graphs'); + $interval = (int) get_parameter('interval'); + + if (empty($graphs) === true) { + echo __('Empty graphs'); + return; + } + + $update_filter = db_process_sql_update( + 'tgraph_analytics_filter', + [ + 'graph_modules' => json_encode($graphs), + 'interval' => $interval, + ], + ['id' => $update_filter] + ); + + if ($update_filter > 0) { + echo 'updated'; + return; + } else { + echo __('No updated'); + return; + } + + echo $update_filter; + return; + } + + // Load filter. + if (empty($load_filter) === false) { + $data = []; + $data['graphs'] = json_decode(db_get_value('graph_modules', 'tgraph_analytics_filter', 'id', $load_filter)); + $data['interval'] = db_get_value('tgraph_analytics_filter.interval', 'tgraph_analytics_filter', 'id', $load_filter); + + echo json_encode($data); + return; + } + + // Get new values. + if (empty($get_new_values) === false) { + $data = []; + + $agent_module_id = $get_new_values; + $date_array = get_parameter('date_array'); + $data_module_graph = get_parameter('data_module_graph'); + $params = get_parameter('params'); + $suffix = get_parameter('suffix'); + + // Stract data. + $array_data_module = grafico_modulo_sparse_data( + $agent_module_id, + $date_array, + $data_module_graph, + $params, + $suffix + ); + + echo json_encode($array_data_module); + return; + } + return; } +// Save filter modal. +echo ''; + +// Load filter modal. +$filters = graph_analytics_filter_select(); + +echo ''; + // Header & Actions. $title_tab = __('Start realtime'); $tab_start_realtime = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/change-active.svg', true, [ @@ -130,9 +487,21 @@ $tab_start_realtime = [ ).$title_tab.'', ]; +$title_tab = __('Pause realtime'); +$tab_pause_realtime = [ + 'text' => ''.html_print_image( + 'images/change-pause.svg', + true, + [ + 'title' => $title_tab, + 'class' => 'invert_filter main_menu_icon', + ] + ).$title_tab.'', +]; + $title_tab = __('New'); $tab_new = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/plus-black.svg', true, [ @@ -144,7 +513,7 @@ $tab_new = [ $title_tab = __('Save'); $tab_save = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/save_mc.png', true, [ @@ -156,7 +525,7 @@ $tab_save = [ $title_tab = __('Load'); $tab_load = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/logs@svg.svg', true, [ @@ -168,7 +537,7 @@ $tab_load = [ $title_tab = __('Share'); $tab_share = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/responses.svg', true, [ @@ -180,7 +549,7 @@ $tab_share = [ $title_tab = __('Export to custom graph'); $tab_export = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/module-graph.svg', true, [ @@ -202,6 +571,7 @@ ui_print_standard_header( $tab_load, $tab_save, $tab_new, + $tab_pause_realtime, $tab_start_realtime, ], [ @@ -212,22 +582,10 @@ ui_print_standard_header( ] ); -// Header options. -// $options_content = 'Sample text'; -// html_print_div( -// [ -// 'class' => 'options-graph-analytics', -// 'content' => $options_content, -// ] -// ); // Content. $left_content = ''; $right_content = ''; -// $left_content .= ''; -//
-//
-//
$left_content .= '
@@ -306,7 +664,10 @@ $left_content .= ' ).'
- + + + +
'; @@ -364,217 +725,38 @@ html_print_div( ); -// Realtime graph. -$table = new stdClass(); -$table->width = '100%'; -$table->id = 'table-form'; -$table->class = 'filter-table-adv'; -$table->style = []; -$table->data = []; - -$graph_fields['cpu_load'] = __('%s Server CPU', get_product_name()); -$graph_fields['pending_packets'] = __( - 'Pending packages from %s Server', - get_product_name() -); -$graph_fields['disk_io_wait'] = __( - '%s Server Disk IO Wait', - get_product_name() -); -$graph_fields['apache_load'] = __( - '%s Server Apache load', - get_product_name() -); -$graph_fields['mysql_load'] = __( - '%s Server MySQL load', - get_product_name() -); -$graph_fields['server_load'] = __( - '%s Server load', - get_product_name() -); -$graph_fields['snmp_interface'] = __('SNMP Interface throughput'); - -$graph = get_parameter('graph', 'cpu_load'); -$refresh = get_parameter('refresh', '1000'); - -if ($graph != 'snmp_module') { - $data['graph'] = html_print_label_input_block( - __('Graph'), - html_print_select( - $graph_fields, - 'graph', - $graph, - '', - '', - 0, - true, - false, - true, - '', - false, - 'width: 100%' - ) - ); -} - -$refresh_fields[1000] = human_time_description_raw(1, true, 'large'); -$refresh_fields[5000] = human_time_description_raw(5, true, 'large'); -$refresh_fields[10000] = human_time_description_raw(10, true, 'large'); -$refresh_fields[30000] = human_time_description_raw(30, true, 'large'); - -if ($graph == 'snmp_module') { - $agent_alias = io_safe_output(get_parameter('agent_alias', '')); - $module_name = io_safe_output(get_parameter('module_name', '')); - $module_incremental = get_parameter('incremental', 0); - $data['module_info'] = html_print_label_input_block( - $agent_alias.': '.$module_name, - html_print_input_hidden( - 'incremental', - $module_incremental, - true - ).html_print_select( - ['snmp_module' => '-'], - 'graph', - 'snmp_module', - '', - '', - 0, - true, - false, - true, - '', - false, - 'width: 100%; display: none;' - ) - ); -} - -$data['refresh'] = html_print_label_input_block( - __('Refresh interval'), - html_print_select( - $refresh_fields, - 'refresh', - $refresh, - '', - '', - 0, - true, - false, - true, - '', - false, - 'width: 100%' - ) -); - -if ($graph != 'snmp_module') { - $data['incremental'] = html_print_label_input_block( - __('Incremental'), - html_print_checkbox_switch('incremental', 1, 0, true) - ); -} - -$table->data[] = $data; - -// Print the relative path to AJAX calls. -html_print_input_hidden('rel_path', get_parameter('rel_path', '')); - -// Print the form. -$searchForm = '
'; -$searchForm .= html_print_table($table, true); -$searchForm .= html_print_div( - [ - 'class' => 'action-buttons', - 'content' => html_print_submit_button( - __('Clear graph'), - 'srcbutton', - false, - [ - 'icon' => 'delete', - 'mode' => 'mini', - 'onClick' => 'javascript:realtimeGraphs.clearGraph();', - ], - true - ), - ], - true -); -$searchForm .= '
'; - -// echo $searchForm; -echo ' - - -'; - -// Canvas realtime graph. -$canvas = '
'; -$canvas .= '
'; - -$width = 800; -$height = 300; - -$data_array['realtime']['data'][0][0] = (time() - 10); -$data_array['realtime']['data'][0][1] = 0; -$data_array['realtime']['data'][1][0] = time(); -$data_array['realtime']['data'][1][1] = 0; -$data_array['realtime']['color'] = 'green'; - -$params = [ - 'agent_module_id' => false, - 'period' => 300, - 'width' => $width, - 'height' => $height, - 'only_image' => false, - 'type_graph' => 'area', - 'font' => $config['fontpath'], - 'font-size' => $config['font_size'], - 'array_data_create' => $data_array, - 'show_legend' => false, - 'show_menu' => false, - 'backgroundColor' => 'transparent', -]; - -$canvas .= grafico_modulo_sparse($params); -$canvas .= '
'; -echo $canvas; - -html_print_input_hidden( - 'custom_action', - urlencode( - base64_encode( - ' 
' - ) - ), - false -); -html_print_input_hidden('incremental_base', '0'); - -echo ''; -echo ''; - -if ($config['style'] !== 'pandora_black') { - echo ''; -} - -// Store servers timezone offset to be retrieved from js. -set_js_value('timezone_offset', date('Z', time())); - -extensions_add_operation_menu_option( - __('Realtime graphs'), - 'estado', - null, - 'v1r1', - 'view' -); -extensions_add_main_function('pandora_realtime_graphs'); ?> \ No newline at end of file diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 0056868752..0d7fa28a71 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4408,3 +4408,15 @@ CREATE TABLE IF NOT EXISTS `tnetwork_explorer_filter` ( `advanced_filter` TEXT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tgraph_analytics_filter` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tgraph_analytics_filter` ( +`id` INT NOT NULL auto_increment, +`filter_name` VARCHAR(45) NULL, +`user_id` VARCHAR(255) NULL, +`graph_modules` TEXT NULL, +`interval` INT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; \ No newline at end of file From 34f683809512492c91d1492f3a7430bac877d9e8 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 22 Aug 2023 10:49:00 +0200 Subject: [PATCH 21/97] #11927 Fixed msg --- .../update_manager_client/lib/UpdateManager/Client.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/update_manager_client/lib/UpdateManager/Client.php b/pandora_console/update_manager_client/lib/UpdateManager/Client.php index 2525fd4f2b..ae893e2fb9 100644 --- a/pandora_console/update_manager_client/lib/UpdateManager/Client.php +++ b/pandora_console/update_manager_client/lib/UpdateManager/Client.php @@ -709,9 +709,9 @@ class Client $target = ''; if ($request['action'] === 'get_server_package') { - $target = __('server update %d', $request['version']); + $target = __('server update %s', $request['version']); } else if ($request['action'] === 'get_package') { - $target = __('console update %d', $request['version']); + $target = __('console update %s', $request['version']); } // phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found @@ -2134,7 +2134,7 @@ class Client if ($package === null) { // Retrieve package from UMS. - $this->notify(0, 'Downloading server update '.$version.'.'); + $this->notify(0, 'Downloading server update '.$version); $file = $this->post( [ 'action' => 'get_server_package', From aa39f2eac2d8ac5f34c7d9c0c95bfecacae4b8b0 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 22 Aug 2023 12:41:30 +0200 Subject: [PATCH 22/97] #11926 Fixed requires --- .../extensions/agents_modules_csv.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pandora_console/extensions/agents_modules_csv.php b/pandora_console/extensions/agents_modules_csv.php index 53225f8e4d..2171a961b1 100644 --- a/pandora_console/extensions/agents_modules_csv.php +++ b/pandora_console/extensions/agents_modules_csv.php @@ -26,20 +26,14 @@ * ============================================================================ */ - -/* - require_once $config['homedir'].'/include/config.php'; - require_once $config['homedir'].'/include/functions_reporting.php'; - require_once $config['homedir'].'/include/functions_modules.php'; -*/ -require_once '../include/config.php'; -require_once '../include/functions_agents.php'; -require_once '../include/functions_reporting.php'; -require_once '../include/functions_modules.php'; -require_once '../include/functions_users.php'; - global $config; +require_once $config['homedir'].'/include/config.php'; +require_once $config['homedir'].'/include/functions_agents.php'; +require_once $config['homedir'].'/include/functions_reporting.php'; +require_once $config['homedir'].'/include/functions_modules.php'; +require_once $config['homedir'].'/include/functions_users.php'; + check_login(); // ACL Check. From 4d500b98e4a7fc4046edfe58ab839be1c95d05b6 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 22 Aug 2023 13:04:31 +0200 Subject: [PATCH 23/97] #10637 Change group report view --- .../include/functions_reporting_html.php | 117 +++++++++++++++++- 1 file changed, 114 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 91d8a9e5a5..7c01e34515 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2581,7 +2581,118 @@ function reporting_html_group_report($table, $item, $pdf=0) $table->colspan['group_report']['cell'] = 3; $table->cellstyle['group_report']['cell'] = 'text-align: center;'; - $data = " + + $group_id = db_get_value('id_grupo', 'tgrupo', 'nombre', $item['subtitle']); + $description = db_get_value('description', 'tgrupo', 'id_grupo', $group_id); + $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group_id); + $icon = html_print_image( + 'images/'.$icon_url, + true, + [ + 'title' => $item['subtitle'], + 'class' => 'main_menu_icon invert_filter', + ] + ); + + $group_events = db_get_all_rows_sql( + 'SELECT COUNT(te.id_evento) as count_events, ta.alias + FROM tevento as te + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo = '.$group_id.' + GROUP BY te.id_agente' + ); + + $group_os = db_get_all_rows_sql( + 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo + FROM tconfig_os as os + INNER JOIN tagente as ta ON ta.id_os = os.id_os WHERE ta.id_grupo = '.$group_id.' GROUP by os.name' + ); + + $graph_width = 180; + $graph_height = 200; + + $out = '
'; + $out .= ''; + $out .= ''; + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
'; + $out .= '
+ '.$item['subtitle'].'   '.$icon.''; + + $out .= ''; + $out .= ''; + $out .= ''; + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
+
+ '.__('Description').''.$description.'
+
'; + $out .= tactical_groups_get_stats_alerts($group_id); + $out .= '
'; + $out .= tactical_groups_get_agents_and_monitoring($group_id); + $out .= ''; + $out .= groups_get_stats_modules_status($group_id); + $out .= '
'.__('Events per agent').''; + $data = []; + $options = []; + $labels = []; + + foreach ($group_events as $value) { + $data[$value['alias']] = $value['count_events']; + $labels[] = io_safe_output($value['alias']); + } + + $options = [ + 'width' => $graph_width, + 'height' => $graph_height, + 'legend' => ['display' => false], + 'labels' => $labels, + ]; + + $out .= '
'.pie_graph($data, $options).'
'; + $out .= '
'; + $out .= '
'.__('Distribution by OS').''; + + $data = []; + $options = []; + $labels = []; + foreach ($group_os as $value) { + $data[$value['name_os']] = $value['count_os']; + $labels[] = io_safe_output($value['name_os']); + } + + $options = [ + 'width' => $graph_width, + 'height' => $graph_height, + 'legend' => ['display' => false], + 'labels' => $labels, + ]; + + $out .= '
'.pie_graph($data, $options).'
'; + $out .= '
'; + $out .= '
'; + + $out .= '
'; + $out .= '
'; + $out .= '
'; + + /* + $data = " @@ -2624,9 +2735,9 @@ function reporting_html_group_report($table, $item, $pdf=0) -
".__('Total')."".__('Events (not validated)')." ".$item['data']['count_events'].'
'; + ';*/ - $table->data['group_report']['cell'] = $data; + $table->data['group_report']['cell'] = $out; if ($pdf !== 0) { return $data; From 330f36a3cf4f71406071cf52d4d3b0059f72529c Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 22 Aug 2023 13:23:17 +0200 Subject: [PATCH 24/97] Fix group view --- .../operation/agentes/group_view.php | 274 ++++-------------- 1 file changed, 49 insertions(+), 225 deletions(-) diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 204f7d937e..08066014e0 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -175,182 +175,7 @@ if ($total_agentes > 0) { $total_not_init = format_numeric((($agents_notinit * 100) / $total_agentes), 2); } -$all_group_id = []; -foreach ($result_groups as $group) { - if ($group['_id_'] !== '0') { - $all_group_id[] = $group['_id_']; - } -} - -$out = ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; - -$description = ''; -$odd = false; -$graph_width = 180; -$graph_height = 200; - -foreach ($result_groups as $group) { - if ($group['_id_'] !== '0') { - $description = db_get_value('description', 'tgrupo', 'id_grupo', $group['_id_']); - $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group['_id_']); - $icon = html_print_image( - 'images/'.$icon_url, - true, - [ - 'title' => $group['_name_'], - 'class' => 'main_menu_icon invert_filter', - ] - ); - - $where_event = 'WHERE te.id_grupo = '.$group['_id_']; - $where_os = 'WHERE ta.id_grupo = '.$group['_id_']; - } else { - $description = __('Data view of all groups'); - $icon = ''; - $where_event = 'WHERE te.id_grupo in ('.implode(', ', $all_group_id).')'; - $where_os = 'WHERE ta.id_grupo in ('.implode(', ', $all_group_id).')'; - } - - $group_events = db_get_all_rows_sql( - 'SELECT COUNT(te.id_evento) as count_events, ta.alias - FROM tevento as te - INNER JOIN tagente as ta ON te.id_agente = ta.id_agente '.$where_event.' GROUP BY te.id_agente' - ); - - $group_os = db_get_all_rows_sql( - 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo - FROM tconfig_os as os - INNER JOIN tagente as ta ON ta.id_os = os.id_os '.$where_os.' GROUP by os.name' - ); - - if ($odd === false) { - $out .= ''; - } - - $out .= ''; - $out .= ''; - - if ($odd === true) { - $out .= ''; - $odd = false; - } else { - $odd = true; - } -} - -$out .= ''; -$out .= ''; -$out .= ''; -$out .= '
'.__('Summary of the status groups').'
'; - $out .= '
- '.$group['_name_'].'   '.$icon.''; - - $out .= ''; - $out .= ''; - $out .= ''; - - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= '
-
- '.__('Description').''.$description.'
-
'; - if ($group['_id_'] === '0') { - $out .= tactical_groups_get_stats_alerts($all_group_id); - } else { - $out .= tactical_groups_get_stats_alerts($group['_id_']); - } - - $out .= '
'; - if ($group['_id_'] === '0') { - $out .= tactical_groups_get_agents_and_monitoring($all_group_id); - } else { - $out .= tactical_groups_get_agents_and_monitoring($group['_id_']); - } - - $out .= ''; - if ($group['_id_'] === '0') { - $out .= groups_get_stats_modules_status($all_group_id); - } else { - $out .= groups_get_stats_modules_status($group['_id_']); - } - - $out .= '
'.__('Events per agent').''; - - $data = []; - $options = []; - $labels = []; - foreach ($group_events as $value) { - $data[$value['alias']] = $value['count_events']; - $labels[] = io_safe_output($value['alias']); - } - - $options = [ - 'width' => $graph_width, - 'height' => $graph_height, - 'legend' => ['display' => false], - 'labels' => $labels, - ]; - - $out .= '
'.'
'.pie_graph($data, $options).'
'; - $out .= '
'; - $out .= '
'.__('Distribution by so').''; - - $data = []; - $options = []; - $labels = []; - foreach ($group_os as $value) { - $data[$value['name_os']] = $value['count_os']; - $labels[] = io_safe_output($value['name_os']); - } - - $options = [ - 'width' => $graph_width, - 'height' => $graph_height, - 'legend' => ['display' => false], - 'labels' => $labels, - ]; - - $out .= '
'.'
'.pie_graph($data, $options).'
'; - $out .= '
'; - $out .= '
'; - - if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) { - $out .= ''.html_print_image( - 'images/force@svg.svg', - true, - [ - 'border' => '0', - 'title' => __('Force'), - 'class' => 'main_menu_icon invert_filter', - ] - ).''; - } - - $out .= '
'; - $out .= '
'; - $out .= '
'; - -echo $out; -/* - echo ''; +echo '
'; echo ''; echo ''; echo "'; @@ -378,15 +203,15 @@ echo $out; echo ''; echo ''; echo ''; - echo '
".__('Summary of the status groups').'
'; +echo ''; - if ($count == 1) { +if ($count == 1) { if ($result_groups[0]['_id_'] == 0) { unset($result_groups[0]); } - } +} - if (empty($result_groups) === false) { +if (empty($result_groups) === false) { $pagination = ui_pagination( $count, false, @@ -534,10 +359,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_']."'>"; } else { - $link = ""; + $link = ""; } if ($data['_id_'] == 0) { @@ -554,10 +379,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_UNKNOWN."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_unknown != 0)) { @@ -574,10 +399,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NOT_INIT."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_notinit != 0)) { @@ -594,10 +419,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NORMAL."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_ok != 0)) { @@ -614,10 +439,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_WARNING."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_warning != 0)) { @@ -634,10 +459,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_CRITICAL."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_critical != 0)) { @@ -653,11 +478,11 @@ echo $out; // Monitors unknown echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_unknown != 0)) { @@ -673,11 +498,11 @@ echo $out; // Monitors not init echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_not_init != 0)) { @@ -693,11 +518,11 @@ echo $out; // Monitors OK echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_ok != 0)) { @@ -713,11 +538,11 @@ echo $out; // Monitors Warning echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_warning != 0)) { @@ -733,11 +558,11 @@ echo $out; // Monitors Critical echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_critical != 0)) { @@ -753,11 +578,11 @@ echo $out; // Alerts fired echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($all_alerts_fired != 0)) { @@ -774,7 +599,6 @@ echo $out; } echo ''; - } else { +} else { ui_print_info_message(__('There are no defined agents')); - } -*/ +} From 9bb0b30772341cb21538a95475708e83928b7172 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 22 Aug 2023 14:23:57 +0200 Subject: [PATCH 25/97] #11926 Fix download CSV --- pandora_console/extensions/agents_modules_csv.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandora_console/extensions/agents_modules_csv.php b/pandora_console/extensions/agents_modules_csv.php index 2171a961b1..8170d568ed 100644 --- a/pandora_console/extensions/agents_modules_csv.php +++ b/pandora_console/extensions/agents_modules_csv.php @@ -28,6 +28,12 @@ global $config; +require_once '../include/config.php'; +require_once '../include/functions_agents.php'; +require_once '../include/functions_reporting.php'; +require_once '../include/functions_modules.php'; +require_once '../include/functions_users.php'; + require_once $config['homedir'].'/include/config.php'; require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_reporting.php'; From fc32fcff87f27a3c055fff33fcbe0356af013eb8 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 22 Aug 2023 14:35:28 +0200 Subject: [PATCH 26/97] #11926 Fix download CSV --- .../extensions/agents_modules_csv.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pandora_console/extensions/agents_modules_csv.php b/pandora_console/extensions/agents_modules_csv.php index 8170d568ed..6ed1061c11 100644 --- a/pandora_console/extensions/agents_modules_csv.php +++ b/pandora_console/extensions/agents_modules_csv.php @@ -27,18 +27,19 @@ */ global $config; +if (true) { + include_once '../include/config.php'; + include_once '../include/functions_agents.php'; + include_once '../include/functions_reporting.php'; + include_once '../include/functions_modules.php'; + include_once '../include/functions_users.php'; + include_once $config['homedir'].'/include/config.php'; + include_once $config['homedir'].'/include/functions_agents.php'; + include_once $config['homedir'].'/include/functions_reporting.php'; + include_once $config['homedir'].'/include/functions_modules.php'; + include_once $config['homedir'].'/include/functions_users.php'; +} -require_once '../include/config.php'; -require_once '../include/functions_agents.php'; -require_once '../include/functions_reporting.php'; -require_once '../include/functions_modules.php'; -require_once '../include/functions_users.php'; - -require_once $config['homedir'].'/include/config.php'; -require_once $config['homedir'].'/include/functions_agents.php'; -require_once $config['homedir'].'/include/functions_reporting.php'; -require_once $config['homedir'].'/include/functions_modules.php'; -require_once $config['homedir'].'/include/functions_users.php'; check_login(); From fa2d3ec2e50af3df06bd0107593932d4a522a23d Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 22 Aug 2023 15:03:12 +0200 Subject: [PATCH 27/97] #10637 Fix all group view --- .../include/functions_reporting_html.php | 71 +++++++++++++------ 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 7c01e34515..8b4473436d 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2582,30 +2582,55 @@ function reporting_html_group_report($table, $item, $pdf=0) $table->colspan['group_report']['cell'] = 3; $table->cellstyle['group_report']['cell'] = 'text-align: center;'; - $group_id = db_get_value('id_grupo', 'tgrupo', 'nombre', $item['subtitle']); - $description = db_get_value('description', 'tgrupo', 'id_grupo', $group_id); - $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group_id); - $icon = html_print_image( - 'images/'.$icon_url, - true, - [ - 'title' => $item['subtitle'], - 'class' => 'main_menu_icon invert_filter', - ] - ); + if ($item['subtitle'] === 'All') { + $group_id = []; + $all_group_id = db_get_all_rows_sql('SELECT id_grupo FROM tgrupo'); - $group_events = db_get_all_rows_sql( - 'SELECT COUNT(te.id_evento) as count_events, ta.alias - FROM tevento as te - INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo = '.$group_id.' - GROUP BY te.id_agente' - ); + foreach ($all_group_id as $group) { + $group_id[] = $group['id_grupo']; + } - $group_os = db_get_all_rows_sql( - 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo - FROM tconfig_os as os - INNER JOIN tagente as ta ON ta.id_os = os.id_os WHERE ta.id_grupo = '.$group_id.' GROUP by os.name' - ); + $description = __('Data view of all groups'); + $icon = ''; + + $group_events = db_get_all_rows_sql( + 'SELECT COUNT(te.id_evento) as count_events, ta.alias + FROM tevento as te + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente + GROUP BY te.id_agente' + ); + + $group_os = db_get_all_rows_sql( + 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo + FROM tconfig_os as os + INNER JOIN tagente as ta ON ta.id_os = os.id_os GROUP by os.name' + ); + } else { + $group_id = db_get_value('id_grupo', 'tgrupo', 'nombre', $item['subtitle']); + $description = db_get_value('description', 'tgrupo', 'id_grupo', $group_id); + $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group_id); + $icon = html_print_image( + 'images/'.$icon_url, + true, + [ + 'title' => $item['subtitle'], + 'class' => 'main_menu_icon invert_filter', + ] + ); + + $group_events = db_get_all_rows_sql( + 'SELECT COUNT(te.id_evento) as count_events, ta.alias + FROM tevento as te + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo = '.$group_id.' + GROUP BY te.id_agente' + ); + + $group_os = db_get_all_rows_sql( + 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo + FROM tconfig_os as os + INNER JOIN tagente as ta ON ta.id_os = os.id_os WHERE ta.id_grupo = '.$group_id.' GROUP by os.name' + ); + } $graph_width = 180; $graph_height = 200; @@ -2622,7 +2647,7 @@ function reporting_html_group_report($table, $item, $pdf=0) $out .= ''; $out .= '
- '.__('Description').''.$description.'
+ '.__('Group Description').''.$description.' '; $out .= ''; From bfa09367d4bbebfea1bc8abbe2c964ddb619a6a9 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Tue, 22 Aug 2023 15:28:05 +0200 Subject: [PATCH 28/97] 11423-Graph analytics. Share function --- pandora_console/include/constants.php | 1 + .../include/javascript/graph_analytics.js | 619 ++++++++++++++++++ .../include/styles/graph_analytics.css | 5 + .../operation/reporting/graph_analytics.php | 618 +++++------------ .../reporting/graph_analytics_public.php | 191 ++++++ 5 files changed, 965 insertions(+), 469 deletions(-) create mode 100644 pandora_console/include/javascript/graph_analytics.js create mode 100644 pandora_console/operation/reporting/graph_analytics_public.php diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index e8d4eb3a4f..889e32f693 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -807,6 +807,7 @@ define('AUDIT_LOG_FILE_MANAGER', 'File manager'); define('AUDIT_LOG_ALERT_MANAGEMENT', 'Alert management'); define('AUDIT_LOG_ALERT_CORRELATION_MANAGEMENT', 'Alert correlation management'); define('AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT', 'Visual Console Management'); +define('AUDIT_LOG_GRAPH_ANALYTICS_PUBLIC', 'Graph Analytics Public'); define('AUDIT_LOG_TAG_MANAGEMENT', 'Tag management'); define('AUDIT_LOG_SNMP_MANAGEMENT', 'SNMP management'); define('AUDIT_LOG_DASHBOARD_MANAGEMENT', 'Dashboard management'); diff --git a/pandora_console/include/javascript/graph_analytics.js b/pandora_console/include/javascript/graph_analytics.js new file mode 100644 index 0000000000..6afd0d9d38 --- /dev/null +++ b/pandora_console/include/javascript/graph_analytics.js @@ -0,0 +1,619 @@ +// Droppable options. +var droppableOptions = { + accept: ".draggable", + hoverClass: "drops-hover", + activeClass: "droppable-zone", + drop: function(event, ui) { + // Add new module. + $(this) + .data("modules") + .push(ui.draggable.data("id-module")); + + // Create elements. + createDroppableZones(droppableOptions, getModulesByGraphs()); + } +}; + +// Doc ready. +$(document).ready(function() { + // Hide toggles. + $("#agents-toggle").hide(); + $("#groups-toggle").hide(); + $("#modules-toggle").hide(); + $("[data-button=pause-realtime]") + .parent() + .hide(); + + // Set droppable zones. + $(".droppable").droppable(droppableOptions); +}); + +// Interval change. +$("#interval").change(function(e) { + createDroppableZones(droppableOptions, getModulesByGraphs()); +}); + +// Collapse filters. +$("div.filters-div-main > .filters-div-header > img").click(function(e) { + if ($(".filters-div-main").hasClass("filters-div-main-collapsed") === true) { + $(".filters-div-header > img").attr("src", "images/menu/contraer.svg"); + $(".filters-div-main").removeClass("filters-div-main-collapsed"); + } else { + $(".filters-div-header > img").attr("src", "images/menu/expandir.svg"); + $(".filters-div-main").addClass("filters-div-main-collapsed"); + } +}); + +// Search left. +$("#search-left").keyup(function(e) { + if ($(this).val() !== "") { + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + search_left: e.target.value + }, + success: function(data) { + if (data.agents || data.groups || data.modules) { + var agentsToggle = $( + "#agents-toggle > div[id^=tgl_div_] > div.white-box-content" + ); + var groupsToggle = $( + "#groups-toggle > div[id^=tgl_div_] > div.white-box-content" + ); + var modulesToggle = $( + "#modules-toggle > div[id^=tgl_div_] > div.white-box-content" + ); + agentsToggle.empty(); + groupsToggle.empty(); + modulesToggle.empty(); + + if (data.agents) { + $("#agents-toggle").show(); + data.agents.forEach(agent => { + agentsToggle.append( + `
${agent.alias}
` + ); + }); + } else { + $("#agents-toggle").hide(); + } + + if (data.groups) { + $("#groups-toggle").show(); + data.groups.forEach(group => { + groupsToggle.append( + `
${group.nombre}
` + ); + }); + } else { + $("#groups-toggle").hide(); + } + + if (data.modules) { + $("#modules-toggle").show(); + data.modules.forEach(module => { + modulesToggle.append( + `
${module.nombre}
` + ); + }); + } else { + $("#modules-toggle").hide(); + } + + // Create draggable elements. + $(".draggable").draggable({ + revert: "invalid", + stack: ".draggable", + helper: "clone" + }); + } else { + console.error("NO DATA FOUND"); + } + } + }); + } +}); + +function clickAgent(e) { + $("#search-agent").val($(e).data("id-agent")); + $("#search-group").val(""); + searchRight($("#search-right").val()); +} + +function clickGroup(e) { + $("#search-group").val($(e).data("id-group")); + $("#search-agent").val(""); + searchRight($("#search-right").val()); +} + +// Search right. +$("#search-right").keyup(function(e) { + if ($("#search-right") !== "") { + searchRight(e.target.value); + } +}); + +function searchRight(freeSearch) { + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + search_right: true, + free_search: freeSearch, + search_agent: $("#search-agent").val(), + search_group: $("#search-group").val() + }, + success: function(data) { + var modulesRight = $("#modules-right"); + + if (data.modules) { + modulesRight.empty(); + + data.modules.forEach(module => { + modulesRight.append( + `
${module.nombre}
` + ); + }); + + // Create draggable elements. + $(".draggable").draggable({ + revert: "invalid", + stack: ".draggable", + helper: "clone" + }); + } else { + modulesRight.empty(); + console.error("NO DATA FOUND"); + } + } + }); +} + +function createDroppableZones( + droppableOptions, + modulesByGraphs, + homeurl = "", + getInterval = 0 +) { + var url = "ajax.php"; + var interval = $("#interval").val(); + + if (homeurl !== "") { + url = homeurl + "/ajax.php"; + } + + if (getInterval !== 0) { + interval = getInterval; + } + + // Clear graph area. + $("#droppable-graphs").empty(); + + // Reset realtime data. + realtimeGraphs = []; + + // Graph modules. + modulesByGraphs + .slice() + .reverse() + .forEach(graph => { + // Max modules by graph. + var droppableClass = ""; + if (graph.length < 2) { + droppableClass = "droppable"; + } + + // Create graph div. + var graphDiv = $( + `
` + ); + $("#droppable-graphs").prepend(graphDiv); + + // Print graphs. + $.ajax({ + method: "POST", + url, + dataType: "html", + data: { + page: "operation/reporting/graph_analytics", + get_graphs: graph, + interval + }, + success: function(data) { + if (data) { + graphDiv.append( + $( + `
${data}
` + ) + ); + } + } + }); + + // Create next droppable zone. + graphDiv.after( + $( + `
${dropHere}
` + ) + ); + }); + + // Create first droppable zones and graphs. + $("#droppable-graphs").prepend( + $( + `
${dropHere}
` + ) + ); + + // Set droppable zones. + $(".droppable").droppable(droppableOptions); + + // todo: Create draggable graphs. +} + +function getModulesByGraphs() { + var modulesByGraphs = []; + $("#droppable-graphs > div").each(function(i, v) { + var modulesTmp = $(v).data("modules"); + if (modulesTmp.length > 0) { + modulesByGraphs.push(modulesTmp); + } + }); + + return modulesByGraphs; +} + +function realtimeGraph() { + realtimeGraphsTmp = realtimeGraphs; + realtimeGraphs = []; + + realtimeGraphsTmp.forEach(graph => { + $.each(graph.series_type, function(i, v) { + // Get new values. + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + get_new_values: graph.values[i].agent_module_id, + date_array: graph.date_array, + data_module_graph: graph.data_module_graph, + params: graph.params, + suffix: i.slice(-1) + }, + success: function(data) { + if (data) { + // Set new values + graph.values[i].data = data[i].data; + } + } + }); + }); + + // New periods. + var period = $("#interval").val(); + var time = Math.floor(Date.now() / 1000); + + graph.params.date = time; + + var date_array = { + period, + final_date: time, + start_date: time - period + }; + + pandoraFlotArea( + graph.graph_id, + graph.values, + graph.legend, + graph.series_type, + graph.color, + date_array, + graph.data_module_graph, + graph.params, + graph.events_array + ); + }); +} + +// Action buttons. +// Start/Pause Realtime. +var realtimeGraphInterval; +$("[data-button=pause-realtime]") + .parent() + .hide(); + +$("[data-button=start-realtime]").click(function(e) { + $("[data-button=start-realtime]") + .parent() + .hide(); + $("[data-button=pause-realtime]") + .parent() + .show(); + + realtimeGraphInterval = setInterval(realtimeGraph, 5000); +}); + +$("[data-button=pause-realtime]").click(function(e) { + $("[data-button=pause-realtime]") + .parent() + .hide(); + $("[data-button=start-realtime]") + .parent() + .show(); + + clearInterval(realtimeGraphInterval); +}); + +// New graph. +$("[data-button=new]").click(function(e) { + confirmDialog({ + title: titleNew, + message: messageNew, + onAccept: function() { + $("#droppable-graphs").empty(); + + // Create graph div. + $("#droppable-graphs").prepend( + $( + `
${dropHere}
` + ) + ); + $(".droppable").droppable(droppableOptions); + + // Reset realtime button. + $("[data-button=pause-realtime]") + .parent() + .hide(); + $("[data-button=start-realtime]") + .parent() + .show(); + } + }); +}); + +// Save graps modal. +$("[data-button=save]").click(function(e) { + // Filter save mode selector + $("#save_filter_row1").show(); + $("#save_filter_row2").show(); + $("#update_filter_row1").hide(); + $("#radiobtn0002").prop("checked", false); + $("#radiobtn0001").prop("checked", true); + $("#text-id_name").val(""); + + $("[name='filter_mode']").click(function() { + if ($(this).val() == "new") { + $("#save_filter_row1").show(); + $("#save_filter_row2").show(); + $("#submit-save_filter").show(); + $("#update_filter_row1").hide(); + } else { + $("#save_filter_row1").hide(); + $("#save_filter_row2").hide(); + $("#update_filter_row1").show(); + $("#submit-save_filter").hide(); + } + }); + + $("#save-filter-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: 350 + }); +}); + +// Save filter button. +function save_new_filter() { + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "html", + data: { + page: "operation/reporting/graph_analytics", + save_filter: $("#text-id_name").val(), + graphs: getModulesByGraphs(), + interval: $("#interval").val() + }, + success: function(data) { + if (data == "saved") { + confirmDialog({ + title: titleSave, + message: messageSave, + hideCancelButton: true, + onAccept: function() { + $( + "button.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close" + ).click(); + } + }); + } else { + var message = messageSaveEmpty; + if (data === "") { + message = messageSaveEmptyName; + } + confirmDialog({ + title: titleError, + message, + hideCancelButton: true + }); + } + } + }); +} + +// Update filter button. +function save_update_filter() { + confirmDialog({ + title: titleUpdate, + message: messageUpdate, + onAccept: function() { + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "html", + data: { + page: "operation/reporting/graph_analytics", + update_filter: $("#overwrite_filter").val(), + graphs: getModulesByGraphs(), + interval: $("#interval").val() + }, + success: function(data) { + if (data == "updated") { + confirmDialog({ + title: titleUpdateConfirm, + message: messageUpdateConfirm, + hideCancelButton: true, + onAccept: function() { + $( + "button.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close" + ).click(); + } + }); + } else { + confirmDialog({ + title: titleUpdateError, + message: messageUpdateError, + hideCancelButton: true + }); + } + } + }); + } + }); +} + +// Load graps modal. +$("[data-button=load]").click(function(e) { + $("#load-filter-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto" + }); +}); + +// Load filter button. +function load_filter_values(id = 0, homeurl) { + var url = "ajax.php"; + var filterId = $("#filter_id").val(); + + if (id !== 0) { + filterId = id; + url = homeurl + "/ajax.php"; + } + + if (id === 0) { + confirmDialog({ + title: titleLoad, + message: messageLoad, + onAccept: function() { + loadFilter(url, filterId, homeurl, id); + } + }); + } else { + loadFilter(url, filterId, homeurl, id); + } +} + +function loadFilter(url, filterId, homeurl, id) { + $.ajax({ + method: "POST", + url, + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_filter: filterId + }, + success: function(data) { + if (data) { + createDroppableZones( + droppableOptions, + data.graphs, + homeurl, + data.interval + ); + if (id === 0) { + $("#interval") + .val(data.interval) + .trigger("change"); + } + + $( + "button.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close" + ).click(); + + // Reset realtime button. + if (id === 0) { + $("[data-button=pause-realtime]") + .parent() + .hide(); + $("[data-button=start-realtime]") + .parent() + .show(); + } + } else { + confirmDialog({ + title: titleLoadConfirm, + message: messageLoadConfirm, + hideCancelButton: true + }); + } + } + }); +} + +// Share button. +$("[data-button=share]").click(function(e) { + $("#share-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto" + }); +}); + +$("#button-share-modal").click(function(e) { + const hash = $("#hash_share").val(); + const idFilter = btoa($("#share-id").val()); + const idUser = $("#id_user").val(); + + const queryParams = "hash=" + hash + "&id=" + idFilter + "&id_user=" + idUser; + + window.open( + configHomeurl + + "/operation/reporting/graph_analytics_public.php?" + + queryParams + ); +}); + +// Export button. +$("[data-button=export]").click(function(e) { + $("#export-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto", + title: titleExport + }); +}); + +$("#button-export-modal").click(function(e) { + const filter = parseInt($("#export-filter-id").val()); + const group = parseInt($("#export-group-id").val()); + + if (filter !== 0 && group !== 0) { + // todo: Ajax save in tgraph & tgraph_source. + } +}); diff --git a/pandora_console/include/styles/graph_analytics.css b/pandora_console/include/styles/graph_analytics.css index c9ae76fe8f..a21c532ab7 100644 --- a/pandora_console/include/styles/graph_analytics.css +++ b/pandora_console/include/styles/graph_analytics.css @@ -68,6 +68,10 @@ div.main-div { min-height: calc(100vh - 160px); } +div.main-div.graph-analytics-public { + min-height: calc(100vh - 2px); +} + div.padding-div { margin: 0; padding: 10px; @@ -88,6 +92,7 @@ div.filters-div-main { div.filters-div-main.filters-div-main-collapsed { width: 35px; min-width: 20px; + border-right: 0px; } div.filters-div-main.filters-div-main-collapsed diff --git a/pandora_console/operation/reporting/graph_analytics.php b/pandora_console/operation/reporting/graph_analytics.php index 1b6751fa1a..5ce6d97bdf 100644 --- a/pandora_console/operation/reporting/graph_analytics.php +++ b/pandora_console/operation/reporting/graph_analytics.php @@ -28,8 +28,11 @@ // Begin. global $config; + check_login(); +use PandoraFMS\User; + // Requires. ui_require_css_file('graph_analytics'); require_once 'include/functions_custom_graphs.php'; @@ -474,6 +477,126 @@ $table->rowclass[] = ''; html_print_table($table); echo '
'; +// Share modal. +echo ''; + +// Export graphs. +echo ''; + + // Header & Actions. $title_tab = __('Start realtime'); $tab_start_realtime = [ @@ -535,6 +658,9 @@ $tab_load = [ ).$title_tab.'', ]; +// Hash for auto-auth in public link. +$hash = User::generatePublicHash(); + $title_tab = __('Share'); $tab_share = [ 'text' => ''.html_print_image( @@ -544,7 +670,8 @@ $tab_share = [ 'title' => $title_tab, 'class' => 'invert_filter main_menu_icon', ] - ).$title_tab.'', + ).$title_tab.' + ', ]; $title_tab = __('Export to custom graph'); @@ -698,9 +825,7 @@ $right_content .= '
'.__('Drop here').'
'; -//
-//
-//
+ $filters_div = html_print_div( [ 'class' => 'filters-div-main', @@ -724,482 +849,37 @@ html_print_div( ] ); - +ui_require_javascript_file('graph_analytics', 'include/javascript/', true); ?> \ No newline at end of file diff --git a/pandora_console/operation/reporting/graph_analytics_public.php b/pandora_console/operation/reporting/graph_analytics_public.php new file mode 100644 index 0000000000..434bb89809 --- /dev/null +++ b/pandora_console/operation/reporting/graph_analytics_public.php @@ -0,0 +1,191 @@ + + + + + + + '.get_product_name().$text_subtitle.' +'; + +// CSS. +ui_require_css_file('common', 'include/styles/', true); +ui_require_css_file('pandora', 'include/styles/', true); +ui_require_css_file('discovery', 'include/styles/', true); +ui_require_css_file('register', 'include/styles/', true); +ui_require_css_file('order_interpreter', 'include/styles/', true); +ui_require_css_file('graph_analytics', 'include/styles/', true); +ui_require_css_file('jquery-ui.min', 'include/styles/js/', true); +ui_require_css_file('jquery-ui_custom', 'include/styles/js/', true); +ui_require_css_file('introjs', 'include/styles/js/', true); +ui_require_css_file('events', 'include/styles/', true); + +// JS. +ui_require_javascript_file('jquery.current', 'include/javascript/', true); +ui_require_javascript_file('jquery.pandora', 'include/javascript/', true); +ui_require_javascript_file('jquery-ui.min', 'include/javascript/', true); +ui_require_javascript_file('jquery.countdown', 'include/javascript/', true); +ui_require_javascript_file('pandora', 'include/javascript/', true); +ui_require_javascript_file('pandora_ui', 'include/javascript/', true); +ui_require_javascript_file('pandora_events', 'include/javascript/', true); +ui_require_javascript_file('select2.min', 'include/javascript/', true); +// ui_require_javascript_file('connection_check', 'include/javascript/', true); +ui_require_javascript_file('encode_decode_base64', 'include/javascript/', true); +ui_require_javascript_file('qrcode', 'include/javascript/', true); +ui_require_javascript_file('intro', 'include/javascript/', true); +ui_require_javascript_file('clippy', 'include/javascript/', true); +ui_require_javascript_file('underscore-min', 'include/javascript/', true); + +echo ' + +'; + + + +ui_require_javascript_file('date', 'include/javascript/timezone/src/', true); +ui_require_javascript_file('jquery.flot.min', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.time', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.pie', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.crosshair.min', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.stack.min', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.selection.min', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.resize.min', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.threshold', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.threshold.multiple', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.symbol.min', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.exportdata.pandora', 'include/graphs/flot/', true); +ui_require_javascript_file('jquery.flot.axislabels', 'include/graphs/flot/', true); +ui_require_javascript_file('pandora.flot', 'include/graphs/flot/', true); +ui_require_javascript_file('chart', 'include/graphs/chartjs/', true); +ui_require_javascript_file('chartjs-plugin-datalabels.min', 'include/graphs/chartjs/', true); + + + +ui_require_javascript_file('graph_analytics', 'include/javascript/', true); + + +echo ' + + +'; + +// Content. +$right_content = ''; + +$right_content .= ' +
+
'.__('Drop here').'
+
+'; + +$graphs_div = html_print_div( + [ + 'class' => 'padding-div graphs-div-main', + 'content' => $right_content, + ], + true +); + +html_print_div( + [ + 'class' => 'white_box main-div graph-analytics-public', + 'content' => $graphs_div, + ] +); + +?> + + + + + \ No newline at end of file From 72bd992a982e9c71142be8cd126841c2d2d7e02c Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 22 Aug 2023 17:17:34 +0200 Subject: [PATCH 29/97] Add pandora_sca.exe to the repo. Ref. pandora_enterprise#11324. --- pandora_agents/win32/bin/util/pandora_sca.exe | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 pandora_agents/win32/bin/util/pandora_sca.exe diff --git a/pandora_agents/win32/bin/util/pandora_sca.exe b/pandora_agents/win32/bin/util/pandora_sca.exe new file mode 100755 index 0000000000..be447566e1 --- /dev/null +++ b/pandora_agents/win32/bin/util/pandora_sca.exe @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d93bd9d56c938063045fa2093198d324746f84df2b74567648f3baebd635657 +size 5248006 From 1b4212ee532b4f3c7e728e4a4fdf92041dd8690b Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 22 Aug 2023 18:03:44 +0200 Subject: [PATCH 30/97] Add the security compliance plug-in to pandora_agent.conf. --- pandora_agents/win32/bin/pandora_agent.conf | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 1a44a8048e..4f77777f08 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -522,4 +522,11 @@ module_plugin "%PROGRAMFILES%\Pandora_Agent\util\autodiscover.exe" --default #module_type generic_data_string #module_exec echo Bordón #module_native_encoding OEM -#module_end \ No newline at end of file +#module_end + +# Hardening plugin for security compliance analysis. +#module_begin +#module_plugin "%PROGRAMFILES%\Pandora_Agent\util\pandora_sca.exe" +#module_absoluteinterval 7d +#module_end + From 71ddd711466d4ff2278d78f6d5acb9c081c33ac8 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 23 Aug 2023 01:00:53 +0200 Subject: [PATCH 31/97] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 916d4021bb..27b6eccfe0 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.773.1-230822 +Version: 7.0NG.773.1-230823 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 9dda816e8a..4afa5d54b1 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.773.1-230822" +pandora_version="7.0NG.773.1-230823" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 0ed89efb7d..8dc24a4f6f 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1031,7 +1031,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.773.1'; -use constant AGENT_BUILD => '230822'; +use constant AGENT_BUILD => '230823'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 707d3e4ec0..88f92ec31e 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.773.1 -%define release 230822 +%define release 230823 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index a2fcfa3ae8..7bc448e7d7 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.773.1 -%define release 230822 +%define release 230823 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 224c90e4c7..b5a5722872 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.773.1" -PI_BUILD="230822" +PI_BUILD="230823" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 50cda79363..676fa3c84d 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230822} +{230823} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 95e40871f5..91f30018f0 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.773.1 Build 230822") +#define PANDORA_VERSION ("7.0NG.773.1 Build 230823") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 219d251ddf..ef231be60a 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.773.1(Build 230822))" + VALUE "ProductVersion", "(7.0NG.773.1(Build 230823))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index b8ecfe51bd..7bed7edec7 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.773.1-230822 +Version: 7.0NG.773.1-230823 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index b5958b5d85..1ea36432fc 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.773.1-230822" +pandora_version="7.0NG.773.1-230823" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 682d0b382b..4caeeed582 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC230822'; +$build_version = 'PC230823'; $pandora_version = 'v7.0NG.773.1'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 15f3603de4..336ee13671 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index ba5f9909d5..acd2813fd2 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.773.1 -%define release 230822 +%define release 230823 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 2a336745bb..f7d0eba035 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.773.1" -PI_BUILD="230822" +PI_BUILD="230823" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index d027236d45..d6ef5c4334 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.773.1 Build 230822"; +my $version = "7.0NG.773.1 Build 230823"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 2a67b5c576..4d9e2fc6fe 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.773.1 Build 230822"; +my $version = "7.0NG.773.1 Build 230823"; # save program name for logging my $progname = basename($0); From 3a39670faf93c45c547838d13d72ab8d966d0925 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 23 Aug 2023 10:08:45 +0200 Subject: [PATCH 32/97] #11547 fix profile admin --- pandora_console/include/functions_menu.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index d250643cde..614c0df43e 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -951,7 +951,7 @@ if (is_ajax()) { '; - if ($config['is_admin']['admin'] === true) { + if ((bool) check_acl($config['id_user'], 0, 'PM') === true || $config['is_admin']['admin'] === true) { $dialog .= '
From b0aa8f3fb2220c376ce49e3f928492344a10bb54 Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 23 Aug 2023 10:34:19 +0200 Subject: [PATCH 33/97] adding autoinstall for tools and docs --- pandora_console/install.php | 1348 ----------------- pandora_server/util/load/README.MD | 44 +- .../util/load/create_usersandgroups.sh | 4 +- .../util/load/generate_inventory_data.sh | 6 +- pandora_server/util/load/install_load_data.sh | 55 + .../util/load/pandora_xml_stress.log | 24 + tentacle/tentacle_client | 2 +- 7 files changed, 123 insertions(+), 1360 deletions(-) delete mode 100644 pandora_console/install.php mode change 100644 => 100755 pandora_server/util/load/create_usersandgroups.sh create mode 100755 pandora_server/util/load/install_load_data.sh create mode 100644 pandora_server/util/load/pandora_xml_stress.log diff --git a/pandora_console/install.php b/pandora_console/install.php deleted file mode 100644 index 336ee13671..0000000000 --- a/pandora_console/install.php +++ /dev/null @@ -1,1348 +0,0 @@ - - - - - Pandora FMS - Installation Wizard - - - - - - - - - - - - - - - - - - -
- -
- - - -
'; -} - -/** - * Check if file exist and print a - * new row in the table with the result - * - * @param string $file File. - * @param string $label Label file. - * - * @return integer status - */ -function check_exists($file, $label) -{ - echo ''; -} - - -/** - * Check variable ok and return row - * with 'checked' if is 1 or 'incomplete' if is 0 - * - * @param integer $ok Status. - * @param string $label Label to show. - * - * @return integer status - */ -function check_generic($ok, $label) -{ - echo ''; - echo ''; - return 1; - } else { - echo " $label "; - echo ''; - echo ''; - return 0; - } -} - - -/** - * Check if path is writable and print a - * new row in the table with the result. - * - * @param string $fullpath Path folder or file. - * @param string $label Label to show. - * - * @return integer status - */ -function check_writable($fullpath, $label) -{ - echo ''; - echo ''; - echo ''; - return 0; - } else { - echo " $label "; - echo ''; - echo ''; - echo ''; - return 1; - } - } else { - echo " $label "; - echo ''; - echo ''; - return 1; - } -} - - -/** - * Check if $var is equal to $value and - * print result in a row. - * - * @param string $var Variable. - * @param string $value Value to check. - * @param string $label Label to show. - * @param integer $mode Mode. - * - * @return integer status - */ -function check_variable($var, $value, $label, $mode) -{ - echo ''; -} - - -function parse_mysql_dump($url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysql_query($query)) { - echo mysql_error(); - // Uncomment for debug - echo "
$query
"; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -/** - * Parse sql to script dump, execute it - * and return if exist error. - * - * @param object $connection Connection sql. - * @param string $url Path file sql script. - * - * @return integer status - */ -function parse_mysqli_dump($connection, $url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysqli_query($connection, $query)) { - if (mysqli_error($connection)) { - return mysqli_error($connection).'
'.$query.'
'; - } - - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -/** - * Generate a random password - * - * Admits a huge mount of ASCII chars. - * - * @param integer $size Size of the password returned. - * - * @return string $output - */ -function random_name(int $size) -{ - $output = ''; - - // Range pair of ASCII position for allow A-Z, a-z, 0-9 and special chars. - $rangeSeed = [ - '48:57', - '65:90', - '97:122', - '40:47', - ]; - - // Size of the password must be over range seed count. - $size = ($size >= count($rangeSeed)) ? $size : count($rangeSeed); - - $auxIndex = 0; - for ($i = 0; $i < $size; $i++) { - $tmpSeedValues = explode(':', $rangeSeed[$auxIndex]); - $output = $output.chr(rand($tmpSeedValues[1], $tmpSeedValues[0])); - $auxIndex++; - if ($auxIndex >= 4) { - $auxIndex = 0; - } - } - - // Remix the string for strong the password. - return str_shuffle($output); -} - - -/** - * Print the header installation - * - * @param integer $step Number of step. - * - * @return string Html output. - */ -function print_logo_status($step) -{ - global $banner; - - $header = ' -
-

Pandora FMS OpenSource Installer - '.$banner.' -

-
- 1 -
- 2 -
- 3 -
- 4 -
- 5 -
- 6 - -
-
- '; - - return $header; -} - - -/** - * This function adjusts path settings in pandora db for FreeBSD. - * All packages and configuration files except operating system's base files - * are installed under /usr/local in FreeBSD. So, path settings in pandora db - * for some programs should be changed from the Linux default. - * - * @param string $engine Type of engine. - * @param object $connection Connection database. - * - * @return integer Status. - */ -function adjust_paths_for_freebsd($engine, $connection=false) -{ - $adjust_sql = [ - "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');", - "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';", - "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');", - "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');", - "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');", - "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');", - "insert into tconfig (token, value) VALUES ('graphviz_bin_dir', '/usr/local/bin');", - ]; - - for ($i = 0; $i < count($adjust_sql); $i++) { - switch ($engine) { - case 'mysql': - $result = mysql_query($adjust_sql[$i]); - break; - - case 'mysqli': - $result = mysqli_query($connection, $adjust_sql[$i]); - break; - - case 'oracle': - // Delete the last semicolon from current query - $query = substr($adjust_sql[$i], 0, (strlen($adjust_sql[$i]) - 1)); - $sql = oci_parse($connection, $query); - $result = oci_execute($sql); - break; - - case 'pgsql': - pg_send_query($connection, $adjust_sql[$i]); - $result = pg_get_result($connection); - break; - } - - if (!$result) { - return 0; - } - } - - return 1; -} - - -/** - * Print all step 1 - * - * @return void - */ -function install_step1() -{ - echo " -
-
- ".print_logo_status(1, 6)." -
-
-
-

Welcome to Pandora FMS installation Wizard

-

This wizard helps you to quick install Pandora FMS console and main database in your system. - In four steps, this installer will check all dependencies and will create your configuration, ready to use.

-

For more information, please refer to documentation →

- "; - if (file_exists('include/config.php')) { - echo "
You already have a config.php file. - Configuration and database would be overwritten if you continued.
"; - } - - echo '
'; - echo '
'; - echo " $label "; - echo ''; - if (!extension_loaded($ext)) { - echo "incomplete"; - return 1; - } else { - echo "checked"; - return 0; - } - - echo '
'; - echo " $label "; - echo ''; - if (!file_exists($file)) { - echo " incomplete"; - return 1; - } else { - echo " checked"; - return 0; - } - - echo '
'; - if ($ok == 0) { - echo " $label "; - echo ''; - echo " incomplete"; - echo '
'; - echo " checked"; - echo '
'; - if (file_exists($fullpath)) { - if (is_writable($fullpath)) { - echo " $label "; - echo ''; - echo "checked"; - echo '
'; - echo "incomplete"; - echo '
'; - echo "incomplete"; - echo '
'; - echo " $label "; - echo ''; - if ($mode == 1) { - if ($var >= $value) { - echo "checked"; - return 0; - } else { - echo "incomplete"; - return 1; - } - } else if ($var == $value) { - echo "checked"; - return 0; - } else { - echo "incomplete"; - return 1; - } - - echo '
'; - $writable = check_writable('include', './include is writable'); - if (file_exists('include/config.php')) { - $writable += check_writable('include/config.php', 'include/config.php is writable'); - } - - echo '
'; - - echo "
This installer will overwrite and destroy - your existing Pandora FMS configuration and Database. Before continue, - please be sure that you have no valuable Pandora FMS data in your Database.
-
"; - - if ($writable !== 0) { - echo "
You need to setup permissions to be able to write in ./include directory
"; - } - - echo '
'; - - echo "
"; - echo " -
-
-
-
-
-
-
-
-
-
-
- -
-
'; -} - - -/** - * Print license content - * - * @return void - */ -function install_step1_licence() -{ - echo " -
-
- ".print_logo_status(2, 6)." -
-

GPL2 Licence terms agreement

-

Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, you must accept the licence terms.. -

For more information, please refer to our website at https://pandorafms.com/community/ and contact us if you have any kind of question about the usage of Pandora FMS

-

If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.

- "; - - if (!file_exists('COPYING')) { - echo "
Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file."; - echo '
'; - } else { - echo "'; - echo '

'; - } - - echo '

'; - - echo "
-
-
'; -} - - -/** - * Print all step 2 - * - * @return void - */ -function install_step2() -{ - echo " -
-
- ".print_logo_status(3, 6)." -
"; - echo '

Checking software dependencies

'; - echo ' -
-
- '; - $res = 0; - $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1); - $res += check_extension('gd', 'PHP GD extension'); - $res += check_extension('ldap', 'PHP LDAP extension'); - $res += check_extension('snmp', 'PHP SNMP extension'); - $res += check_extension('session', 'PHP session extension'); - $res += check_extension('gettext', 'PHP gettext extension'); - $res += check_extension('mbstring', 'PHP Multibyte String'); - $res += check_extension('zip', 'PHP Zip'); - $res += check_extension('zlib', 'PHP Zlib extension'); - $res += check_extension('json', 'PHP json extension'); - $res += check_extension('curl', 'CURL (Client URL Library)'); - $res += check_extension('filter', 'PHP filter extension'); - $res += check_extension('calendar', 'PHP calendar extension'); - if (PHP_OS == 'FreeBSD') { - $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); - } else if (PHP_OS == 'NetBSD') { - $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); - } else if (substr(PHP_OS, 0, 3) == 'WIN') { - $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); - } else { - $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); - } - - echo ''; - check_extension('mysqli', 'PHP MySQL(mysqli) extension'); - echo '
'; - echo "DB Engines"; - echo ''; - echo '
'; - if ($res > 0) { - echo "
-
You have some incomplete - dependencies. Please correct them or this installer - will not be able to finish your installation. -
-
- Remember, if you install any PHP module to comply - with these dependences, you need to restart - your HTTP/Apache server after it to use the new - modules. -
-
"; - } - - echo '
'; - echo "
-
-
'; -} - - -/** - * Print all step 3 - * - * @return void - */ -function install_step3() -{ - $options = []; - if (extension_loaded('mysql')) { - $options['mysql'] = 'MySQL'; - } - - if (extension_loaded('mysqli')) { - $options['mysqli'] = 'MySQL(mysqli)'; - } - - $error = false; - if (empty($options)) { - $error = true; - } - - echo " -
-
- ".print_logo_status(4, 6)." -
-
-
-

Environment and database setup

-

- This wizard will create your Pandora FMS database, - and populate it with all the data needed to run for the first time. -

-

- You need a privileged user to create database schema, this is usually root user. - Information about root user will not be used or stored anymore. -

-

- You can also deploy the scheme into an existing Database. - In this case you need a privileged Database user and password of that instance. -

-

- Now, please, complete all details to configure your database and environment setup. -

-
- This installer will overwrite and destroy your existing - Pandora FMS configuration and Database. Before continue, - please be sure that you have no valuable Pandora FMS data in your Database. -

-
"; - if ($error) { - echo "
- You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. -
"; - } - - if (extension_loaded('oci8')) { - echo "
For Oracle installation an existing Database with a privileged user is needed.
"; - } - - echo '
'; - echo '
'; - if (!$error) { - echo "
"; - } - - echo ""; - - if (!$error) { - echo ' - - - - - - - "; - - // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost - echo " - - "; - - echo " - - "; - echo " - - - "; - - echo " - - "; - - echo '
'; - echo '

DB Engine

'; - - echo ''; - - echo ''; - - echo '
'; - echo '

Installation in

'; - - echo ''; - - echo ''; - } - - echo "
-

DB User with privileges

- -
-

DB Password for this user

- -
-

DB Hostname

- -
-

DB Name (pandora by default)

- -
-

Full path to HTTP publication directory

-

For example /var/www/pandora_console/

- -
-

URL path to Pandora FMS Console

-

For example '/pandora_console'

- -
- -

Drop Database if exists

-
'; - - echo '
'; - - echo '
'; - echo '
'; - echo "
- '; -} - - -/** - * Print all step 4 - * - * @return void - */ -function install_step4() -{ - $pandora_config = 'include/config.php'; - - if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) - || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) - ) { - $dbpassword = ''; - $dbuser = ''; - $dbhost = ''; - $dbname = ''; - $engine = ''; - $dbaction = ''; - $dbgrant = ''; - } else { - $engine = $_POST['engine']; - $dbpassword = $_POST['pass']; - $dbuser = $_POST['user']; - $dbhost = $_POST['host']; - $dbaction = $_POST['db_action']; - if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { - $dbgrant = $_POST['dbgrant']; - } else { - $dbgrant = $_SERVER['SERVER_ADDR']; - } - - if (isset($_POST['drop'])) { - $dbdrop = $_POST['drop']; - } else { - $dbdrop = 0; - } - - $dbname = $_POST['dbname']; - if (isset($_POST['url'])) { - $url = $_POST['url']; - } else { - $url = 'http://localhost'; - } - - if (isset($_POST['path'])) { - $path = $_POST['path']; - $path = str_replace('\\', '/', $path); - // Windows compatibility - } else { - $path = '/var/www'; - } - } - - $everything_ok = 0; - $step1 = 0; - $step2 = 0; - $step3 = 0; - $step4 = 0; - $step5 = 0; - $step6 = 0; - $step7 = 0; - $errors = []; - echo " -
-
- ".print_logo_status(5, 6)." -
-
-
- "; - switch ($engine) { - case 'mysql': - if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysql_query("DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysql_query("CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysql_select_db($dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysql_dump('pandoradb.sql'); - - if ($step3 !== 0 && $step3 !== 1) { - $errors[] = $step3; - $step3 = 0; - } - - check_generic($step3, 'Creating schema'); - $step4 = parse_mysql_dump('pandoradb_data.sql'); - - if ($step4 !== 0 && $step4 !== 1) { - $errors[] = $step4; - $step4 = 0; - } - - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysql_query( - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysql_query('FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password

Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file

"); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - - case 'mysqli': - $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); - if (mysqli_connect_error() > 0) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysqli_select_db($connection, $dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); - if ($step3 !== 0 && $step3 !== 1) { - $errors[] = $step3; - $step3 = 0; - } - - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); - - if ($step4 !== 0 && $step4 !== 1) { - $errors[] = $step4; - $step4 = 0; - } - - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine, $connection); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysqli_query( - $connection, - "CREATE USER IF NOT EXISTS pandora@$host" - ); - - mysqli_query( - $connection, - "SET PASSWORD FOR 'pandora'@'".$host."' = '".$random_password."'" - ); - - $step5 |= mysqli_query( - $connection, - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host" - ); - mysqli_query($connection, 'FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password

Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file

"); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - } - - echo '
'; - echo '
'; - echo '
'; - echo "

Creating database and default configuration file

"; - if ($everything_ok !== 1) { - $info = ''; - - if (!empty($errors)) { - foreach ($errors as $key => $err) { - $info .= '
'.$err.'
'; - } - - $info .= "
If you use MySQL 8 make sure to include the - following parameter in your installation's my.cnf configuration file
- sql_mode=\"\"
"; - } - - $info .= "
There were some problems. - Installation was not completed. -

Please correct failures before trying again. - All database "; - - if ($engine == 'oracle') { - $info .= 'objects '; - } else { - $info .= 'schemes '; - } - - $info .= 'created in this step have been dropped.

-
'; - echo $info; - - switch ($engine) { - case 'mysql': - if (mysql_error() != '') { - echo "
".mysql_error().'.
'; - echo "
If you use MySQL 8 make sure to include the - following parameter in your installation's my.cnf configuration file
- sql_mode=\"\"
"; - } - - if ($step1 == 1) { - mysql_query("DROP DATABASE $dbname"); - } - break; - - case 'mysqli': - if ($connection && mysqli_error($connection) != '') { - echo "
".mysqli_error($connection).'.
'; - echo "
If you use MySQL 8 make sure to include the - following parameter in your installation's my.cnf configuration file
- sql_mode=\"\"
"; - } - - if ($step1 == 1) { - mysqli_query($connection, "DROP DATABASE $dbname"); - } - break; - } - } - - echo '
'; - echo '
'; - echo '
'; - echo " -
-
'; -} - - -/** - * Print all step 5 - * - * @return void - */ -function install_step5() -{ - echo " -
-
- ".print_logo_status(6, 6)." -
-

Installation complete

-

For security, you now must manually delete this installer - ('install.php') file before trying to access to your Pandora FMS console. -

You should also install Pandora FMS Servers before trying to monitor anything; - please read documentation on how to install it.

-

Default user is 'admin' with password 'pandora', - please change it both as soon as possible.

-

Don't forget to check https://pandorafms.com - for updates. -

Select if you want to rename 'install.php'.

-
- - -
-

-
-
-
- -
-
"; -} diff --git a/pandora_server/util/load/README.MD b/pandora_server/util/load/README.MD index d042cb1503..c7556e3a07 100644 --- a/pandora_server/util/load/README.MD +++ b/pandora_server/util/load/README.MD @@ -1,7 +1,38 @@ -### Purpose of this toolkit +## Purpose of this toolkit This directory contains configuration files and small scripts to generate an environment with simulated data for testing purposes. +### Quik start +To add monitoring data, inventory, groups and users to a pandorafms environment automatically Just execute: +``` +/usr/share/pandora_server/util/load/install_load_data.sh +``` + +This command will creates: +- 30 Agents with inventory linux +- 30 Agents whith inventory Windows +- 300 Agents +- 44 Groups +- 34 Users + +Will randonly add users to groups and move agents to groups. +Creates a cronjob to generate agent data each 5 min and inventory data once a day. + +_note: make sure you have a licence with at least 300 agents or modify the /usr/share/pandora_server/util/load/pandora_xml_stress.agents to use max your licence limit agent amount before execute_ + +## Toolset description. +Here we describe the specific use for all the toolset the `install_load_data.sh` used automatically, to be used individualy if its needed + +### Generation of inventory agents +The script will use th file pandora_xml_stress.agents take by default the first 30 listed agents and add linux inventory and the last 30 listed agents and add windows inventory. +This will generate xml data using the templates on `templates` folder. + +to run it, execute +``` +cd pandorafms/pandora_server/util/load +./generate_inventory_data.sh +``` + ### Generation of XML files to simulate agent load There is a tool that comes configured with Pandora FMS to generate test data (pandora_xml_stress) and that generates XML. It has different options and in this directory is provided a configuration file and all the dictionaries and additional files to generate data of 300 agents, with pseudo-random names (like for example "7fb8a1a734c24cc22a5c75eb"). @@ -9,18 +40,18 @@ There is a tool that comes configured with Pandora FMS to generate test data (pa These agents are defined in the "pandora_xml_stress.agents" file. If you want less agents, you can delete elements in this file. To execute the XML generation manually from the code repository: - +``` cd pandorafms/pandora_server/util/load perl ../pandora_xml_stress.pl pandora_xml_stress.conf - +``` This will generate 300 XML in the /var/spool/pandora/data_in directory. If you create a scheduled execution of this command every 5 minutes (e.g. through cron), keep in mind that if the PandoraFMS server stops, it could have hundreds of thousands of XML files pending to be processed. Create /etc/cron.d/pandora_stress with this content: - +``` */5 * * * * root - +``` ### Generation of groups and users @@ -31,6 +62,7 @@ On the other hand, it will also create a series of groups, taking as source the Finally, it will take all the agents available in Pandora FMS and it will distribute them in an equal and random way among the available groups. You should only run it once: - +``` cd pandorafms/pandora_server/util/load ./create_userandgroups.sh +``` \ No newline at end of file diff --git a/pandora_server/util/load/create_usersandgroups.sh b/pandora_server/util/load/create_usersandgroups.sh old mode 100644 new mode 100755 index 36534bbf0b..418efa322d --- a/pandora_server/util/load/create_usersandgroups.sh +++ b/pandora_server/util/load/create_usersandgroups.sh @@ -35,7 +35,7 @@ done TOTAL_GROUPS=`cat groupnames.txt | wc -l` for username in `cat usernames.txt` do - RAN=`echo $RANDOM % $TOTAL_GROUPS + 1 | bc` + RAN=`echo $(($RANDOM % $TOTAL_GROUPS + 1))` GROUP_NAME=`cat groupnames.txt | tail -$RAN | head -1` /usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --add_profile $username "Operator (Read)" $GROUP_NAME @@ -45,7 +45,7 @@ done TOTAL_GROUPS=`cat groupnames.txt | wc -l` for agentname in `/usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --get_agents | cut -f 2 -d ","` do - RAN=`echo $RANDOM % $TOTAL_GROUPS + 1 | bc` + RAN=`echo $(($RANDOM % $TOTAL_GROUPS + 1))` GROUP_NAME=`cat groupnames.txt | tail -$RAN | head -1` /usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --update_agent $agentname group_name $GROUP_NAME done diff --git a/pandora_server/util/load/generate_inventory_data.sh b/pandora_server/util/load/generate_inventory_data.sh index b91ac24af7..cfd537d67e 100755 --- a/pandora_server/util/load/generate_inventory_data.sh +++ b/pandora_server/util/load/generate_inventory_data.sh @@ -11,7 +11,7 @@ linux_inventory=1 windows_inventory=1 # Variables -agent_count=5 +agent_count=30 data_in=/var/spool/pandora/data_in/ description='Demo data Agent' @@ -28,7 +28,7 @@ if [ $linux_inventory -eq 1 ] ; then 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 + for agent_name in $(cat pandora_xml_stress.agents | head -n ${agent_count}); do echo " - Adding invetory data to ${agent_name} linux agent" ip_add="10.0.0.$(( RANDOM % 255 + 1 ))" rand_number=$(( RANDOM % 10 + 1 )) @@ -50,7 +50,7 @@ if [ $windows_inventory -eq 1 ]; then 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 + for agent_name in $(cat pandora_xml_stress.agents | tail -n ${agent_count}); do echo " - Adding invetory data to ${agent_name} windows agent" ip_add="172.16.5.$(( RANDOM % 255 + 1 ))" rand_number=$(( RANDOM % 100 + 1 )) diff --git a/pandora_server/util/load/install_load_data.sh b/pandora_server/util/load/install_load_data.sh new file mode 100755 index 0000000000..b2bcdfa18f --- /dev/null +++ b/pandora_server/util/load/install_load_data.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# (c) 2023 Pandora FMS +# This script is used to install a set of tools to load data automatically +# by default it will creates a set of users, groups and agents +# then set a cronjob to insert fake monitoring data to agents each 5 min +# and inventory data once a day. + +PREFIX='' + +# Moving directory +init_dir=$(pwd) +# Get the directory where the script is located +script_dir="$(dirname "$0")" +# Change the working directory to the script's directory +cd "$script_dir" || exit 1 + +# Check needed file exists +echo ' [INFO] Checking file requirements:' +if [ -f $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl ] && \ + [ -f $(pwd)/pandora_xml_stress.agents ] && \ + [ -f $(pwd)/pandora_xml_stress.conf ] && \ + [ -f $(pwd)/create_usersandgroups.sh ] && \ + [ -f $(pwd)/generate_inventory_data.sh ] && \ + [ -f $(pwd)/templates/inventory_linux.template ] && \ + [ -f $(pwd)/templates/inventory_windows.template] && \ + [ -f $(pwd)/pandora_xml_stress_module_source.txt ]; then + echo ' [INFO] All file exist, continue' +else + echo ' [ERROR] Missing files, please check.' && exit -1 +fi +# Create a set of users and grups +echo ' [INFO] Creating demo users and groups:' +$(pwd)/generate_inventory_data.sh +echo ' [INFO] Waiting for inventory agents to be created:' +while [ $(ls $PREFIX/var/spool/pandora/data_in/ | wc -l) -ge 10 ]; do + sleep 2 + echo -ne . +done +# Load init monitoring data +echo ' [INFO] Creating demo agent data:' +perl $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl $(pwd)/pandora_xml_stress.conf || echo ' [ERROR] Generating agent data cant be completed' +echo ' [INFO] Waiting for agents to be created:' +while [ $(ls $PREFIX/var/spool/pandora/data_in/ | wc -l) -ge 10 ]; do + sleep 2 + echo -ne . +done +# Create a set of users and grups +echo ' [INFO] Creating demo users and groups:' +$(pwd)/create_usersandgroups.sh +# Set cronjobs in /etc/crotab +echo ' [INFO] Adding data and inventory data to cronjob' +echo "*/5 * * * * root cd $(pwd) && perl $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl $(pwd)/pandora_xml_stress.conf " >> /etc/crontab +echo "0 0 * * * root cd $(pwd) && $(pwd)/generate_inventory_data.sh" >> /etc/crontab +# Get back init directory +cd $init_dir \ No newline at end of file diff --git a/pandora_server/util/load/pandora_xml_stress.log b/pandora_server/util/load/pandora_xml_stress.log new file mode 100644 index 0000000000..35a677d1a6 --- /dev/null +++ b/pandora_server/util/load/pandora_xml_stress.log @@ -0,0 +1,24 @@ +[1692774345] Generating XML data files for 300 agents from 2023-08-23 09:05:45 to 2023-08-23 09:05:45 interval 300. +[1692774345] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6964 per second) +[1692774481] Generating XML data files for 300 agents from 2023-08-23 09:08:01 to 2023-08-23 09:08:01 interval 300. +[1692774481] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6996 per second) +[1692775236] Generating XML data files for 300 agents from 2023-08-23 09:20:36 to 2023-08-23 09:20:36 interval 300. +[1692775236] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (7036 per second) +[1692775282] Generating XML data files for 300 agents from 2023-08-23 09:21:22 to 2023-08-23 09:21:22 interval 300. +[1692775282] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6935 per second) +[1692775320] Generating XML data files for 300 agents from 2023-08-23 09:22:00 to 2023-08-23 09:22:00 interval 300. +[1692775320] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6921 per second) +[1692775629] Generating XML data files for 300 agents from 2023-08-23 09:27:09 to 2023-08-23 09:27:09 interval 300. +[1692775629] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6927 per second) diff --git a/tentacle/tentacle_client b/tentacle/tentacle_client index ecc2da18bb..d90d21f344 100755 --- a/tentacle/tentacle_client +++ b/tentacle/tentacle_client @@ -1095,7 +1095,7 @@ Protocol description and more info at: L<< https://pandorafms.com/manual/en/docu =head1 COPYRIGHT -Copyright (c) 2005-2023 Pandora FMS. +Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L =cut From 0d172ec7c6af6914228b9cc8417f9bfbab11e43c Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 23 Aug 2023 10:36:23 +0200 Subject: [PATCH 34/97] adding autoinstall for tools and docs --- pandora_console/install.php | 1348 +++++++++++++++++++++++++++++++++++ 1 file changed, 1348 insertions(+) create mode 100644 pandora_console/install.php diff --git a/pandora_console/install.php b/pandora_console/install.php new file mode 100644 index 0000000000..336ee13671 --- /dev/null +++ b/pandora_console/install.php @@ -0,0 +1,1348 @@ + + + + + Pandora FMS - Installation Wizard + + + + + + + + + + + + + + + + + + +
+ +
+ + + +'; + echo " $label "; + echo ''; + if (!extension_loaded($ext)) { + echo "incomplete"; + return 1; + } else { + echo "checked"; + return 0; + } + + echo ''; +} + +/** + * Check if file exist and print a + * new row in the table with the result + * + * @param string $file File. + * @param string $label Label file. + * + * @return integer status + */ +function check_exists($file, $label) +{ + echo ''; + echo " $label "; + echo ''; + if (!file_exists($file)) { + echo " incomplete"; + return 1; + } else { + echo " checked"; + return 0; + } + + echo ''; +} + + +/** + * Check variable ok and return row + * with 'checked' if is 1 or 'incomplete' if is 0 + * + * @param integer $ok Status. + * @param string $label Label to show. + * + * @return integer status + */ +function check_generic($ok, $label) +{ + echo ''; + if ($ok == 0) { + echo " $label "; + echo ''; + echo " incomplete"; + echo ''; + echo ''; + return 1; + } else { + echo " $label "; + echo ''; + echo " checked"; + echo ''; + echo ''; + return 0; + } +} + + +/** + * Check if path is writable and print a + * new row in the table with the result. + * + * @param string $fullpath Path folder or file. + * @param string $label Label to show. + * + * @return integer status + */ +function check_writable($fullpath, $label) +{ + echo ''; + if (file_exists($fullpath)) { + if (is_writable($fullpath)) { + echo " $label "; + echo ''; + echo ''; + echo "checked"; + echo ''; + echo ''; + return 0; + } else { + echo " $label "; + echo ''; + echo ''; + echo "incomplete"; + echo ''; + echo ''; + return 1; + } + } else { + echo " $label "; + echo ''; + echo "incomplete"; + echo ''; + echo ''; + return 1; + } +} + + +/** + * Check if $var is equal to $value and + * print result in a row. + * + * @param string $var Variable. + * @param string $value Value to check. + * @param string $label Label to show. + * @param integer $mode Mode. + * + * @return integer status + */ +function check_variable($var, $value, $label, $mode) +{ + echo ''; + echo " $label "; + echo ''; + if ($mode == 1) { + if ($var >= $value) { + echo "checked"; + return 0; + } else { + echo "incomplete"; + return 1; + } + } else if ($var == $value) { + echo "checked"; + return 0; + } else { + echo "incomplete"; + return 1; + } + + echo ''; +} + + +function parse_mysql_dump($url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysql_query($query)) { + echo mysql_error(); + // Uncomment for debug + echo "
$query
"; + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +/** + * Parse sql to script dump, execute it + * and return if exist error. + * + * @param object $connection Connection sql. + * @param string $url Path file sql script. + * + * @return integer status + */ +function parse_mysqli_dump($connection, $url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysqli_query($connection, $query)) { + if (mysqli_error($connection)) { + return mysqli_error($connection).'
'.$query.'
'; + } + + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +/** + * Generate a random password + * + * Admits a huge mount of ASCII chars. + * + * @param integer $size Size of the password returned. + * + * @return string $output + */ +function random_name(int $size) +{ + $output = ''; + + // Range pair of ASCII position for allow A-Z, a-z, 0-9 and special chars. + $rangeSeed = [ + '48:57', + '65:90', + '97:122', + '40:47', + ]; + + // Size of the password must be over range seed count. + $size = ($size >= count($rangeSeed)) ? $size : count($rangeSeed); + + $auxIndex = 0; + for ($i = 0; $i < $size; $i++) { + $tmpSeedValues = explode(':', $rangeSeed[$auxIndex]); + $output = $output.chr(rand($tmpSeedValues[1], $tmpSeedValues[0])); + $auxIndex++; + if ($auxIndex >= 4) { + $auxIndex = 0; + } + } + + // Remix the string for strong the password. + return str_shuffle($output); +} + + +/** + * Print the header installation + * + * @param integer $step Number of step. + * + * @return string Html output. + */ +function print_logo_status($step) +{ + global $banner; + + $header = ' +
+

Pandora FMS OpenSource Installer + '.$banner.' +

+
+ 1 +
+ 2 +
+ 3 +
+ 4 +
+ 5 +
+ 6 + +
+
+ '; + + return $header; +} + + +/** + * This function adjusts path settings in pandora db for FreeBSD. + * All packages and configuration files except operating system's base files + * are installed under /usr/local in FreeBSD. So, path settings in pandora db + * for some programs should be changed from the Linux default. + * + * @param string $engine Type of engine. + * @param object $connection Connection database. + * + * @return integer Status. + */ +function adjust_paths_for_freebsd($engine, $connection=false) +{ + $adjust_sql = [ + "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');", + "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';", + "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');", + "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');", + "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');", + "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');", + "insert into tconfig (token, value) VALUES ('graphviz_bin_dir', '/usr/local/bin');", + ]; + + for ($i = 0; $i < count($adjust_sql); $i++) { + switch ($engine) { + case 'mysql': + $result = mysql_query($adjust_sql[$i]); + break; + + case 'mysqli': + $result = mysqli_query($connection, $adjust_sql[$i]); + break; + + case 'oracle': + // Delete the last semicolon from current query + $query = substr($adjust_sql[$i], 0, (strlen($adjust_sql[$i]) - 1)); + $sql = oci_parse($connection, $query); + $result = oci_execute($sql); + break; + + case 'pgsql': + pg_send_query($connection, $adjust_sql[$i]); + $result = pg_get_result($connection); + break; + } + + if (!$result) { + return 0; + } + } + + return 1; +} + + +/** + * Print all step 1 + * + * @return void + */ +function install_step1() +{ + echo " +
+
+ ".print_logo_status(1, 6)." +
+
+
+

Welcome to Pandora FMS installation Wizard

+

This wizard helps you to quick install Pandora FMS console and main database in your system. + In four steps, this installer will check all dependencies and will create your configuration, ready to use.

+

For more information, please refer to documentation →

+ "; + if (file_exists('include/config.php')) { + echo "
You already have a config.php file. + Configuration and database would be overwritten if you continued.
"; + } + + echo '
'; + echo ''; + $writable = check_writable('include', './include is writable'); + if (file_exists('include/config.php')) { + $writable += check_writable('include/config.php', 'include/config.php is writable'); + } + + echo '
'; + + echo "
This installer will overwrite and destroy + your existing Pandora FMS configuration and Database. Before continue, + please be sure that you have no valuable Pandora FMS data in your Database.
+
"; + + if ($writable !== 0) { + echo "
You need to setup permissions to be able to write in ./include directory
"; + } + + echo '
'; + + echo "
"; + echo " +
+
+
+
+
+
+
+
+
+
+
+
+
+
'; +} + + +/** + * Print license content + * + * @return void + */ +function install_step1_licence() +{ + echo " +
+
+ ".print_logo_status(2, 6)." +
+

GPL2 Licence terms agreement

+

Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, you must accept the licence terms.. +

For more information, please refer to our website at https://pandorafms.com/community/ and contact us if you have any kind of question about the usage of Pandora FMS

+

If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.

+ "; + + if (!file_exists('COPYING')) { + echo "
Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file."; + echo '
'; + } else { + echo "'; + echo '

'; + } + + echo '

'; + + echo "
+
+
'; +} + + +/** + * Print all step 2 + * + * @return void + */ +function install_step2() +{ + echo " +
+
+ ".print_logo_status(3, 6)." +
"; + echo '

Checking software dependencies

'; + echo ' +
+
+ '; + $res = 0; + $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1); + $res += check_extension('gd', 'PHP GD extension'); + $res += check_extension('ldap', 'PHP LDAP extension'); + $res += check_extension('snmp', 'PHP SNMP extension'); + $res += check_extension('session', 'PHP session extension'); + $res += check_extension('gettext', 'PHP gettext extension'); + $res += check_extension('mbstring', 'PHP Multibyte String'); + $res += check_extension('zip', 'PHP Zip'); + $res += check_extension('zlib', 'PHP Zlib extension'); + $res += check_extension('json', 'PHP json extension'); + $res += check_extension('curl', 'CURL (Client URL Library)'); + $res += check_extension('filter', 'PHP filter extension'); + $res += check_extension('calendar', 'PHP calendar extension'); + if (PHP_OS == 'FreeBSD') { + $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); + } else if (PHP_OS == 'NetBSD') { + $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); + } else if (substr(PHP_OS, 0, 3) == 'WIN') { + $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); + } else { + $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); + } + + echo ''; + check_extension('mysqli', 'PHP MySQL(mysqli) extension'); + echo '
'; + echo "DB Engines"; + echo ''; + echo '
'; + if ($res > 0) { + echo "
+
You have some incomplete + dependencies. Please correct them or this installer + will not be able to finish your installation. +
+
+ Remember, if you install any PHP module to comply + with these dependences, you need to restart + your HTTP/Apache server after it to use the new + modules. +
+
"; + } + + echo '
'; + echo "
+
+
'; +} + + +/** + * Print all step 3 + * + * @return void + */ +function install_step3() +{ + $options = []; + if (extension_loaded('mysql')) { + $options['mysql'] = 'MySQL'; + } + + if (extension_loaded('mysqli')) { + $options['mysqli'] = 'MySQL(mysqli)'; + } + + $error = false; + if (empty($options)) { + $error = true; + } + + echo " +
+
+ ".print_logo_status(4, 6)." +
+
+
+

Environment and database setup

+

+ This wizard will create your Pandora FMS database, + and populate it with all the data needed to run for the first time. +

+

+ You need a privileged user to create database schema, this is usually root user. + Information about root user will not be used or stored anymore. +

+

+ You can also deploy the scheme into an existing Database. + In this case you need a privileged Database user and password of that instance. +

+

+ Now, please, complete all details to configure your database and environment setup. +

+
+ This installer will overwrite and destroy your existing + Pandora FMS configuration and Database. Before continue, + please be sure that you have no valuable Pandora FMS data in your Database. +

+
"; + if ($error) { + echo "
+ You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. +
"; + } + + if (extension_loaded('oci8')) { + echo "
For Oracle installation an existing Database with a privileged user is needed.
"; + } + + echo '
'; + echo '
'; + if (!$error) { + echo "
"; + } + + echo ""; + + if (!$error) { + echo ' + + + + + + + "; + + // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost + echo " + + "; + + echo " + + "; + echo " + + + "; + + echo " + + "; + + echo '
'; + echo '

DB Engine

'; + + echo ''; + + echo ''; + + echo '
'; + echo '

Installation in

'; + + echo ''; + + echo ''; + } + + echo "
+

DB User with privileges

+ +
+

DB Password for this user

+ +
+

DB Hostname

+ +
+

DB Name (pandora by default)

+ +
+

Full path to HTTP publication directory

+

For example /var/www/pandora_console/

+ +
+

URL path to Pandora FMS Console

+

For example '/pandora_console'

+ +
+ +

Drop Database if exists

+
'; + + echo '
'; + + echo '
'; + echo '
'; + echo "
+ '; +} + + +/** + * Print all step 4 + * + * @return void + */ +function install_step4() +{ + $pandora_config = 'include/config.php'; + + if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) + || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) + ) { + $dbpassword = ''; + $dbuser = ''; + $dbhost = ''; + $dbname = ''; + $engine = ''; + $dbaction = ''; + $dbgrant = ''; + } else { + $engine = $_POST['engine']; + $dbpassword = $_POST['pass']; + $dbuser = $_POST['user']; + $dbhost = $_POST['host']; + $dbaction = $_POST['db_action']; + if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { + $dbgrant = $_POST['dbgrant']; + } else { + $dbgrant = $_SERVER['SERVER_ADDR']; + } + + if (isset($_POST['drop'])) { + $dbdrop = $_POST['drop']; + } else { + $dbdrop = 0; + } + + $dbname = $_POST['dbname']; + if (isset($_POST['url'])) { + $url = $_POST['url']; + } else { + $url = 'http://localhost'; + } + + if (isset($_POST['path'])) { + $path = $_POST['path']; + $path = str_replace('\\', '/', $path); + // Windows compatibility + } else { + $path = '/var/www'; + } + } + + $everything_ok = 0; + $step1 = 0; + $step2 = 0; + $step3 = 0; + $step4 = 0; + $step5 = 0; + $step6 = 0; + $step7 = 0; + $errors = []; + echo " +
+
+ ".print_logo_status(5, 6)." +
+
+
+ "; + switch ($engine) { + case 'mysql': + if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysql_query("DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysql_query("CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysql_select_db($dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysql_dump('pandoradb.sql'); + + if ($step3 !== 0 && $step3 !== 1) { + $errors[] = $step3; + $step3 = 0; + } + + check_generic($step3, 'Creating schema'); + $step4 = parse_mysql_dump('pandoradb_data.sql'); + + if ($step4 !== 0 && $step4 !== 1) { + $errors[] = $step4; + $step4 = 0; + } + + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysql_query( + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host + IDENTIFIED BY '".$random_password."'" + ); + mysql_query('FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password

Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file

"); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = ''; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + + case 'mysqli': + $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); + if (mysqli_connect_error() > 0) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysqli_select_db($connection, $dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); + if ($step3 !== 0 && $step3 !== 1) { + $errors[] = $step3; + $step3 = 0; + } + + check_generic($step3, 'Creating schema'); + + $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); + + if ($step4 !== 0 && $step4 !== 1) { + $errors[] = $step4; + $step4 = 0; + } + + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine, $connection); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysqli_query( + $connection, + "CREATE USER IF NOT EXISTS pandora@$host" + ); + + mysqli_query( + $connection, + "SET PASSWORD FOR 'pandora'@'".$host."' = '".$random_password."'" + ); + + $step5 |= mysqli_query( + $connection, + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host" + ); + mysqli_query($connection, 'FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password

Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file

"); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = ''; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + } + + echo '
'; + echo '
'; + echo '
'; + echo "

Creating database and default configuration file

"; + if ($everything_ok !== 1) { + $info = ''; + + if (!empty($errors)) { + foreach ($errors as $key => $err) { + $info .= '
'.$err.'
'; + } + + $info .= "
If you use MySQL 8 make sure to include the + following parameter in your installation's my.cnf configuration file
+ sql_mode=\"\"
"; + } + + $info .= "
There were some problems. + Installation was not completed. +

Please correct failures before trying again. + All database "; + + if ($engine == 'oracle') { + $info .= 'objects '; + } else { + $info .= 'schemes '; + } + + $info .= 'created in this step have been dropped.

+
'; + echo $info; + + switch ($engine) { + case 'mysql': + if (mysql_error() != '') { + echo "
".mysql_error().'.
'; + echo "
If you use MySQL 8 make sure to include the + following parameter in your installation's my.cnf configuration file
+ sql_mode=\"\"
"; + } + + if ($step1 == 1) { + mysql_query("DROP DATABASE $dbname"); + } + break; + + case 'mysqli': + if ($connection && mysqli_error($connection) != '') { + echo "
".mysqli_error($connection).'.
'; + echo "
If you use MySQL 8 make sure to include the + following parameter in your installation's my.cnf configuration file
+ sql_mode=\"\"
"; + } + + if ($step1 == 1) { + mysqli_query($connection, "DROP DATABASE $dbname"); + } + break; + } + } + + echo '
'; + echo '
'; + echo '
'; + echo " +
+
'; +} + + +/** + * Print all step 5 + * + * @return void + */ +function install_step5() +{ + echo " +
+
+ ".print_logo_status(6, 6)." +
+

Installation complete

+

For security, you now must manually delete this installer + ('install.php') file before trying to access to your Pandora FMS console. +

You should also install Pandora FMS Servers before trying to monitor anything; + please read documentation on how to install it.

+

Default user is 'admin' with password 'pandora', + please change it both as soon as possible.

+

Don't forget to check https://pandorafms.com + for updates. +

Select if you want to rename 'install.php'.

+
+ + +
+

+
+
+
+ +
+
"; +} From cce9ee3043b6318555a6279d57fdf6b58b3ea3fa Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 23 Aug 2023 10:38:26 +0200 Subject: [PATCH 35/97] fix typo --- tentacle/tentacle_client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tentacle/tentacle_client b/tentacle/tentacle_client index d90d21f344..be989f541f 100755 --- a/tentacle/tentacle_client +++ b/tentacle/tentacle_client @@ -2,7 +2,7 @@ ################################################################################ # # Copyright (c) 2007-2008 Ramon Novoa -# Copyright (c) 2007-2023 Pandora FMS. +# Copyright (c) 2007-2023 Pandora FMS. # # tentacle_client.pl Tentacle Client. See https://pandorafms.com/docs/ for # protocol description. From 30f4a27638dcb35b9cfe34974baebc700472482a Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 23 Aug 2023 10:39:36 +0200 Subject: [PATCH 36/97] fix typo --- tentacle/tentacle_client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tentacle/tentacle_client b/tentacle/tentacle_client index be989f541f..da917863d6 100755 --- a/tentacle/tentacle_client +++ b/tentacle/tentacle_client @@ -1095,7 +1095,7 @@ Protocol description and more info at: L<< https://pandorafms.com/manual/en/docu =head1 COPYRIGHT -Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L +Copyright (c) 2005-2023 Pandora FMS. =cut From 34bbc5f0de9fa5bd8c1b78a8c97b61aa2f5eb86f Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 23 Aug 2023 11:48:39 +0200 Subject: [PATCH 37/97] #10637 Fix recursive group --- .../include/functions_reporting_html.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 8b4473436d..4ee1cb98b3 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2618,17 +2618,34 @@ function reporting_html_group_report($table, $item, $pdf=0) ] ); + $childrens = db_get_all_rows_sql('SELECT id_grupo FROM tgrupo WHERE parent = '.$group_id); + $total_agents = db_get_all_rows_sql('SELECT COUNT(id_agente) as total FROM tagente where id_grupo = '.$group_id); + + if ($childrens !== false && (int) $total_agents[0]['total'] !== $item['data']['group_stats']['total_agents']) { + $array_group_id = []; + $array_group_id[] = $group_id; + foreach ($childrens as $group) { + $array_group_id[] = $group['id_grupo']; + } + + $group_id = $array_group_id; + $explode_group_id = implode(',', $group_id); + } else { + $explode_group_id = $group_id; + } + $group_events = db_get_all_rows_sql( 'SELECT COUNT(te.id_evento) as count_events, ta.alias FROM tevento as te - INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo = '.$group_id.' + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo IN ('.$explode_group_id.') GROUP BY te.id_agente' ); $group_os = db_get_all_rows_sql( 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo FROM tconfig_os as os - INNER JOIN tagente as ta ON ta.id_os = os.id_os WHERE ta.id_grupo = '.$group_id.' GROUP by os.name' + INNER JOIN tagente as ta ON ta.id_os = os.id_os + WHERE ta.id_grupo IN ('.$explode_group_id.') GROUP by os.name' ); } From c0933e8b15cad4a089657a1cc05311141a493448 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Wed, 23 Aug 2023 11:51:29 +0200 Subject: [PATCH 38/97] 11423-Graph analytics --- pandora_console/images/draggable.svg | 10 +++ .../include/javascript/graph_analytics.js | 43 ++++++++++- .../include/styles/graph_analytics.css | 75 +++++++++++++------ .../operation/reporting/graph_analytics.php | 68 +++++++++++++++-- 4 files changed, 164 insertions(+), 32 deletions(-) create mode 100644 pandora_console/images/draggable.svg diff --git a/pandora_console/images/draggable.svg b/pandora_console/images/draggable.svg new file mode 100644 index 0000000000..3889fef861 --- /dev/null +++ b/pandora_console/images/draggable.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/pandora_console/include/javascript/graph_analytics.js b/pandora_console/include/javascript/graph_analytics.js index 6afd0d9d38..77cdab85d7 100644 --- a/pandora_console/include/javascript/graph_analytics.js +++ b/pandora_console/include/javascript/graph_analytics.js @@ -38,9 +38,11 @@ $("div.filters-div-main > .filters-div-header > img").click(function(e) { if ($(".filters-div-main").hasClass("filters-div-main-collapsed") === true) { $(".filters-div-header > img").attr("src", "images/menu/contraer.svg"); $(".filters-div-main").removeClass("filters-div-main-collapsed"); + $("#droppable-graphs").removeClass("droppable-graphs-collapsed"); } else { $(".filters-div-header > img").attr("src", "images/menu/expandir.svg"); $(".filters-div-main").addClass("filters-div-main-collapsed"); + $("#droppable-graphs").addClass("droppable-graphs-collapsed"); } }); @@ -96,7 +98,13 @@ $("#search-left").keyup(function(e) { $("#modules-toggle").show(); data.modules.forEach(module => { modulesToggle.append( - `
${module.nombre}
` + `
+ +
+ ${module.nombre} + ${module.alias} +
+
` ); }); } else { @@ -156,7 +164,13 @@ function searchRight(freeSearch) { data.modules.forEach(module => { modulesRight.append( - `
${module.nombre}
` + `
+ +
+ ${module.nombre} + ${module.alias} +
+
` ); }); @@ -614,6 +628,29 @@ $("#button-export-modal").click(function(e) { const group = parseInt($("#export-group-id").val()); if (filter !== 0 && group !== 0) { - // todo: Ajax save in tgraph & tgraph_source. + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "html", + data: { + page: "operation/reporting/graph_analytics", + export_filter: filter, + group + }, + success: function(data) { + if (data) { + confirmDialog({ + title: titleExportConfirm, + message: data + " " + messageExportConfirm, + hideCancelButton: true, + onAccept: function() { + $( + "button.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close" + ).click(); + } + }); + } + } + }); } }); diff --git a/pandora_console/include/styles/graph_analytics.css b/pandora_console/include/styles/graph_analytics.css index a21c532ab7..2499a0620e 100644 --- a/pandora_console/include/styles/graph_analytics.css +++ b/pandora_console/include/styles/graph_analytics.css @@ -1,19 +1,3 @@ -/* .options-graph-analytics { - position: sticky; - top: 110px; - width: -webkit-fill-available; - width: -moz-available; - height: 18px; - margin: -25px -25px 25px -25px; - padding: 10px 20px; - z-index: 1; - font-weight: bold; - display: flex; - min-width: fit-content; - background-color: var(--secondary-color); - border: 1px solid #e5e9ed; -} */ - div#main { margin-bottom: 0; } @@ -21,6 +5,7 @@ div#main { div.box-flat.white_table_graph > div[id^="tgl_div_"] { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; + width: 228px; } div.box-flat.white_table_graph > div[id^="tgl_div_"] > div.white-box-content { @@ -85,7 +70,8 @@ div.margin-div { div.filters-div-main { padding: 0; margin: 0; - min-width: 400px; + width: 500px; + min-width: 500px; border-right: 1px solid var(--border-dark-color); } @@ -100,6 +86,10 @@ div.filters-div-main.filters-div-main-collapsed display: none; } +.droppable-graphs-collapsed { + margin-left: -30px; +} + div.filters-div-main > .filters-div-header { display: flex; flex-direction: row; @@ -126,7 +116,9 @@ div.filter-div { display: flex; flex-direction: column; flex-wrap: nowrap; - width: 50%; + width: 230px; + min-width: 230px; + max-width: 230px; height: 100%; padding: 10px; border-top: 1px solid var(--border-dark-color); @@ -136,7 +128,10 @@ div.filter-div { border-right: 1px solid var(--border-dark-color); } -.filters-right-div { +div.filters-right-div { + width: 230px; + min-width: 230px; + max-width: 230px; } .search-graph-analytics { @@ -184,11 +179,47 @@ div.graphs-div-main { text-overflow: ellipsis; } +.draggable-container { + display: flex; + flex-direction: row; + align-items: center; + margin-left: -10px; + padding-top: 3px; + padding-bottom: 3px; + border-bottom: 1px solid #f0f0f0; +} + +.draggable-container:last-child { + border-bottom: 0px; +} + +.draggable-module { + display: flex; + flex-direction: column; + flex-wrap: nowrap; +} + +.draggable-icon { + height: 25px; +} + +.draggable-module > span { + line-height: 10pt; +} + +.draggable-module > span.draggable-module-name { + font-weight: bold; +} + +.draggable-module > span.draggable-agent-name { + color: #8a96a6; +} + +/* Droppable */ #droppable-graphs * { cursor: default; } -/* Droppable */ .droppable { width: 100%; /* height: 20px; */ @@ -307,7 +338,7 @@ div.graph-analytics-legend-square > span.square-unit { div.graph-analytics-legend { display: flex; - flex-direction: column; + flex-direction: column-reverse; flex-wrap: nowrap; } @@ -315,7 +346,7 @@ div.graph-analytics-legend > span { line-height: 12pt; } -div.graph-analytics-legend > span:last-child { +div.graph-analytics-legend > span:first-child { font-weight: normal; font-size: 8pt; margin-left: 5px; diff --git a/pandora_console/operation/reporting/graph_analytics.php b/pandora_console/operation/reporting/graph_analytics.php index 5ce6d97bdf..b3549defe2 100644 --- a/pandora_console/operation/reporting/graph_analytics.php +++ b/pandora_console/operation/reporting/graph_analytics.php @@ -46,6 +46,7 @@ if (is_ajax()) { $load_filter = get_parameter('load_filter'); $update_filter = get_parameter('update_filter'); $get_new_values = get_parameter('get_new_values'); + $export_filter = get_parameter('export_filter'); if (empty($search_left) === false) { $output = []; @@ -101,14 +102,15 @@ if (is_ajax()) { } $id_agents = implode(',', $result_agents); - $search_sql = ' AND (nombre LIKE "%%'.$search.'%%" OR descripcion LIKE "%%'.$search.'%%")'; + $search_sql = ' AND (tam.nombre LIKE "%%'.$search.'%%" OR tam.descripcion LIKE "%%'.$search.'%%")'; $sql = sprintf( - 'SELECT id_agente_modulo, nombre, descripcion - FROM tagente_modulo - WHERE (id_agente IN (%s)) + 'SELECT tam.id_agente_modulo, tam.nombre, tam.descripcion, ta.alias + FROM tagente_modulo tam + INNER JOIN tagente ta ON ta.id_agente = tam.id_agente + WHERE (tam.id_agente IN (%s)) %s - ORDER BY nombre', + ORDER BY tam.nombre', $id_agents, $search_sql ); @@ -131,8 +133,9 @@ if (is_ajax()) { // Agent. if (empty($agent) === false) { $sql = sprintf( - 'SELECT tam.id_agente_modulo, tam.nombre, tam.descripcion + 'SELECT tam.id_agente_modulo, tam.nombre, tam.descripcion, ta.alias FROM tagente_modulo tam + INNER JOIN tagente ta ON ta.id_agente = tam.id_agente WHERE (tam.id_agente = %s) %s ORDER BY tam.nombre', @@ -146,7 +149,7 @@ if (is_ajax()) { // Group. if (empty($group) === false) { $sql = sprintf( - 'SELECT tam.id_agente_modulo, tam.nombre, tam.descripcion + 'SELECT tam.id_agente_modulo, tam.nombre, tam.descripcion, ta.alias FROM tagente_modulo tam INNER JOIN tagente ta ON ta.id_agente = tam.id_agente WHERE (ta.id_grupo = %s) @@ -309,6 +312,54 @@ if (is_ajax()) { return; } + // Export graphs. + if (empty($export_filter) === false) { + $counter = 0; + $filter = get_parameter('export_filter'); + $group = get_parameter('group'); + + $filter_name = db_get_value('filter_name', 'tgraph_analytics_filter', 'id', $filter); + $graphs = json_decode(db_get_value('graph_modules', 'tgraph_analytics_filter', 'id', $filter)); + $interval = db_get_value('tgraph_analytics_filter.interval', 'tgraph_analytics_filter', 'id', $filter); + + foreach ($graphs as $graph) { + $id_graph = db_process_sql_insert( + 'tgraph', + [ + 'id_user' => $config['id_user'], + 'id_group' => $group, + 'name' => $filter_name.' ('.__('Graph').' '.($counter + 1).')', + 'description' => __('Created from Graph analytics. Filter:').' '.$filter_name.'. '.__('Graph').' '.($counter + 1), + 'period' => $interval, + 'stacked' => 2, + ] + ); + + if ($id_graph > 0) { + $counter++; + $field_order = 1; + + foreach ($graph as $module) { + $id_graph_source = db_process_sql_insert( + 'tgraph_source', + [ + 'id_graph' => $id_graph, + 'id_server' => 0, + 'id_agent_module' => $module, + 'weight' => 1, + 'label' => '', + 'field_order' => $field_order, + ] + ); + + $field_order++; + } + } + } + + echo $counter; + } + return; } @@ -882,4 +933,7 @@ const titleLoadConfirm = ""; const messageLoadConfirm = ""; const titleExport = ""; + +const titleExportConfirm = ""; +const messageExportConfirm = ""; \ No newline at end of file From 92fae2bb5419882fb7181a3f58570b2a74ae5db4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 23 Aug 2023 13:25:06 +0200 Subject: [PATCH 39/97] #11929 fix datatable for port != 80 --- pandora_console/include/functions_ui.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index ec072735c7..3b3a56ddfb 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -4166,9 +4166,9 @@ function ui_print_datatable(array $parameters) // * START JAVASCRIPT. if (is_metaconsole() === false) { - $file_path = ui_get_full_url('include/javascript/datatablesFunction.js'); + $file_path = 'include/javascript/datatablesFunction.js'; } else { - $file_path = ui_get_full_url('../../include/javascript/datatablesFunction.js'); + $file_path = '../../include/javascript/datatablesFunction.js'; } $file_content = file_get_contents($file_path); From 120298e6a3ecdd25af0923d33059e64d048f7aba Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Wed, 23 Aug 2023 14:00:35 +0200 Subject: [PATCH 40/97] 11930-Remove in pandora_db.pl integrity & functions_agents.php --- pandora_console/include/functions_agents.php | 28 --------------- pandora_server/util/pandora_db.pl | 37 -------------------- 2 files changed, 65 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index bb5b19a27e..3009671216 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2766,13 +2766,6 @@ function agents_delete_agent($id_agents, $disableACL=false) ['id_agent' => $id_agent] ); - // Delete agent from visual dashboards. - db_process_sql( - 'UPDATE twidget_dashboard - SET options = NULL - WHERE options LIKE ("%\"agentid\":\"'.$id_agent.'\"%")' - ); - // Delete agent from treport. db_process_sql_delete( 'treport_content', @@ -2796,33 +2789,12 @@ function agents_delete_agent($id_agents, $disableACL=false) ] ); - // Delete from gis maps history - db_process_sql_delete( - 'tgis_data_history', - ['tagente_id_agente' => $id_agent] - ); - // Delete from policies. db_process_sql_delete( 'tpolicy_agents', ['id_agent' => $id_agent] ); - // Delete from tnetwork maps - db_process_sql_delete( - 'titem', - ['source_data' => $id_agent] - ); - - db_process_sql_delete( - 'trel_item', - [ - 'id_parent_source_data' => $id_agent, - 'id_child_source_data' => $id_agent, - ], - 'OR' - ); - // Delete agent from fav menu. db_process_sql_delete( 'tfavmenu_user', diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index d6ef5c4334..ce476d7154 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -772,47 +772,10 @@ sub pandora_checkdb_integrity { db_do ($dbh, 'DELETE FROM tlayout_data WHERE id_agent <> 0 AND id_agent NOT IN (SELECT id_agente FROM tagente)'); db_do ($dbh, 'DELETE FROM tlayout_data WHERE id_agente_modulo <> 0 AND id_agente_modulo NOT IN (SELECT id_agente_modulo FROM tagente_modulo)'); - # Delete orphan data form deleted agents. - # Clearl orphan data from dashboards - log_message ('INTEGRITY', "Deleting orphan dahsboard items."); - my @agents_ids = get_db_rows($dbh, 'SELECT id_agente FROM tagente'); - my $where_condition; - foreach my $agent_id (@agents_ids) { - $where_condition .= 'options NOT LIKE ("%\\"agentid\\":\\"'.$agent_id->{'id_agente'}.'\\"%")'; - if($agent_id == $agents_ids[-1]) { - last; - } - $where_condition .= ' AND '; - } - - db_do ($dbh, 'UPDATE twidget_dashboard set options = NULL WHERE '.$where_condition); - - $where_condition = ''; - my @modules = get_db_rows($dbh, 'SELECT id_agente_modulo FROM tagente_modulo'); - foreach my $id_agente_modulo (@modules) { - $where_condition .= 'options NOT LIKE ("%\\"moduleId\\":\\"'.$id_agente_modulo->{'id_agente_modulo'}.'\\"%")'; - if($id_agente_modulo == $modules[-1]) { - last; - } - $where_condition .= ' AND '; - } - - db_do ($dbh, 'UPDATE twidget_dashboard set options = NULL WHERE '.$where_condition); - # Delete orphan data from favorite agents log_message ('INTEGRITY', "Deleting orphan favories items."); db_do ($dbh, 'DELETE FROM tfavmenu_user WHERE section = "Agents" AND id_element NOT IN (SELECT id_agente FROM tagente)'); - # Delete orphan data from gis maps - log_message ('INTEGRITY', "Deleting orphan GIS data."); - db_do ($dbh, 'DELETE FROM tgis_data_history WHERE tagente_id_agente NOT IN (SELECT id_agente FROM tagente)'); - - # Delete orphan tnetwork maps data - log_message ('INTEGRITY', "Deleting orphan networkmaps data."); - db_do ($dbh, 'DELETE FROM titem WHERE source_data NOT IN (SELECT id_agente FROM tagente)'); - db_do ($dbh, 'DELETE FROM trel_item WHERE id_parent_source_data NOT IN (SELECT id_agente FROM tagente) OR id_child_source_data NOT IN (SELECT id_agente FROM tagente)'); - - # Check enterprise tables enterprise_hook ('pandora_checkdb_integrity_enterprise', [$conf, $dbh]); } From 45c15acf8e39ec1afbee99d5ec775f48337cad3e Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Wed, 23 Aug 2023 14:46:55 +0200 Subject: [PATCH 41/97] 11930-Remove in pandora_db.pl integrity & functions_agents.php --- pandora_console/include/functions_agents.php | 45 -------------------- pandora_server/util/pandora_db.pl | 9 ---- 2 files changed, 54 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 3009671216..a199fa2b6b 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2760,51 +2760,6 @@ function agents_delete_agent($id_agents, $disableACL=false) enterprise_include_once('include/functions_agents.php'); enterprise_hook('agent_delete_from_cache', [$id_agent]); - // Delete agent from visual console. - db_process_sql_delete( - 'tlayout_data', - ['id_agent' => $id_agent] - ); - - // Delete agent from treport. - db_process_sql_delete( - 'treport_content', - ['id_agent' => $id_agent] - ); - - // Delete rules from tevent alerts (correlative alerts) - db_process_sql_delete( - 'tevent_rule', - [ - 'agent' => $id_agent, - 'operator_agent' => '==', - ] - ); - - db_process_sql_delete( - 'tevent_rule', - [ - 'log_agent' => $id_agent, - 'operator_log_agent' => '==', - ] - ); - - // Delete from policies. - db_process_sql_delete( - 'tpolicy_agents', - ['id_agent' => $id_agent] - ); - - // Delete agent from fav menu. - db_process_sql_delete( - 'tfavmenu_user', - [ - 'id_element' => $id_agent, - 'section' => 'Agents', - 'id_user' => $config['id_user'], - ] - ); - // Break the loop on error. if ((bool) $error === true) { break; diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index ce476d7154..5567ab5227 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -767,15 +767,6 @@ sub pandora_checkdb_integrity { # Delete orphan data_inc reference records db_do ($dbh, 'DELETE FROM tagente_datos_inc WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM tagente_modulo)'); - # Delete orphan data from visual console. - log_message ('INTEGRITY', "Deleting orphan visual console items."); - db_do ($dbh, 'DELETE FROM tlayout_data WHERE id_agent <> 0 AND id_agent NOT IN (SELECT id_agente FROM tagente)'); - db_do ($dbh, 'DELETE FROM tlayout_data WHERE id_agente_modulo <> 0 AND id_agente_modulo NOT IN (SELECT id_agente_modulo FROM tagente_modulo)'); - - # Delete orphan data from favorite agents - log_message ('INTEGRITY', "Deleting orphan favories items."); - db_do ($dbh, 'DELETE FROM tfavmenu_user WHERE section = "Agents" AND id_element NOT IN (SELECT id_agente FROM tagente)'); - # Check enterprise tables enterprise_hook ('pandora_checkdb_integrity_enterprise', [$conf, $dbh]); } From 4830cf21e67a948843cc5c5af748d950669599ea Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 23 Aug 2023 15:49:36 +0200 Subject: [PATCH 42/97] Updated version and build strings. --- pandora_agents/pc/AIX/pandora_agent.conf | 2 +- pandora_agents/pc/FreeBSD/pandora_agent.conf | 2 +- pandora_agents/pc/HP-UX/pandora_agent.conf | 2 +- pandora_agents/pc/Linux/pandora_agent.conf | 2 +- pandora_agents/pc/NT4/pandora_agent.conf | 2 +- pandora_agents/pc/SunOS/pandora_agent.conf | 2 +- pandora_agents/pc/Win32/pandora_agent.conf | 2 +- pandora_agents/shellscript/aix/pandora_agent.conf | 2 +- pandora_agents/shellscript/bsd-ipso/pandora_agent.conf | 2 +- pandora_agents/shellscript/hp-ux/pandora_agent.conf | 2 +- pandora_agents/shellscript/linux/pandora_agent.conf | 2 +- pandora_agents/shellscript/mac_osx/pandora_agent.conf | 2 +- pandora_agents/shellscript/openWRT/pandora_agent.conf | 2 +- pandora_agents/shellscript/solaris/pandora_agent.conf | 2 +- pandora_agents/unix/AIX/pandora_agent.conf | 2 +- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh | 2 +- pandora_agents/unix/Darwin/dmg/extras/distribution.xml | 4 ++-- .../PandoraFMS agent uninstaller.app/Contents/Info.plist | 6 +++--- pandora_agents/unix/Darwin/pandora_agent.conf | 2 +- pandora_agents/unix/FreeBSD/pandora_agent.conf | 2 +- pandora_agents/unix/HP-UX/pandora_agent.conf | 2 +- pandora_agents/unix/Linux/pandora_agent.conf | 2 +- pandora_agents/unix/NT4/pandora_agent.conf | 2 +- pandora_agents/unix/NetBSD/pandora_agent.conf | 2 +- pandora_agents/unix/SunOS/pandora_agent.conf | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 4 ++-- pandora_agents/unix/pandora_agent.spec | 4 ++-- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/bin/pandora_agent.conf | 2 +- pandora_agents/win32/installer/pandora.mpi | 4 ++-- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 4 ++-- pandora_console/pandora_console.rhel7.spec | 4 ++-- pandora_console/pandora_console.spec | 4 ++-- pandora_console/pandora_console_install | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/conf/pandora_server.conf.new | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.spec | 4 ++-- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 52 files changed, 62 insertions(+), 62 deletions(-) diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index bf46603c0f..3a2a1bfbf0 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1, AIX version +# Version 7.0NG.773.2, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 77a602713c..ec35083cd3 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1, FreeBSD Version +# Version 7.0NG.773.2, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 1b54a696d3..2e88f0f376 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1, HP-UX Version +# Version 7.0NG.773.2, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 6fc3a3e48e..2a5b0d24b4 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1, GNU/Linux +# Version 7.0NG.773.2, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index c68ae6f7ea..07bb852d55 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1, GNU/Linux +# Version 7.0NG.773.2, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 60ecdf748a..bfdf81ba25 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1, Solaris Version +# Version 7.0NG.773.2, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 49f55782b6..bb90bbc54c 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.773.1 +# Version 7.0NG.773.2 # 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 diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index a3ec6a1081..cfd3ad7755 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.773.1, AIX version +# Version 7.0NG.773.2, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 49a1e220aa..28f89ae7af 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.773.1 +# Version 7.0NG.773.2 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 3a75628bd3..9576e28cbe 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.773.1, HPUX Version +# Version 7.0NG.773.2, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index ed1af5662f..911eedebc7 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1 +# Version 7.0NG.773.2 # Licensed under GPL license v2, # (c) 2003-2023 Pandora FMS # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 89fdf1325d..9b265e9adf 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1 +# Version 7.0NG.773.2 # Licensed under GPL license v2, # (c) 2003-2023 Pandora FMS # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 14b40b0b0b..1d9ea69ef5 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1 +# Version 7.0NG.773.2 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index d9e8f7f5a8..99069653a2 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.773.1, Solaris version +# Version 7.0NG.773.2, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index ece393dd79..8af939a5e4 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.1, AIX version +# Version 7.0NG.773.2, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 27b6eccfe0..6ecda6849e 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.773.1-230823 +Version: 7.0NG.773.2 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 4afa5d54b1..24dbd7bd2c 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.773.1-230823" +pandora_version="7.0NG.773.2" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh index cac873c9ea..a498498938 100644 --- a/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh +++ b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh @@ -31,7 +31,7 @@ fi if [ "$#" -ge 2 ]; then VERSION="$2" else - VERSION="7.0NG.773.1" + VERSION="7.0NG.773.2" fi # Path for the generated DMG file diff --git a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml index 0b11dd8905..0ca54a29e6 100644 --- a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml +++ b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml @@ -19,11 +19,11 @@ - pandorafms_src.pdk + pandorafms_src.pdk - pandorafms_uninstall.pdk + pandorafms_uninstall.pdk