Changeset 828


Ignore:
Timestamp:
04/12/13 15:46:51 (11 years ago)
Author:
ramonb
Message:
  • removed pie chart
Location:
branches/1.0/web/addons/job_monarch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0/web/addons/job_monarch/overview.php

    r823 r828  
    9292
    9393    $tpl_data[ "order"]= $filterorder;
    94 
    95     if( array_key_exists( "id", $filter ) )
    96     {
    97         $piefilter = 'id';
    98     }
    99     else if( array_key_exists( "owner", $filter ) )
    100     {
    101         $piefilter = 'owner';
    102     }
    103     else if( array_key_exists( "queue", $filter ) )
    104     {
    105         $piefilter = 'queue';
    106     }
    107 
    108     $pie    = drawPie();
    109 
    110     $tpl_data["pie"]= $pie;
    11194}
    11295
     
    223206    return $new;
    224207}
    225 
    226 // Code these some day
    227 function drawJobPie() { }
    228 
    229 function drawUserPie() { }
    230 
    231 function drawQueuePie() { }
    232 
    233 function drawPie()
    234 {
    235     global $jobs, $gnodes, $piefilter, $filter, $metrics;
    236 
    237     $nodes = $gnodes;
    238 
    239     if( isset($piefilter) )   
    240     {
    241         $pie_args = "title=" . rawurlencode("Cluster ".$piefilter." usage");
    242     }
    243     else
    244     {
    245         $pie_args = "title=" . rawurlencode("Cluster queue usage");
    246     }
    247 
    248     $pie_args .= "&size=250x150";
    249 
    250     $queues    = array();
    251     $nr_jobs   = count( $jobs );
    252     $nr_nodes  = count( $nodes );
    253 
    254     $nr_cpus   = cluster_sum("cpu_num", $metrics);
    255 
    256     $empty_cpus= 0;
    257     $used_cpus = 0;
    258 
    259     $job_weight= array();
    260 
    261     foreach( $nodes as $node )
    262     {
    263         $myjobs    = $node->getJobs();
    264         $myhost    = $node->getHostname();
    265         $node_cpus = $metrics[$myhost]["cpu_num"]['VAL'];
    266         $job_cpu   = 0;
    267 
    268         foreach( $myjobs as $myjob )
    269         {
    270             $job_cpu += isset( $jobs[$myjob]['ppn'] ) ? $jobs[$myjob]['ppn'] : 1;
    271         }
    272 
    273         $node_freecpu= $node_cpus - $job_cpu;
    274 
    275         $empty_cpus += $node_freecpu;
    276     }
    277 
    278     $empty_cpus = ( $empty_cpus >= 0 ) ? $empty_cpus : 0;
    279     $used_cpus  = $nr_cpus - $empty_cpus;
    280 
    281     $empty_percentage= $empty_cpus;
    282 
    283     $qcolors   = array();
    284     $color     = randomColor( $qcolors );
    285     $qcolors[] = $color;
    286     $pie_args .= "&free=$empty_percentage,$color";
    287 
    288     if( isset( $piefilter ) )
    289     {
    290         $filterpie = array();
    291     }
    292 
    293     foreach( $nodes as $node )
    294     {
    295         $node_jobs    = $node->getJobs();
    296         $nr_node_jobs = count( $node_jobs );
    297         $myhost       = $node->getHostname();
    298         $node_cpus    = $metrics[$myhost]["cpu_num"]['VAL'];
    299 
    300         foreach( $node_jobs as $myjob )
    301         {
    302             $job_cpu = isset( $jobs[$myjob]['ppn'] ) ? $jobs[$myjob]['ppn'] : 1;
    303 
    304             // Determine the weight of this job
    305             // - what percentage of the cpus is in use by this job
    306             //
    307             //$job_weight[$myjob]    = ( $job_cpu / $nr_cpus );
    308             $job_weight[$myjob]    = $job_cpu;
    309 
    310             if( isset( $piefilter ) ) {
    311 
    312                 $countjob = 1;
    313 
    314                 if( $piefilter == 'id' )
    315                 {
    316                     if( $myjob != $filter[$piefilter] )
    317                     {
    318                         $countjob = 0;
    319                     }
    320                 }
    321                 else if( $piefilter == 'owner' )
    322                 {
    323                     if( $jobs[$myjob]['owner'] != $filter[$piefilter] )
    324                     {
    325                         $countjob = 0;
    326                     }
    327                 }
    328                 else
    329                 {
    330                     if( $jobs[$myjob][$piefilter] != $filter[$piefilter] )
    331                     {
    332                         $countjob = 0;
    333                     }
    334                 }
    335 
    336                 if( $countjob )
    337                 {
    338 
    339                     if( !isset( $filterpie[$filter[$piefilter]] ) )
    340                     {
    341                         $filterpie[$filter[$piefilter]] = $job_weight[$myjob];
    342                     }
    343                     else
    344                     {
    345 
    346                         $filterpie[$filter[$piefilter]] = $filterpie[$filter[$piefilter]] + $job_weight[$myjob];
    347                     }
    348                 }
    349                 else
    350                 {
    351                     if( !isset( $filterpie["other"] ) )
    352                     {
    353                         $filterpie["other"] = $job_weight[$myjob];
    354                     }
    355                     else
    356                     {
    357                         $filterpie["other"] = $filterpie["other"] + $job_weight[$myjob];
    358                     }
    359 
    360                 }
    361                
    362             }
    363             else
    364             {
    365 
    366                 $qname = $jobs[$myjob]['queue'];
    367 
    368                 if( !isset( $queues[$qname] ) )
    369                 {
    370                     $queues[$qname] = $job_weight[$myjob];
    371                 }
    372                 else
    373                 {
    374                     $queues[$qname] = $queues[$qname] + $job_weight[$myjob];
    375                 }
    376             }
    377         }
    378     }
    379 
    380     if( isset( $piefilter ) )
    381     {
    382         $graphvals = $filterpie;
    383     }
    384     else
    385     {
    386         $graphvals = $queues;
    387     }
    388 
    389     foreach( $graphvals as $name => $totalweight)
    390     {
    391         $percentage    = $totalweight;
    392        
    393         $color         = randomColor( $qcolors );
    394         $qcolors[]     = $color;
    395         $pie_args     .= "&$name=$percentage,$color";
    396     }
    397     $pie = "../../pie.php?$pie_args";
    398 
    399     return $pie;
    400 }
    401 
    402208
    403209function sortJobs( $jobs, $sortby, $sortorder )
  • branches/1.0/web/addons/job_monarch/templates/overview.tpl

    r824 r828  
    147147  </TD>
    148148
    149   </TD>
    150   <TD ALIGN="CENTER">
    151     <IMG SRC="{$pie}">
    152   </TD>
    153149</TR>
    154150</TABLE>
Note: See TracChangeset for help on using the changeset viewer.