From 230a8d804a09379037186883a83511485c159f42 Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 16 Mar 2023 10:16:14 +0100 Subject: [PATCH 01/55] added powershell dchp plugin --- pandora_plugins/Dhcp/pandora_dhcp.ps1 | 85 +++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 pandora_plugins/Dhcp/pandora_dhcp.ps1 diff --git a/pandora_plugins/Dhcp/pandora_dhcp.ps1 b/pandora_plugins/Dhcp/pandora_dhcp.ps1 new file mode 100644 index 0000000000..0b50e00e5f --- /dev/null +++ b/pandora_plugins/Dhcp/pandora_dhcp.ps1 @@ -0,0 +1,85 @@ +#Plugin for monitoring Microsoft Exchange Server. +# +# Pandora FMS Agent Plugin for dchp. +# +#(c) Alejandro Sánchez +# v1.2, 26 enero 2023 +# ------------------------------------------------------------------------ + + +function print_module { + + param ([string]$module_name,[string]$module_type,[string]$module_value,[string]$module_desc) + + echo "" + echo "$module_name" + echo "$module_type" + echo "" + echo "" + echo "" + +} + +#$LinuxCurrentIP=$() 2> $NULL +$WindowsCurrentIP=$((Get-NetIPConfiguration | Where-Object { $_.IPv4DefaultGateway -ne $null -and $_.NetAdapter.Status -ne "Disconnected" }).IPv4Address.IPAddress) 2> $NULL +$Scopes=$(get-dhcpserverv4scope | ConvertTo-Csv -NoTypeInformation) 2> $NULL +$Scopes=$(get-dhcpserverv4scope | Select ScopeId |ConvertTo-Csv -NoTypeInformation) 2> $NULL +$ScopeIds=$(((get-dhcpserverv4scope).ScopeId).IPAddressToString) 2> $NULL + +$avalaible_ips=0 +$count_reservation=0 +$count_leases=0 +ForEach($scope_ids in $Scopes) +{ +if($scope_ids -notmatch 'ScopeId') +{ +$scope_ids = $scope_ids -replace '"', "" +$scope_ids =[IPAddress]$scope_ids +$ScopeRange=$(get-dhcpserverv4scope -ScopeId $scope_ids | ConvertTo-Csv -NoTypeInformation) +$ScopeMask=$(((get-dhcpserverv4scope -ScopeId $scope_ids).SubnetMask).IPAddressToString) 2> $NULL +$PercentageInUse=$((get-dhcpserverv4scopestatistics -ScopeId $scope_ids).PercentageInUse) 2> $NULL +# $Free=$((get-dhcpserverv4scopestatistics -ScopeId $scope_ids).Free) 2> $NULL +# $InUse=$((get-dhcpserverv4scopestatistics -ScopeId $scope_ids).InUse) 2> $NULL +# $Reserved=$((get-dhcpserverv4scopestatistics -ScopeId $scope_ids).Reserved) 2> $NULL +# $Pending=$((get-dhcpserverv4scopestatistics -ScopeId $scope_ids).Pending) 2> $NULL +#$AddressAssignedList=$(Get-DhcpServerv4Lease -ScopeId $scope_ids | ConvertTo-Csv -NoTypeInformation) 2> $NULL +$AddressAssignedList=$((Get-DhcpServerv4Lease -ScopeId $scope_ids).AddressState) 2> $NULL +#$Reservations=$(Get-DhcpServerv4Reservation -ScopeId $scope_ids | ConvertTo-Csv -NoTypeInformation) 2> $NULL +$Reservations=$((Get-DhcpServerv4Reservation -ScopeId $scope_ids).AddressState) 2> $NULL +$ExclusionRanges=$(Get-DhcpServerv4ExclusionRange -ScopeId $scope_ids | ConvertTo-Csv -NoTypeInformation) 2> $NULL +$Start_range=((Get-DhcpServerv4ExclusionRange -ScopeId $scope_ids).StartRange.IPAddressToString) 2> $NULL +$End_range=((Get-DhcpServerv4ExclusionRange -ScopeId $scope_ids).EndRange.IPAddressToString) 2> $NULL + + +## reservation +ForEach($reservation in $Reservations){ +if ($Reservations -match "InactiveReservation"){$count_reservation=$count_reservation+0}else {if ($Reservations){$count_reservation=$count_reservation+1}else {$count_reservation=$count_reservation+0} } +} +## leases +ForEach($lease in $AddressAssignedList){ +if ($AddressAssignedList -match "InactiveReservation"){$count_leases=$count_leases+0}else {if ($Reservations){$count_reservation=$count_reservation+1}else {$count_reservation=$count_reservation+0} } +} + +$count_assigned=$count_reservation+$count_leases + +# last octet value of an IP address +$exc_start=$Start_range.Split('.')[-1] +$exc_end=$End_range.Split('.')[-1] + +# avalaible end range - start range +1 +$avalaible=[int]$exc_end - [int]$exc_start +1 + +$free= $avalaible - $count_reservation + +print_module "[$scope_ids] - dhcp usage" "generic_data" "$PercentageInUse" "Used percentage" +print_module "[$scope_ids] - dhcp reserved ips" "generic_data" "$count_reservation" "reservations" +print_module "[$scope_ids] - dhcp assigned ips" "generic_data" "$count_assigned" "assigned ips" +print_module "[$scope_ids] - dhcp avalaible ips" "generic_data" "$avalaible" "Available and reserved ips" +print_module "[$scope_ids] - dhcp free ips" "generic_data" "$free" "Available ips (not reserved)" + +#reset +$count_reservation=0 +$count_leases=0 +} +} + From 48d7eb2514ca6b772d337bb0d06a482a4f4c55bd Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 20 Apr 2023 11:15:34 +0200 Subject: [PATCH 02/55] #10733 align text widget hotizontally --- .../include/lib/Dashboard/Widgets/AvgSumMaxMinModule.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/AvgSumMaxMinModule.php b/pandora_console/include/lib/Dashboard/Widgets/AvgSumMaxMinModule.php index 033761afdf..9d65fe1b40 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/AvgSumMaxMinModule.php +++ b/pandora_console/include/lib/Dashboard/Widgets/AvgSumMaxMinModule.php @@ -643,17 +643,19 @@ class AvgSumMaxMinModule extends Widget $output .= '
'; $orientation = ''; + $extraClass = ''; if ((int) $this->values['horizontal'] === 1) { $orientation = 'flex aligni_center'; } else { $orientation = 'grid'; + $extraClass = 'mrgn_btn_20px'; } // General div. $output .= '
'; // Div value. - $output .= '
'; + $output .= '
'; if (is_numeric($data) === true) { $dataDatos = remove_right_zeros( From c70082e12d1c81f80235795384a2cc1730e7b52e Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 21 Apr 2023 09:40:14 +0200 Subject: [PATCH 03/55] Fix limit in SQL query --- .../include/class/AuditLog.class.php | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/class/AuditLog.class.php b/pandora_console/include/class/AuditLog.class.php index c16628dd69..e0d1ce2620 100644 --- a/pandora_console/include/class/AuditLog.class.php +++ b/pandora_console/include/class/AuditLog.class.php @@ -318,17 +318,29 @@ class AuditLog extends HTML $count = (int) db_get_value_sql(sprintf('SELECT COUNT(*) as "total" FROM tsesion WHERE %s', $filter)); - $sql = sprintf( - 'SELECT * - FROM tsesion - WHERE %s - ORDER BY %s - LIMIT %d, %d', - $filter, - $order, - $start, - $length - ); + if ($length !== '-1') { + $sql = sprintf( + 'SELECT * + FROM tsesion + WHERE %s + ORDER BY %s + LIMIT %d, %d', + $filter, + $order, + $start, + $length + ); + } else { + $sql = sprintf( + 'SELECT * + FROM tsesion + WHERE %s + ORDER BY %s', + $filter, + $order + ); + } + $data = db_get_all_rows_sql($sql); if (empty($data) === false) { From 0c2de27774b37280a7f1ecb431f105c39b59d3cc Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 21 Apr 2023 11:40:27 +0200 Subject: [PATCH 04/55] #10984 title visual console --- .../operation/visual_console/view.php | 82 ++++++++++--------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index 80254800b5..01f4a2092f 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -60,8 +60,10 @@ function visual_map_print_button_editor_refactor( $disabled, '', [ - 'class' => $class, - 'mode' => 'onlyIcon', + 'class' => $class, + 'mode' => 'onlyIcon', + 'data-title' => $label, + 'data-use_title_for_force_title' => '1', ], false, true @@ -270,45 +272,45 @@ if ($pure === false) { echo '
'; echo '