private function parseDf($dfOutput, $appDir, array $mountPaths)
    {
        $results = [];
        foreach (explode("\n", $dfOutput) as $i => $line) {
            if ($i === 0) {
                continue;
            }
            try {
                $path = $this->getDfColumn($line, 'path');
            } catch (\RuntimeException $e) {
                $this->debug($e->getMessage());
                continue;
            }
            if (strpos($path, $appDir . '/') !== 0) {
                continue;
            }
            $mountPath = ltrim(substr($path, strlen($appDir)), '/');
            if (!in_array($mountPath, $mountPaths)) {
                continue;
            }
            $filesystem = $this->getDfColumn($line, 'filesystem');
            if (isset($results[$filesystem])) {
                $results[$filesystem]['mounts'][] = $mountPath;
                continue;
            }
            $results[$filesystem] = [
                'total' => $this->getDfColumn($line, 'total'),
                'used' => $this->getDfColumn($line, 'used'),
                'available' => $this->getDfColumn($line, 'available'),
                'mounts' => [$mountPath],
            ];
            $results[$filesystem]['percent_used'] = $results[$filesystem]['used'] / $results[$filesystem]['total'] * 100;
        }

        return $results;
    }
private function parseDf($dfOutput, $appDir, array $mountPaths)
    {
        $results = [];
        foreach (explode("\n", $dfOutput) as $i => $line) {
            if ($i === 0) {
                continue;
            }
            try {
                $path = $this->getDfColumn($line, 'path');
            } catch (\RuntimeException $e) {
                $this->debug($e->getMessage());
                continue;
            }
            if (strpos($path, $appDir . '/') !== 0) {
                continue;
            }
            $mountPath = ltrim(substr($path, strlen($appDir)), '/');
            if (!in_array($mountPath, $mountPaths)) {
                continue;
            }
            $filesystem = $this->getDfColumn($line, 'filesystem');
            if (isset($results[$filesystem])) {
                $results[$filesystem]['mounts'][] = $mountPath;
                continue;
            }
            $results[$filesystem] = [
                'total' => $this->getDfColumn($line, 'total'),
                'used' => $this->getDfColumn($line, 'used'),
                'available' => $this->getDfColumn($line, 'available'),
                'mounts' => [$mountPath],
            ];
            $results[$filesystem]['percent_used'] = $results[$filesystem]['used'] / $results[$filesystem]['total'] * 100;
        }

        return $results;
    }
private function parseDf ( $ dfOutput , $ appDir , array $ mountPaths ) { $ results = [ ] ; foreach ( explode ( "\n" , $ dfOutput ) as $ i => $ line ) { if ( $ i === 0 ) { continue ; } try { $ path = $ this -> getDfColumn ( $ line , 'path' ) ; } catch ( \ RuntimeException $ e ) { $ this -> debug ( $ e -> getMessage ( ) ) ; continue ; } if ( strpos ( $ path , $ appDir . '/' ) !== 0 ) { continue ; } $ mountPath = ltrim ( substr ( $ path , strlen ( $ appDir ) ) , '/' ) ; if ( ! in_array ( $ mountPath , $ mountPaths ) ) { continue ; } $ filesystem = $ this -> getDfColumn ( $ line , 'filesystem' ) ; if ( isset ( $ results [ $ filesystem ] ) ) { $ results [ $ filesystem ] [ 'mounts' ] [ ] = $ mountPath ; continue ; } $ results [ $ filesystem ] = [ 'total' => $ this -> getDfColumn ( $ line , 'total' ) , 'used' => $ this -> getDfColumn ( $ line , 'used' ) , 'available' => $ this -> getDfColumn ( $ line , 'available' ) , 'mounts' => [ $ mountPath ] , ] ; $ results [ $ filesystem ] [ 'percent_used' ] = $ results [ $ filesystem ] [ 'used' ] / $ results [ $ filesystem ] [ 'total' ] * 100 ; } return $ results ; }
Parse the output of 'df', building a list of results per FS volume.

@param string $dfOutput
@param string $appDir
@param array  $mountPaths

@return array
Parse the output of df building a list of results per FS volume .