Changeset 742


Ignore:
Timestamp:
03/25/13 12:08:47 (11 years ago)
Author:
ramonb
Message:
  • some minor speedup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.4/web/addons/job_monarch/libtoga.php

    r738 r742  
    464464    function DataSource()
    465465    {
    466         global $DATA_SOURCE;
     466        global $DATA_SOURCE, $clustername;
    467467
    468468        $ds_fields     = explode( ':', $DATA_SOURCE );
    469469
    470470        $ds_ip         = $ds_fields[0];
    471         $ds_port     = $ds_fields[1];
    472 
    473         $this->ip     = $ds_ip;
     471        $ds_port       = $ds_fields[1];
     472
     473        $this->ip       = $ds_ip;
    474474        $this->port     = $ds_port;
    475 
     475        $this->clustername = $clustername;
    476476    }
    477477
     
    479479    {
    480480        $errstr        = '';
    481         $errno        = 0;
    482         $timeout    = 3;
     481        $errno         = 0;
     482        $timeout       = 3;
    483483
    484484        $fp = fsockopen( $this->ip, $this->port, $errno, $errstr, $timeout );
     
    488488            echo 'Unable to connect to '.$this->ip.':'.$this->port;
    489489            return;
     490        }
     491
     492        if( $this->port == '8652' )
     493        {
     494            $request = "/$this->clustername\n";
     495            $rc = fputs($fp, $request);
     496            if (!$rc)
     497            {
     498                $error = "Could not sent request to gmetad: $errstr";
     499                if ($debug) print "<br/>DEBUG: $error\n";
     500                   return FALSE;
     501            }
    490502        }
    491503
     
    10701082        $this->tasks        = 0;
    10711083        $this->hostname        = $hostname;
    1072         $this->cpus        = $this->determineCpus();
    10731084        $this->clustername    = $cluster;
    10741085        $this->showinfo        = 1;
     
    12681279    }
    12691280
    1270     function determineCpus()
     1281    function determineLoad()
    12711282    {
    12721283        global $metrics;
    12731284
    12741285        $cpus = $metrics[$this->hostname]['cpu_num']['VAL'];
    1275 
    12761286        if (!$cpus)
    12771287        {
     
    12791289        }
    12801290
    1281         return $cpus;
    1282     }
    1283 
    1284     function determineLoad()
    1285     {
    1286         global $metrics;
    1287 
    12881291        $load_one    = $metrics[$this->hostname]['load_one']['VAL'];
    1289         $load        = ((float) $load_one)/$this->cpus;
     1292        $load        = ((float) $load_one)/$cpus;
    12901293
    12911294        return $load;
Note: See TracChangeset for help on using the changeset viewer.