Page 1 of 1

Load not being shown in web ui on freebsd

Posted: Fri Nov 08, 2013 7:24 am
by aleatorvb
Load not being shown in web ui on freebsd.

On ubuntu the uptime string is ... load average: ...
On freebsd the uptime string is ... load averages: ...

Modified file functions.php and replaced getLoad() with

Code: Select all

function getLoad()
{
    $uptime = shell_exec( 'uptime' );
    $load = '';
    if ( preg_match( '/load average: ([\d.]+)/', $uptime, $matches ) ){
        $load = $matches[1];
    }elseif(preg_match( '/load averages: ([\d.]+)/', $uptime, $matches ) ){
        $load = $matches[1];
    }
    return( $load );
}

Re: Load not being shown in web ui on freebsd

Posted: Fri Nov 08, 2013 7:46 am
by aleatorvb
Shorter (and better) version of getLoad()

Code: Select all

function getLoad()
{
    $uptime = shell_exec( 'uptime' );
    $load = '';
    if ( preg_match( '/load average[s]{0,1}: ([\d.]+)/', $uptime, $matches ) )
        $load = $matches[1];
    return( $load );
}