Return to Snippet

Revision: 1952
at November 28, 2006 09:04 by gdonald


Initial Code
#!/usr/bin/php
<?php

// This works with Mac OS X `uptime`
// others might require tweaks

error_reporting( E_ALL );

function load()
{
    $array = explode( ',', trim( `uptime` ) );

    while( list( , $value ) = each( $array ) )
    {
        if( eregi( 'load', $value ) )
        {
            $parts = explode( ':', trim( $value ) );

            $loads = explode( ' ', $parts[ count( $parts ) - 1 ] );

            $load = $loads[ 1 ];

            break;
        }
    }

    return $load;
}

echo load();

?>

Initial URL

                                

Initial Description

                                

Initial Title
PHP System Load on Mac OS X

Initial Tags
php, mac, load

Initial Language
PHP