Ignore:
Timestamp:
04/18/07 11:11:43 (17 years ago)
Author:
bastiaans
Message:

job_monarch/overview.php:

  • Pie chart is now based on by-cpu percentage instead of by-node percentage
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/job_monarch/overview.php

    r311 r315  
    182182function drawPie() {
    183183
    184         global $jobs, $gnodes, $piefilter, $filter;
    185 
    186         $nodes = $gnodes;
     184        global $jobs, $gnodes, $piefilter, $filter, $metrics;
     185
     186        $nodes          = $gnodes;
    187187
    188188        if( isset($piefilter) )
    189                 $pie_args = "title=" . rawurlencode("Cluster ".$piefilter." usage");
     189                $pie_args       = "title=" . rawurlencode("Cluster ".$piefilter." usage");
    190190        else
    191                 $pie_args = "title=" . rawurlencode("Cluster queue usage");
     191                $pie_args       = "title=" . rawurlencode("Cluster queue usage");
    192192               
    193         $pie_args .= "&size=250x150";
    194 
    195         $queues = array();
    196         $nr_jobs = count( $jobs );
    197         $nr_nodes = count( $nodes );
    198 
    199         $emptynodes = 0;
    200 
    201         $job_weight = array();
     193        $pie_args       .= "&size=250x150";
     194
     195        $queues         = array();
     196        $nr_jobs        = count( $jobs );
     197        $nr_nodes       = count( $nodes );
     198
     199        $nr_cpus        = cluster_sum("cpu_num", $metrics);
     200
     201        $empty_cpus     = 0;
     202        $used_cpus      = 0;
     203
     204        $job_weight     = array();
    202205
    203206        foreach( $nodes as $node ) {
    204207
    205                 $myjobs = $node->getJobs();
    206 
    207                 if( count( $myjobs ) == 0 )
    208                         $emptynodes++;
    209         }
    210         $used_nodes = $nr_nodes - $emptynodes;
    211 
    212         $empty_percentage = ($emptynodes / $nr_nodes) * 100;
    213         $job_percentage = 100 - $empty_percentage;
    214 
    215         $qcolors = array();
    216         $color = randomColor( $qcolors );
    217         $qcolors[] = $color;
    218         $pie_args .= "&free=$empty_percentage,$color";
     208                $myjobs         = $node->getJobs();
     209                $myhost         = $node->getHostname();
     210                $node_cpus      = $metrics[$myhost]["cpu_num"][VAL];
     211                $job_cpu        = 0;
     212
     213                foreach( $myjobs as $myjob ) {
     214
     215                        $job_cpu        += (int) $jobs[$myjob][ppn] ? $jobs[$myjob][ppn] : 1;
     216                }
     217
     218                $node_freecpu   = $node_cpus - $job_cpu;
     219
     220                $empty_cpus     += $node_freecpu;
     221        }
     222
     223        $used_cpus              = $nr_cpus - $empty_cpus;
     224
     225        $empty_percentage       = ($empty_cpus / $nr_cpus) * 100;
     226
     227        $qcolors                = array();
     228        $color                  = randomColor( $qcolors );
     229        $qcolors[]              = $color;
     230        $pie_args               .= "&free=$empty_percentage,$color";
    219231
    220232        if( isset( $piefilter ) )
     
    223235        foreach( $nodes as $node ) {
    224236
    225                 $node_jobs = $node->getJobs();
    226                 $nr_node_jobs = count( $node_jobs );
    227                 $myhost = $node->getHostname();
     237                $node_jobs      = $node->getJobs();
     238                $nr_node_jobs   = count( $node_jobs );
     239                $myhost         = $node->getHostname();
     240                $node_cpus      = $metrics[$myhost]["cpu_num"][VAL];
    228241
    229242                foreach( $node_jobs as $myjob ) {
    230243
    231                         // Determine the weight of this job on the node it is running
    232                         // - what percentage of the node is in use by this job
     244                        $job_cpu                = (int) $jobs[$myjob][ppn] ? $jobs[$myjob][ppn] : 1;
     245
     246                        // Determine the weight of this job
     247                        // - what percentage of the cpus is in use by this job
    233248                        //
    234                         $job_weight[$myjob] = ( 100 / count( $node_jobs ) ) / 100;
    235                         $qname = $jobs[$myjob][queue];
     249                        $job_weight[$myjob]     = ( $job_cpu / $nr_cpus );
     250
    236251
    237252                        if( isset($piefilter) ) {
     
    264279                        } else {
    265280
     281                                $qname          = $jobs[$myjob][queue];
     282
    266283                                if( !isset( $queues[$qname] ) )
    267284                                        $queues[$qname] = $job_weight[$myjob];
     
    272289        }
    273290
    274         //$qcolors = array();
    275291        if( isset( $piefilter ) )
    276292                $graphvals = $filterpie;
     
    280296        foreach( $graphvals as $name => $totalweight) {
    281297
    282                 $percentage = ( $totalweight / $used_nodes ) * $job_percentage;
     298                $percentage     = ( $totalweight * 100 );
    283299               
    284                 $color = randomColor( $qcolors );
    285                 $qcolors[] = $color;
    286                 $pie_args .= "&$name=$percentage,$color";
     300                $color          = randomColor( $qcolors );
     301                $qcolors[]      = $color;
     302                $pie_args       .= "&$name=$percentage,$color";
    287303        }
    288304        $pie = "../../pie.php?$pie_args";
Note: See TracChangeset for help on using the changeset viewer.