- Timestamp:
- 06/06/05 16:12:33 (18 years ago)
- Location:
- trunk/web/addons/toga
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/index.php
r124 r126 36 36 global $parentgrid, $physical, $hostname; 37 37 global $self, $filter, $cluster_url, $get_metric_string; 38 38 global $metrics, $reports, $m, $default_metric; 39 40 if( isset($default_metric) and !isset($m) ) 41 $metricname = $default_metric; 42 else 43 if( isset( $m ) ) 44 $metricname = $m; 45 else 46 $metricname = "load_one"; 47 48 //$metricname = ($m) ? $m : $default_metric; 49 //printf( "m = %s, metricname = %s, default_metric = %s\n", $m, $metricname, $default_metric ); 39 50 if ( $context == "control" && $controlroom < 0 ) 40 51 $header = "header-nobanner"; … … 134 145 } 135 146 147 if (!count($metrics)) { 148 echo "<h4>Cannot find any metrics for selected cluster \"$clustername\", exiting.</h4>\n"; echo "Check ganglia XML tree (telnet $ganglia_ip $ganglia_port)\n"; 149 exit; 150 } 151 $firsthost = key($metrics); 152 foreach ($metrics[$firsthost] as $m => $foo) 153 $context_metrics[] = $m; 154 foreach ($reports as $r => $foo) 155 $context_metrics[] = $r; 156 136 157 $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">Joblist</A></B> "; 137 158 … … 141 162 142 163 $node_menu .= "<B>></B>\n"; 143 $node_menu .= "<B> '$filtername':$filterval</B> ";164 $node_menu .= "<B>$filtername- $filterval</B> "; 144 165 } 145 166 } 146 167 147 168 $tpl->assign("node_menu", $node_menu); 169 170 if( array_key_exists( "id", $filter ) ) { 171 //$context_ranges[]="hour"; 172 //$context_ranges[]="day"; 173 //$context_ranges[]="week"; 174 //$context_ranges[]="month"; 175 //$context_ranges[]="year"; 176 //if ($jobrange) 177 // $context_ranges[]="job"; 178 179 //$range_menu = "<B>Last</B> " 180 // ."<SELECT NAME=\"r\" OnChange=\"toga_form.submit();\">\n"; 181 //foreach ($context_ranges as $v) { 182 // $url=rawurlencode($v); 183 // $range_menu .= "<OPTION VALUE=\"$url\" "; 184 // if ($v == $range) 185 // $range_menu .= "SELECTED"; 186 // $range_menu .= ">$v\n"; 187 // } 188 // $range_menu .= "</SELECT>\n"; 189 190 // $tpl->assign("range_menu", $range_menu); 191 192 //$metricname = $m; 193 194 if (is_array($context_metrics) ) { 195 $metric_menu = "<B>Metric</B> " 196 ."<SELECT NAME=\"m\" OnChange=\"toga_form.submit();\">\n"; 197 198 sort($context_metrics); 199 foreach( $context_metrics as $k ) { 200 $url = rawurlencode($k); 201 $metric_menu .= "<OPTION VALUE=\"$url\" "; 202 if ($k == $metricname ) 203 $metric_menu .= "SELECTED"; 204 $metric_menu .= ">$k\n"; 205 } 206 $metric_menu .= "</SELECT>\n"; 207 208 $tpl->assign("metric_menu", $metric_menu ); 209 } 210 } 211 $m = $metricname; 148 212 149 213 # Make sure that no data is cached.. … … 200 264 break; 201 265 202 case "jobview":203 204 includeJobview();205 break;266 //case "jobview": 267 268 // includeJobview(); 269 // break; 206 270 207 271 default: … … 225 289 break; 226 290 227 case "jobview":228 229 makeJobview();230 break;291 //case "jobview": 292 293 // makeJobview(); 294 // break; 231 295 232 296 default: -
trunk/web/addons/toga/libtoga.php
r124 r126 75 75 // provide us with the correct metrics array 76 76 // 77 global $context, $clustername ;77 global $context, $clustername, $reports; 78 78 //$clustername = $httpvars->getClusterName(); 79 79 //$context = 'cluster'; 80 80 81 82 global $default_metric; 83 81 84 // Ganglia's array of host metrics 82 85 // 83 global $metrics ;86 global $metrics, $hosts_up; 84 87 85 88 -
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 ?> -
trunk/web/addons/toga/templates/header.tpl
r117 r126 9 9 <BODY BGCOLOR="#FFFFFF"> 10 10 11 <FORM ACTION=" {page}" METHOD="GET" NAME="ganglia_form">11 <FORM ACTION="./" METHOD="GET" NAME="toga_form"> 12 12 <TABLE WIDTH="100%"> 13 13 <TR> … … 45 45 </TR> 46 46 </TABLE> 47 </FORM>48 47 49 48 <FONT SIZE="+1"> -
trunk/web/addons/toga/templates/overview.tpl
r124 r126 17 17 <BR><BR> 18 18 19 <SCRIPT TYPE="text/javascript" SRC="ts_picker.js"></SCRIPT> 19 20 <SCRIPT TYPE="text/javascript"> 20 21 function setSort( sortbyval ) { … … 51 52 </SCRIPT> 52 53 53 <FORM NAME="toga_form" ACTION="./" METHOD="GET">54 55 54 <INPUT TYPE="HIDDEN" NAME="sortby" VALUE="{sortby}"> 56 55 <INPUT TYPE="HIDDEN" NAME="sortorder" VALUE="{sortorder}"> … … 60 59 <INPUT TYPE="HIDDEN" NAME="user" VALUE="{f_user}"> 61 60 <INPUT TYPE="HIDDEN" NAME="id" VALUE="{f_id}"> 62 63 </FORM>64 61 65 62 <TABLE WIDTH="90%" CELLPADDING="8" CELLSPACING="3" BORDER=0> … … 93 90 </TABLE> 94 91 </CENTER> 92 93 <!-- START BLOCK : showhosts --> 94 <TABLE BORDER="0" WIDTH="100%"> 95 <TR> 96 <TD CLASS=title COLSPAN="2"> 97 <FONT SIZE="-1"> 98 Show Hosts: 99 yes<INPUT type=radio name="sh" value="1" OnClick="toga_form.submit();" {checked1}> 100 no<INPUT type=radio name="sh" value="0" OnClick="toga_form.submit();" {checked0}> 101 </FONT> 102 | 103 job <strong>{id}</strong> metric <strong>{metric}</strong> 104 | 105 <FONT SIZE="-1"> 106 Columns {cols_menu} 107 </FONT><!-- <BR> 108 <FONT SIZE="-1"> 109 Set graph timeperiod from <INPUT TYPE="text" NAME="start" VALUE="{start}" SIZE=12 ALT="Start time"><a href="javascript:show_calendar('document.toga_form.start', document.toga_form.start.value);"><img src="cal.gif" width="16" height="16" border="0"></a> to <INPUT TYPE="text" NAME="stop" VALUE="{stop}" SIZE=12 ALT="Stop time"><a href="javascript:show_calendar('document.toga_form.stop', document.toga_form.stop.value);"><img src="cal.gif" width="16" height="16" border="0"></a><INPUT TYPE="submit" VALUE="Refresh graphs"> 110 </FONT> --> 111 </TD> 112 </TR> 113 114 </TABLE> 115 116 <CENTER> 117 <TABLE> 118 <TR> 119 <!-- START BLOCK : sorted_list --> 120 {metric_image}{br} 121 <!-- END BLOCK : sorted_list --> 122 </TR> 123 </TABLE> 124 125 <p> 126 (Nodes colored by 1-minute load) | <A HREF="../../node_legend.html" ALT="Node Image egend">Legend</A> 127 128 </CENTER> 129 130 <!-- END BLOCK : showhosts -->
Note: See TracChangeset
for help on using the changeset viewer.