<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># --
# Kernel/System/SupportDataCollector/Plugin/OS/DiskSpace.pm - system data collector plugin
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::System::SupportDataCollector::Plugin::OS::DiskSpace;

use strict;
use warnings;

use base qw(Kernel::System::SupportDataCollector::PluginBase);

sub GetDisplayPath {
    return 'Operating System';
}

sub Run {
    my $Self = shift;

    # This plugin is temporary disabled
    # A new logic is required to calculate the space
    return $Self-&gt;GetResults();

    # Check if used OS is a linux system
    if ( $^O !~ /(linux|unix|netbsd|freebsd|darwin)/i ) {
        return $Self-&gt;GetResults();
    }

    # find OTRS partition
    my $Home = $Self-&gt;{ConfigObject}-&gt;Get('Home');

    my $OTRSPartition = `df -P $Home | tail -1 | cut -d' ' -f 1`;
    chomp $OTRSPartition;

    my $Commandline = "df -lx tmpfs -x iso9660 -x udf -x squashfs";

    # current MacOS and FreeBSD does not support the -x flag for df
    if ( $^O =~ /(darwin|freebsd)/i ) {
        $Commandline = "df -l";
    }

    my $In;
    if ( open( $In, "-|", "$Commandline" ) ) {

        my ( @ProblemPartitions, $StatusProblem );

        # TODO change from percent to megabytes used.
        while (&lt;$In&gt;) {
            if ( $_ =~ /^$OTRSPartition\s.*/ &amp;&amp; $_ =~ /^(.+?)\s.*\s(\d+)%.+?$/ ) {
                my ( $Partition, $UsedPercent ) = $_ =~ /^(.+?)\s.*?\s(\d+)%.+?$/;
                if ( $UsedPercent &gt; 90 ) {
                    push @ProblemPartitions, "$Partition \[$UsedPercent%\]";
                    $StatusProblem = 1;
                }
                elsif ( $UsedPercent &gt; 80 ) {
                    push @ProblemPartitions, "$Partition \[$UsedPercent%\]";
                }
            }
        }
        close($In);
        if (@ProblemPartitions) {
            if ($StatusProblem) {
                $Self-&gt;AddResultProblem(
                    Label   =&gt; 'Disk Usage',
                    Value   =&gt; join( ', ', @ProblemPartitions ),
                    Message =&gt; 'The partition where OTRS is located is almost full.',
                );
            }
            else {
                $Self-&gt;AddResultWarning(
                    Label   =&gt; 'Disk Usage',
                    Value   =&gt; join( ', ', @ProblemPartitions ),
                    Message =&gt; 'The partition where OTRS is located is almost full.',
                );
            }
        }
        else {
            $Self-&gt;AddResultOk(
                Label   =&gt; 'Disk Usage',
                Value   =&gt; '',
                Message =&gt; 'The partition where OTRS is located has no disk space problems.',
            );
        }
    }

    return $Self-&gt;GetResults();
}

=back

=head1 TERMS AND CONDITIONS

This software is part of the OTRS project (L&lt;http://otrs.org/&gt;).

This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see L&lt;http://www.gnu.org/licenses/agpl.txt&gt;.

=cut

1;
</pre></body></html>