Topics

Server Load for android 2.1

is open source widgets for that retrieve your current and display it on a on your android screen, you can add more widgets for each server. The will update every 30 min to display your server’s current average load. Check the example for extracting your servers’ current load.

on Galaxy s2

Download
Source Code
GitHub

Get from Android Market

php file ex:

<?php
$load = getServerLoad();

if( $load !== NULL ){
    $load = explode(' ', $load['load']);
    echo $load[0];
}

function getServerLoad(){
    $os=strtolower(PHP_OS);
    if(strpos($os, 'win') === false){
        if(file_exists('/proc/loadavg')){
            $load = file_get_contents('/proc/loadavg');
            $load = explode(' ', $load, 1);
            $load = $load[0];
        }elseif(function_exists('shell_exec')){
            $load = explode(' ', `uptime`);
            $load = $load[count($load)-1];
        }else{
            return NULL;
        }

        if(function_exists('shell_exec'))
            $_count = shell_exec('cat /proc/cpuinfo | grep processor | wc -l');        

        return array('load'=>$load, 'procs'=>$_count);
    }else{
        if(class_exists('COM')){
            $wmi=new COM('WinMgmts:\\\\.');
            $cpus=$wmi->InstancesOf('Win32_Processor');
            $load=0;
            $_count=0;
            if(version_compare('4.50.0', PHP_VERSION) == 1){
                while($ = $cpus->Next()){
                    $load += $->LoadPercentage;
                    $_count++;
                }
            }else{
                foreach($cpus as $){
                    $load += $->LoadPercentage;
                    $_count++;
                }
            }
            return array('load'=>$load, 'procs'=>$_count);
        }
        return NULL;
    }
    return NULL;
}

?>


ScreenShots :





  • Oleh

    Thanks for the widget. would it be hard to update load data on icon tap (click)?