Changeset 742
- Timestamp:
- 03/25/13 12:08:47 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/web/addons/job_monarch/libtoga.php
r738 r742 464 464 function DataSource() 465 465 { 466 global $DATA_SOURCE ;466 global $DATA_SOURCE, $clustername; 467 467 468 468 $ds_fields = explode( ':', $DATA_SOURCE ); 469 469 470 470 $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; 474 474 $this->port = $ds_port; 475 475 $this->clustername = $clustername; 476 476 } 477 477 … … 479 479 { 480 480 $errstr = ''; 481 $errno = 0;482 $timeout = 3;481 $errno = 0; 482 $timeout = 3; 483 483 484 484 $fp = fsockopen( $this->ip, $this->port, $errno, $errstr, $timeout ); … … 488 488 echo 'Unable to connect to '.$this->ip.':'.$this->port; 489 489 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 } 490 502 } 491 503 … … 1070 1082 $this->tasks = 0; 1071 1083 $this->hostname = $hostname; 1072 $this->cpus = $this->determineCpus();1073 1084 $this->clustername = $cluster; 1074 1085 $this->showinfo = 1; … … 1268 1279 } 1269 1280 1270 function determine Cpus()1281 function determineLoad() 1271 1282 { 1272 1283 global $metrics; 1273 1284 1274 1285 $cpus = $metrics[$this->hostname]['cpu_num']['VAL']; 1275 1276 1286 if (!$cpus) 1277 1287 { … … 1279 1289 } 1280 1290 1281 return $cpus;1282 }1283 1284 function determineLoad()1285 {1286 global $metrics;1287 1288 1291 $load_one = $metrics[$this->hostname]['load_one']['VAL']; 1289 $load = ((float) $load_one)/$ this->cpus;1292 $load = ((float) $load_one)/$cpus; 1290 1293 1291 1294 return $load;
Note: See TracChangeset
for help on using the changeset viewer.