Changeset 126 for trunk


Ignore:
Timestamp:
06/06/05 16:12:33 (19 years ago)
Author:
bastiaans
Message:

web/addons/toga/templates/header.tpl:

  • Changed form action to /

web/addons/toga/templates/overview.tpl:

  • Added showhosts HTML

web/addons/toga/index.php:

  • Header will now show metricmenu
  • Form changed to 1 global form

web/addons/toga/overview.php:

  • Setup for different pie graphs for filters
  • Added showhosts code for a job

web/addons/toga/libtoga.php:

  • Some extra global ganglia vars we need
Location:
trunk/web/addons/toga
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/toga/index.php

    r124 r126  
    3636        global $parentgrid, $physical, $hostname;
    3737        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 );
    3950        if ( $context == "control" && $controlroom < 0 )
    4051                $header = "header-nobanner";
     
    134145        }
    135146
     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
    136157        $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">Joblist</A></B> ";
    137158
     
    141162
    142163                        $node_menu .= "<B>&gt;</B>\n";
    143                         $node_menu .= "<B>'$filtername': $filterval</B> ";
     164                        $node_menu .= "<B>$filtername- $filterval</B> ";
    144165                }
    145166        }
    146167
    147168        $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>&nbsp;&nbsp;"
     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>&nbsp;&nbsp;"
     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;
    148212
    149213        # Make sure that no data is cached..
     
    200264                break;
    201265
    202         case "jobview":
    203 
    204                 includeJobview();
    205                 break;
     266        //case "jobview":
     267
     268        //      includeJobview();
     269        //      break;
    206270
    207271        default:
     
    225289                break;
    226290
    227         case "jobview":
    228 
    229                 makeJobview();
    230                 break;
     291        //case "jobview":
     292
     293        //      makeJobview();
     294        //      break;
    231295
    232296        default:
  • trunk/web/addons/toga/libtoga.php

    r124 r126  
    7575// provide us with the correct metrics array
    7676//
    77 global $context, $clustername;
     77global $context, $clustername, $reports;
    7878//$clustername = $httpvars->getClusterName();
    7979//$context = 'cluster';
    8080
     81
     82global $default_metric;
     83
    8184// Ganglia's array of host metrics
    8285//
    83 global $metrics;
     86global $metrics, $hosts_up;
    8487
    8588
  • trunk/web/addons/toga/overview.php

    r124 r126  
    11<?php
    2 global $GANGLIA_PATH, $clustername, $tpl, $filter, $cluster, $get_metric_string, $cluster_url;
     2global $GANGLIA_PATH, $clustername, $tpl, $filter, $cluster, $get_metric_string, $cluster_url, $sh;
     3global $hosts_up, $m, $start, $end;
    34
    45$data_gatherer = new DataGatherer();
     
    1112$heartbeat = $data_gatherer->getHeartbeat();
    1213$jobs = $data_gatherer->getJobs();
    13 $nodes = $data_gatherer->getNodes();
     14$gnodes = $data_gatherer->getNodes();
    1415$cpus = $data_gatherer->getCpus();
    1516
     
    2324$tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url );
    2425
    25 
    26 $pie = drawClusterPie();
     26if( array_key_exists( "id", $filter ) )
     27        $pie = drawJobPie();
     28else if( array_key_exists( "user", $filter ) )
     29        $pie = drawUserPie();
     30else if( array_key_exists( "queue", $filter ) )
     31        $pie = drawQueuePie();
     32else
     33        $pie = drawClusterPie();
     34
    2735$tpl->assign("pie", $pie );
    2836
     
    170178}
    171179
     180function drawJobPie() {
     181}
     182
     183function drawUserPie() {
     184
     185}
     186
     187function drawQueuePie() {
     188
     189}
    172190
    173191
    174192function drawClusterPie() {
    175193
    176         global $jobs, $nodes;
    177 
     194        global $jobs, $gnodes;
     195
     196        $nodes = $gnodes;
     197       
    178198        $pie_args = "title=" . rawurlencode("Cluster queue usage");
    179199        $pie_args .= "&size=250x150";
     
    326346
    327347        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;
    329353
    330354        $tpl->assign("sortorder", $sortorder );
     
    336360
    337361        $overview_jobs = count( $sorted_jobs );
    338         $overview_nodes = count( $nodes );
     362        $overview_nodes = count( $gnodes );
    339363        $overview_cpus = 0;
    340364
     
    378402                                $tpl->assign("queue", $jobs[$jobid][queue] );
    379403                                $tpl->assign("name", $jobs[$jobid][name] );
     404                                $domain = $jobs[$jobid][domain];
    380405                                $tpl->assign("req_cpu", makeTime( timeToEpoch( $jobs[$jobid][requested_time] ) ) );
    381406                                $tpl->assign("req_memory", $jobs[$jobid][requested_memory] );
     
    386411                                $tpl->assign("cpus", $cpus );
    387412                                $start_time = (int) $jobs[$jobid][start_timestamp];
     413                                $job_start = $start_time;
    388414
    389415                                $f_cpus = $f_cpus + $cpus;
     
    403429
    404430                                        $runningtime = makeTime( $report_time - $start_time );
     431                                        $job_runningtime = $report_time - $start_time;
    405432                                        $tpl->assign("started", makeDate( $start_time ) );
    406433                                        $tpl->assign("runningtime", $runningtime );
     
    417444        $tpl->assignGlobal("f_cpus_nr", $f_cpus );
    418445        $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        }
    419564}
    420565?>
  • trunk/web/addons/toga/templates/header.tpl

    r117 r126  
    99<BODY BGCOLOR="#FFFFFF">
    1010
    11 <FORM ACTION="{page}" METHOD="GET" NAME="ganglia_form">
     11<FORM ACTION="./" METHOD="GET" NAME="toga_form">
    1212<TABLE WIDTH="100%">
    1313<TR>
     
    4545</TR>
    4646</TABLE>
    47 </FORM>
    4847
    4948<FONT SIZE="+1">
  • trunk/web/addons/toga/templates/overview.tpl

    r124 r126  
    1717<BR><BR>
    1818
     19<SCRIPT TYPE="text/javascript" SRC="ts_picker.js"></SCRIPT>
    1920<SCRIPT TYPE="text/javascript">
    2021        function setSort( sortbyval ) {
     
    5152</SCRIPT>
    5253
    53 <FORM NAME="toga_form" ACTION="./" METHOD="GET">
    54 
    5554<INPUT TYPE="HIDDEN" NAME="sortby" VALUE="{sortby}">
    5655<INPUT TYPE="HIDDEN" NAME="sortorder" VALUE="{sortorder}">
     
    6059<INPUT TYPE="HIDDEN" NAME="user" VALUE="{f_user}">
    6160<INPUT TYPE="HIDDEN" NAME="id" VALUE="{f_id}">
    62 
    63 </FORM>
    6461
    6562<TABLE WIDTH="90%" CELLPADDING="8" CELLSPACING="3" BORDER=0>
     
    9390</TABLE>
    9491</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&nbsp;&nbsp;{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.