Topics

Server Load for android 2.1

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

Program test on 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)?