Changeset 123 for trunk


Ignore:
Timestamp:
06/02/05 10:43:09 (19 years ago)
Author:
bastiaans
Message:

toga/overview.php:

  • Fixed piechart percentage calculation for jobs
  • Now a job has a certain 'weight' on a node depending on how much jobs are running there
File:
1 edited

Legend:

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

    r122 r123  
    183183        $emptynodes = 0;
    184184
     185        $job_weight = array();
     186
    185187        foreach( $nodes as $node ) {
    186188
     
    189191                if( count( $myjobs ) == 0 )
    190192                        $emptynodes++;
    191                 else
    192                         $nodes_jobs = $nodes_jobs + count( $myjobs );
    193         }
     193        }
     194        $used_nodes = $nr_nodes - $emptynodes;
    194195
    195196        $empty_percentage = ($emptynodes / $nr_nodes) * 100;
     
    200201        $pie_args .= "&free=$empty_percentage,$color";
    201202
    202         foreach( $jobs as $jobid => $jobattrs ) {
    203 
    204                 $qname = $jobattrs[queue];
    205 
    206                 if( !array_search( $qname, $queues ) ) {
     203        foreach( $nodes as $node ) {
     204
     205                $node_jobs = $node->getJobs();
     206                $nr_node_jobs = count( $node_jobs );
     207                $myhost = $node->getHostname();
     208
     209                foreach( $node_jobs as $myjob ) {
     210
     211                        // Determine the weight of this job on the node it is running
     212                        // - what percentage of the node is in use by this job
     213                        //
     214                        $job_weight[$myjob] = ( 100 / count( $node_jobs ) ) / 100;
     215                        $qname = $jobs[$myjob][queue];
    207216
    208217                        if( !isset( $queues[$qname] ) )
    209                                 $queues[$qname] = array();
    210 
    211                         $queues[$qname][] = $jobid;
     218                                $queues[$qname] = $job_weight[$myjob];
     219                        else
     220                                $queues[$qname] = $queues[$qname] + $job_weight[$myjob];
    212221                }
    213222        }
    214223
    215224        $qcolors = array();
    216         foreach( $queues as $queue => $myjobs ) {
    217 
    218                 $qjobs = count ( $myjobs );
    219                 $percentage = ( $qjobs / $nr_jobs ) * $job_percentage;
     225        foreach( $queues as $queue => $totalweight) {
     226
     227                $percentage = ( $totalweight / $used_nodes ) * $job_percentage;
     228               
    220229                $color = randomColor( $qcolors );
    221230                $qcolors[] = $color;
Note: See TracChangeset for help on using the changeset viewer.