PHP code example of ahaaje / linux-system-information

1. Go to this page and download the library: Download ahaaje/linux-system-information library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ahaaje / linux-system-information example snippets



Ahaaje\LinuxSystemInformation\System;

try {
    $system = new System();

    echo 'Host:' . $system, PHP_EOL;
    echo 'Load average last 5 minutes: ' . $system->getLoadAverage(5), PHP_EOL;
    echo 'Total memory: ' . $system->getMemoryCategory('total'), PHP_EOL;
    echo 'Used memory: ' . $system->getMemoryCategory('used'), PHP_EOL;
    echo 'Available memory: ' . $system->getMemoryCategory('available'), PHP_EOL;
} catch (\RuntimeException $e) {
    // Some stat could not be accessed
    echo get_class($e) . ' : ' . $e->getMessage(), PHP_EOL;
} catch (\Exception $e) {
    echo 'FATAL EXCEPTION: ' . $e->getMessage(), PHP_EOL;
}

 $system->getMemoryCategory('total', true)