Changeset 126 for trunk/web/addons/toga/overview.php
- Timestamp:
- 06/06/05 16:12:33 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/overview.php
r124 r126 1 1 <?php 2 global $GANGLIA_PATH, $clustername, $tpl, $filter, $cluster, $get_metric_string, $cluster_url; 2 global $GANGLIA_PATH, $clustername, $tpl, $filter, $cluster, $get_metric_string, $cluster_url, $sh; 3 global $hosts_up, $m, $start, $end; 3 4 4 5 $data_gatherer = new DataGatherer(); … … 11 12 $heartbeat = $data_gatherer->getHeartbeat(); 12 13 $jobs = $data_gatherer->getJobs(); 13 $ nodes = $data_gatherer->getNodes();14 $gnodes = $data_gatherer->getNodes(); 14 15 $cpus = $data_gatherer->getCpus(); 15 16 … … 23 24 $tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url ); 24 25 25 26 $pie = drawClusterPie(); 26 if( array_key_exists( "id", $filter ) ) 27 $pie = drawJobPie(); 28 else if( array_key_exists( "user", $filter ) ) 29 $pie = drawUserPie(); 30 else if( array_key_exists( "queue", $filter ) ) 31 $pie = drawQueuePie(); 32 else 33 $pie = drawClusterPie(); 34 27 35 $tpl->assign("pie", $pie ); 28 36 … … 170 178 } 171 179 180 function drawJobPie() { 181 } 182 183 function drawUserPie() { 184 185 } 186 187 function drawQueuePie() { 188 189 } 172 190 173 191 174 192 function drawClusterPie() { 175 193 176 global $jobs, $nodes; 177 194 global $jobs, $gnodes; 195 196 $nodes = $gnodes; 197 178 198 $pie_args = "title=" . rawurlencode("Cluster queue usage"); 179 199 $pie_args .= "&size=250x150"; … … 326 346 327 347 global $jobs, $nodes, $heartbeat, $clustername, $tpl; 328 global $sortorder, $sortby, $filter; 348 global $sortorder, $sortby, $filter, $sh, $hc, $m; 349 global $cluster_url, $get_metric_string, $host_url, $metrics; 350 global $start, $end, $reports; 351 352 $metricname = $m; 329 353 330 354 $tpl->assign("sortorder", $sortorder ); … … 336 360 337 361 $overview_jobs = count( $sorted_jobs ); 338 $overview_nodes = count( $ nodes );362 $overview_nodes = count( $gnodes ); 339 363 $overview_cpus = 0; 340 364 … … 378 402 $tpl->assign("queue", $jobs[$jobid][queue] ); 379 403 $tpl->assign("name", $jobs[$jobid][name] ); 404 $domain = $jobs[$jobid][domain]; 380 405 $tpl->assign("req_cpu", makeTime( timeToEpoch( $jobs[$jobid][requested_time] ) ) ); 381 406 $tpl->assign("req_memory", $jobs[$jobid][requested_memory] ); … … 386 411 $tpl->assign("cpus", $cpus ); 387 412 $start_time = (int) $jobs[$jobid][start_timestamp]; 413 $job_start = $start_time; 388 414 389 415 $f_cpus = $f_cpus + $cpus; … … 403 429 404 430 $runningtime = makeTime( $report_time - $start_time ); 431 $job_runningtime = $report_time - $start_time; 405 432 $tpl->assign("started", makeDate( $start_time ) ); 406 433 $tpl->assign("runningtime", $runningtime ); … … 417 444 $tpl->assignGlobal("f_cpus_nr", $f_cpus ); 418 445 $tpl->assignGlobal("f_jobs_nr", $f_jobs ); 446 447 if( array_key_exists( "id", $filter ) ) { 448 $tpl->newBlock( "showhosts" ); 449 450 # Present a width list 451 $cols_menu = "<SELECT NAME=\"hc\" OnChange=\"toga_form.submit();\">\n"; 452 453 $hostcols = ($hc) ? $hc : 4; 454 455 foreach(range(1,25) as $cols) { 456 $cols_menu .= "<OPTION VALUE=$cols "; 457 if ($cols == $hostcols) 458 $cols_menu .= "SELECTED"; 459 $cols_menu .= ">$cols\n"; 460 } 461 $cols_menu .= "</SELECT>\n"; 462 463 //$tpl->assign("cluster", $clustername); 464 $tpl->assign("metric","$metricname $units"); 465 $tpl->assign("id", $id); 466 # Host columns menu defined in header.php 467 $tpl->assign("cols_menu", $cols_menu); 468 469 if( $sh) $showhosts = $sh; 470 if( !$showhosts) $showhosts = 0; 471 $tpl->assign("checked$showhosts", "checked"); 472 473 if( $showhosts ) { 474 //----- 475 476 if( !isset($start) ) $start="jobstart"; 477 if( !isset($stop) ) $stop="now"; 478 //$tpl->assign("start", $start); 479 //$tpl->assign("stop", $stop); 480 481 $sorted_hosts = array(); 482 $hosts_up = $jobs[$filter[id]][nodes]; 483 484 $r = intval($job_runningtime * 1.25); 485 486 $jobrange = ($job_runningtime < 3600) ? -3600 : -$r ; 487 $jobstart = $report_time - $job_runningtime; 488 489 if ($reports[$metricname]) 490 $metricval = "g"; 491 else 492 $metricval = "m"; 493 494 foreach ($hosts_up as $host ) { 495 $host = $host. '.'.$domain; 496 $cpus = $metrics[$host]["cpu_num"][VAL]; 497 if (!$cpus) $cpus=1; 498 $load_one = $metrics[$host]["load_one"][VAL]; 499 $load = ((float) $load_one)/$cpus; 500 $host_load[$host] = $load; 501 $percent_hosts[load_color($load)] += 1; 502 if ($metricname=="load_one") 503 $sorted_hosts[$host] = $load; 504 else 505 $sorted_hosts[$host] = $metrics[$host][$metricname][VAL]; 506 } 507 switch ($sort) { 508 case "descending": 509 arsort($sorted_hosts); 510 break; 511 case "by hostname": 512 ksort($sorted_hosts); 513 break; 514 default: 515 case "ascending": 516 asort($sorted_hosts); 517 break; 518 } 519 520 //$sorted_hosts = array_merge($down_hosts, $sorted_hosts); 521 522 # First pass to find the max value in all graphs for this 523 # metric. The $start,$end variables comes from get_context.php, 524 # included in index.php. 525 list($min, $max) = find_limits($sorted_hosts, $metricname); 526 527 # Second pass to output the graphs or metrics. 528 $i = 1; 529 foreach ( $sorted_hosts as $host=>$value ) { 530 $tpl->newBlock ("sorted_list"); 531 //$host = $host. '.'.$domain; 532 $host_url = rawurlencode($host); 533 $cluster_url = rawurlencode($clustername); 534 535 $textval = ""; 536 //printf("host = %s, value = %s", $host, $value); 537 //echo "$host: $value, "; 538 $val = $metrics[$host][$metricname]; 539 $class = "metric"; 540 $host_link="\"?c=$cluster_url&h=$host_url&r=job&jr=$jobrange&js=$jobstart\""; 541 542 if ($val[TYPE]=="timestamp" or $always_timestamp[$metricname]) { 543 $textval = date("r", $val[VAL]); 544 } elseif ($val[TYPE]=="string" or $val[SLOPE]=="zero" or $always_constant[$metricname] or ($max_graphs > 0 and $i > $max_graphs )) { 545 $textval = "$val[VAL] $val[UNITS]"; 546 } else { 547 $load_color = load_color($host_load[$host]); 548 $graphargs = ($reports[$metricname]) ? "g=$metricname&" : "m=$metricname&"; 549 $graphargs .= "z=small&c=$cluster_url&h=$host_url&l=$load_color" ."&v=$val[VAL]&x=$max&n=$min&r=job&jr=$jobrange&js=$jobstart"; 550 } 551 if ($textval) { 552 $cell="<td class=$class>". "<b><a href=$host_link>$host</a></b><br>". "<i>$metricname:</i> <b>$textval</b></td>"; 553 } else { 554 $cell="<td><a href=$host_link>". "<img src=\"../../graph.php?$graphargs\" ". "alt=\"$host\" height=112 width=225 border=0></a></td>"; 555 } 556 557 $tpl->assign("metric_image", $cell); 558 if (! ($i++ % $hostcols) ) 559 $tpl->assign ("br", "</tr><tr>"); 560 } 561 } 562 //--- 563 } 419 564 } 420 565 ?>
Note: See TracChangeset
for help on using the changeset viewer.