From 7d73e5abfc5c00977ec6deb01e3f91152011e1a5 Mon Sep 17 00:00:00 2001 From: bernhard Date: Thu, 10 Jun 2021 14:02:53 +0200 Subject: [PATCH 1/2] Issue #997: remove checks for 'darwin' --- Kernel/System/Environment.pm | 8 -------- .../Plugin/OS/DiskPartitionOTOBO.pm | 6 ++---- .../Plugin/OS/DiskSpace.pm | 8 +++----- .../Plugin/OS/DiskSpacePartitions.pm | 10 ++++------ .../Plugin/OS/KernelVersion.pm | 6 ++---- .../SupportDataCollector/Plugin/OS/Load.pm | 20 +++---------------- .../SupportDataCollector/Plugin/OS/Swap.pm | 6 ++---- 7 files changed, 16 insertions(+), 48 deletions(-) diff --git a/Kernel/System/Environment.pm b/Kernel/System/Environment.pm index 3182844341..77c8bdf57f 100644 --- a/Kernel/System/Environment.pm +++ b/Kernel/System/Environment.pm @@ -95,7 +95,6 @@ sub OSInfoGet { linux => 'Linux', freebsd => 'FreeBSD', openbsd => 'OpenBSD', - darwin => 'MacOSX', ); # If used OS is a linux system @@ -130,13 +129,6 @@ sub OSInfoGet { } } } - elsif ( $^O eq 'darwin' ) { - - my $MacVersion = `sw_vers -productVersion` || ''; - chomp $MacVersion; - - $OSName = 'MacOSX ' . $MacVersion; - } elsif ( $^O eq 'freebsd' || $^O eq 'openbsd' ) { my $BSDVersion = `uname -r` || ''; diff --git a/Kernel/System/SupportDataCollector/Plugin/OS/DiskPartitionOTOBO.pm b/Kernel/System/SupportDataCollector/Plugin/OS/DiskPartitionOTOBO.pm index f847920a65..d38a3b2432 100644 --- a/Kernel/System/SupportDataCollector/Plugin/OS/DiskPartitionOTOBO.pm +++ b/Kernel/System/SupportDataCollector/Plugin/OS/DiskPartitionOTOBO.pm @@ -34,10 +34,8 @@ sub GetDisplayPath { sub Run { my $Self = shift; - # Check if used OS is a linux system - if ( $^O !~ /(linux|unix|netbsd|freebsd|darwin)/i ) { - return $Self->GetResults(); - } + # Check if used OS is a supported system. See https://perldoc.perl.org/perlport#PLATFORMS. + return $Self->GetResults() unless $^O =~ m/(linux|unix|netbsd|freebsd)/i; # find OTOBO partition my $Home = $Kernel::OM->Get('Kernel::Config')->Get('Home'); diff --git a/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm b/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm index 68d82487ac..7d58305531 100644 --- a/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm +++ b/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm @@ -39,11 +39,9 @@ sub Run { # TODO: fix return $Self->GetResults(); - # # Check if used OS is a linux system - # if ( $^O !~ /(linux|unix|netbsd|freebsd|darwin)/i ) { - # return $Self->GetResults(); - # } - # + ## Check if used OS is a supported system. See https://perldoc.perl.org/perlport#PLATFORMS. + #return $Self->GetResults() unless $^O =~ m/(linux|unix|netbsd|freebsd)/i; + # # find OTOBO partition # my $Home = $Kernel::OM->Get('Kernel::Config')->Get('Home'); # diff --git a/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpacePartitions.pm b/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpacePartitions.pm index 9085ee1491..b4472da3bf 100644 --- a/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpacePartitions.pm +++ b/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpacePartitions.pm @@ -32,15 +32,13 @@ sub GetDisplayPath { sub Run { my $Self = shift; - # Check if used OS is a Linux system - if ( $^O !~ /(linux|unix|netbsd|freebsd|darwin)/i ) { - return $Self->GetResults(); - } + # Check if used OS is a supported system. See https://perldoc.perl.org/perlport#PLATFORMS. + return $Self->GetResults() unless $^O =~ m/(linux|unix|netbsd|freebsd)/i; my $Commandline = "df -lHx tmpfs -x iso9660 -x udf -x squashfs"; - # current MacOS and FreeBSD does not support the -x flag for df - if ( $^O =~ /(darwin|freebsd)/i ) { + # currently FreeBSD does not support the -x flag for df + if ( $^O =~ /(freebsd)/i ) { $Commandline = "df -lH"; } diff --git a/Kernel/System/SupportDataCollector/Plugin/OS/KernelVersion.pm b/Kernel/System/SupportDataCollector/Plugin/OS/KernelVersion.pm index d332a94d5f..5ca00bb69a 100644 --- a/Kernel/System/SupportDataCollector/Plugin/OS/KernelVersion.pm +++ b/Kernel/System/SupportDataCollector/Plugin/OS/KernelVersion.pm @@ -32,10 +32,8 @@ sub GetDisplayPath { sub Run { my $Self = shift; - # Check if used OS is a linux system - if ( $^O !~ /(linux|unix|netbsd|freebsd|darwin)/i ) { - return $Self->GetResults(); - } + # Check if used OS is a supported system. See https://perldoc.perl.org/perlport#PLATFORMS. + return $Self->GetResults() unless $^O =~ m/(linux|unix|netbsd|freebsd)/i; my $KernelVersion = ""; my $KernelInfo; diff --git a/Kernel/System/SupportDataCollector/Plugin/OS/Load.pm b/Kernel/System/SupportDataCollector/Plugin/OS/Load.pm index cea2506d5d..2248928e91 100644 --- a/Kernel/System/SupportDataCollector/Plugin/OS/Load.pm +++ b/Kernel/System/SupportDataCollector/Plugin/OS/Load.pm @@ -32,15 +32,13 @@ sub GetDisplayPath { sub Run { my $Self = shift; - # Check if used OS is a linux system - if ( $^O !~ /(linux|unix|netbsd|freebsd|darwin)/i ) { - return $Self->GetResults(); - } + # Check if used OS is a supported system. See https://perldoc.perl.org/perlport#PLATFORMS. + return $Self->GetResults() unless $^O =~ m/(linux|unix|netbsd|freebsd)/i; my @Loads; # If used OS is a linux system - if ( $^O =~ /(linux|unix|netbsd|freebsd|darwin)/i ) { + if ( $^O =~ /(linux|unix|netbsd|freebsd)/i ) { # linux systems if ( -e '/proc/loadavg' ) { @@ -50,18 +48,6 @@ sub Run { } } - # mac os - elsif ( $^O =~ /darwin/i ) { - if ( open( my $In, '-|', "sysctl vm.loadavg" ) ) { ## no critic qw(OTOBO::ProhibitOpen InputOutput::RequireBriefOpen) - while (<$In>) { - if ( my ($Loads) = $_ =~ /vm\.loadavg: \s* \{ \s* (.*) \s* \}/smx ) { - @Loads = split ' ', $Loads; - } - } - close $In; - } - } - if (@Loads) { $Self->AddResultInformation( Label => Translatable('System Load'), diff --git a/Kernel/System/SupportDataCollector/Plugin/OS/Swap.pm b/Kernel/System/SupportDataCollector/Plugin/OS/Swap.pm index cb161778b2..d5766496f8 100644 --- a/Kernel/System/SupportDataCollector/Plugin/OS/Swap.pm +++ b/Kernel/System/SupportDataCollector/Plugin/OS/Swap.pm @@ -32,10 +32,8 @@ sub GetDisplayPath { sub Run { my $Self = shift; - # Check if used OS is a linux system - if ( $^O !~ /(linux|unix|netbsd|freebsd|darwin)/i ) { - return $Self->GetResults(); - } + # Check if used OS is a supported system. See https://perldoc.perl.org/perlport#PLATFORMS. + return $Self->GetResults() unless $^O =~ m/(linux|unix|netbsd|freebsd)/i; my $MemInfoFile; my ( $MemTotal, $MemFree, $SwapTotal, $SwapFree ); From 3d9722e38e65049d97b43f6cb40f68e4084f3b8c Mon Sep 17 00:00:00 2001 From: bernhard Date: Thu, 10 Jun 2021 14:03:43 +0200 Subject: [PATCH 2/2] Issue #997: specify the relevant issue in a TODO comment --- Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm b/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm index 7d58305531..f4d441de77 100644 --- a/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm +++ b/Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm @@ -36,7 +36,7 @@ sub Run { # This plugin is temporary disabled # A new logic is required to calculate the space - # TODO: fix + # TODO: see https://github.com/RotherOSS/otobo/issues/1076 return $Self->GetResults(); ## Check if used OS is a supported system. See https://perldoc.perl.org/perlport#PLATFORMS.