Changeset 577


Ignore:
Timestamp:
02/03/09 17:04:28 (15 years ago)
Author:
ramonb
Message:

job_monarch/overview.php.orig:

  • old stuff removed

job_monarch/libtoga.php:

  • fixed associative array key WARNINGs of PHP5, i.e.: arraymykey? instead of array[mykey] thanks to felix(.a.t.)derklecks(.d.o.t.)de
Location:
trunk/web2/addons/job_monarch
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web2/addons/job_monarch/libtoga.php

    r576 r577  
    236236
    237237                        $count_result = $this->queryDbase( $count_query );
    238                         $this->resultcount = (int) $count_result[0][count];
     238                        $this->resultcount = (int) $count_result[0]['count'];
    239239
    240240                        $select_query = "SELECT " . $select_result_idname . " " . $query . " ORDER BY job_id DESC LIMIT " . $SEARCH_RESULT_LIMIT;
     
    247247                foreach( $ids as $crow)
    248248                {
    249                         $ret[] = $crow[job_id];
     249                        $ret[] = $crow['job_id'];
    250250                }
    251251
     
    261261                foreach( $result as $result_row )
    262262                {
    263                         $nodes[] = $this->getNodeArray( $result_row[node_id] );
     263                        $nodes[] = $this->getNodeArray( $result_row['node_id'] );
    264264                }
    265265
     
    275275                foreach( $result as $result_row )
    276276                {
    277                         $jobs[] = $this->getJobArray( $result_row[job_id] );
     277                        $jobs[] = $this->getJobArray( $result_row['job_id'] );
    278278                }
    279279                return $jobs;
     
    608608                        foreach( $this->jobs as $jobid=>$jobattrs )
    609609                        {
    610                                 $nodes  = count( $jobattrs[nodes] );
    611                                 $ppn    = (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1;
     610                                $nodes  = count( $jobattrs['nodes'] );
     611                                $ppn    = (int) $jobattrs['ppn'] ? $jobattrs['ppn'] : 1;
    612612                                $mycpus = $nodes * $ppn;
    613613
     
    653653                $nodes = $this->nodes;
    654654
    655                 if ( $attrs[TN] )
     655                if ( $attrs['TN'] )
    656656                {
    657657                        // Ignore dead metrics. Detect and mask failures.
    658                         if ( $attrs[TN] > $attrs[TMAX] * 4 )
     658                        if ( $attrs['TN'] > $attrs['TMAX'] * 4 )
    659659                        {
    660660                                return;
     
    666666                if( $name == 'CLUSTER' )
    667667                {
    668                         $this->proc_cluster = $attrs[NAME];
     668                        $this->proc_cluster = $attrs['NAME'];
    669669                }
    670670                else if( $name == 'HOST' and $this->proc_cluster == $this->clustername)
    671671                {
    672                         $hostname = $attrs[NAME];
     672                        $hostname = $attrs['NAME'];
    673673
    674674                        // Assume to use FQDN if we find a '.' in the hostname
     
    691691                        }
    692692
    693                         $location = $attrs[LOCATION];
     693                        $location = $attrs['LOCATION'];
    694694
    695695                        if( !isset( $nodes[$hostname] ) )
     
    698698                        }
    699699                }
    700                 else if( $name == 'METRIC' and strstr( $attrs[NAME], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
    701                 {
    702                         if( strstr( $attrs[NAME], 'MONARCH-HEARTBEAT' ) )
    703                         {
    704                                 $this->heartbeat['time'] = $attrs[VAL];
    705                         }
    706                         else if( strstr( $attrs[NAME], 'MONARCH-DOWN' ) )
    707                         {
    708                                 $fields         = explode( ' ', $attrs[VAL] );
     700                else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
     701                {
     702                        if( strstr( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) )
     703                        {
     704                                $this->heartbeat['time'] = $attrs['VAL'];
     705                        }
     706                        else if( strstr( $attrs['NAME'], 'MONARCH-DOWN' ) )
     707                        {
     708                                $fields         = explode( ' ', $attrs['VAL'] );
    709709
    710710                                $nodes_down     = array();
     
    746746                                }
    747747                        }
    748                         else if( strstr( $attrs[NAME], 'MONARCH-OFFLINE' ) )
    749                         {
    750                                 $fields         = explode( ' ', $attrs[VAL] );
     748                        else if( strstr( $attrs['NAME'], 'MONARCH-OFFLINE' ) )
     749                        {
     750                                $fields         = explode( ' ', $attrs['VAL'] );
    751751
    752752                                $nodes_offline  = array();
     
    788788                                }
    789789                        }
    790                         else if( strstr( $attrs[NAME], 'MONARCH-JOB' ) )
    791                         {
    792                                 sscanf( $attrs[NAME], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
     790                        else if( strstr( $attrs['NAME'], 'MONARCH-JOB' ) )
     791                        {
     792                                sscanf( $attrs['NAME'], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
    793793
    794794                                if( !isset( $jobs[$jobid] ) )
     
    797797                                }
    798798
    799                                 $fields = explode( ' ', $attrs[VAL] );
     799                                $fields = explode( ' ', $attrs['VAL'] );
    800800
    801801                                foreach( $fields as $f )
     
    808808                                        if( $toganame == 'nodes' )
    809809                                        {
    810                                                 if( $jobs[$jobid][status] == 'R' )
     810                                                if( $jobs[$jobid]['status'] == 'R' )
    811811                                                {
    812812                                                        if( !isset( $jobs[$jobid][$toganame] ) )
     
    826826
    827827                                                }
    828                                                 else if( $jobs[$jobid][status] == 'Q' )
     828                                                else if( $jobs[$jobid]['status'] == 'Q' )
    829829                                                {
    830830                                                        $jobs[$jobid][$toganame] = $togavalue;
     
    837837                                }
    838838
    839                                 if( isset( $jobs[$jobid][nodes] ) )
    840                                 {
    841                                         $nr_nodes = count( $jobs[$jobid][nodes] );
     839                                if( isset( $jobs[$jobid]['nodes'] ) )
     840                                {
     841                                        $nr_nodes = count( $jobs[$jobid]['nodes'] );
    842842               
    843                                         if( $jobs[$jobid][status] == 'R' )
     843                                        if( $jobs[$jobid]['status'] == 'R' )
    844844                                        {
    845                                                 if( isset( $jobs[$jobid][domain] ) )
     845                                                if( isset( $jobs[$jobid]['domain'] ) )
    846846                                                {
    847                                                         $domain         = $jobs[$jobid][domain];
     847                                                        $domain         = $jobs[$jobid]['domain'];
    848848                                                }
    849849                                                $job_nodes      = array();
    850850
    851                                                 foreach( $jobs[$jobid][nodes] as $node )
     851                                                foreach( $jobs[$jobid]['nodes'] as $node )
    852852                                                {
    853853                                                        // Only add domain name to the hostname if Ganglia is doing that too
     
    866866                                                        if( !$my_node->hasJob( $jobid ) )
    867867                                                        {
    868                                                                 if( isset( $jobs[$jobid][ppn] ) )
     868                                                                if( isset( $jobs[$jobid]['ppn'] ) )
    869869                                                                {
    870                                                                         $my_node->addJob( $jobid, ((int) $jobs[$jobid][ppn]) );
     870                                                                        $my_node->addJob( $jobid, ((int) $jobs[$jobid]['ppn']) );
    871871                                                                }
    872872                                                                else
     
    879879                                                        $job_nodes[]    = $host;
    880880                                                }
    881                                                 $jobs[$jobid][nodes]    = $job_nodes;
     881                                                $jobs[$jobid]['nodes']  = $job_nodes;
    882882                                        }
    883883                                }
     
    960960                        printf( "job %s\n", $jobid );
    961961
    962                         if( isset( $job[nodes] ) )
    963                         {
    964                                 foreach( $job[nodes] as $node )
     962                        if( isset( $job['nodes'] ) )
     963                        {
     964                                foreach( $job['nodes'] as $node )
    965965                                {
    966966                                        $mynode = $this->nodes[$node];
     
    13261326                global $metrics;
    13271327
    1328                 $cpus = $metrics[$this->hostname][cpu_num][VAL];
     1328                $cpus = $metrics[$this->hostname][cpu_num]['VAL'];
    13291329
    13301330                if (!$cpus)
     
    13401340                global $metrics;
    13411341
    1342                 $load_one       = $metrics[$this->hostname][load_one][VAL];
     1342                $load_one       = $metrics[$this->hostname][load_one]['VAL'];
    13431343                $load           = ((float) $load_one)/$this->cpus;
    13441344
     
    21292129                                if( $headername == 'nodes' )
    21302130                                {
    2131                                         $attrval        = strval( count( $jobinfo[nodes] ) );
     2131                                        $attrval        = strval( count( $jobinfo['nodes'] ) );
    21322132                                }
    21332133                                else if( $headername == 'cpus' )
    21342134                                {
    2135                                         if( !isset( $jobinfo[ppn] ) )
     2135                                        if( !isset( $jobinfo['ppn'] ) )
    21362136                                        {
    2137                                                 $jobinfo[ppn] = 1;
     2137                                                $jobinfo['ppn'] = 1;
    21382138                                        }
    21392139
    2140                                         $attrval        = strval( count( $jobinfo[nodes] ) * intval( $jobinfo[ppn] ) );
     2140                                        $attrval        = strval( count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] ) );
    21412141                                }
    21422142                                else if( $headername == 'runningtime' )
    21432143                                {
    2144                                         $attrval        = makeTime( intval( $jobinfo[reported] ) - intval( $jobinfo[start_timestamp] ) );
     2144                                        $attrval        = makeTime( intval( $jobinfo['reported'] ) - intval( $jobinfo['start_timestamp'] ) );
    21452145                                }
    21462146                                else
     
    21672167                        $jobinfo                = $dg->getJob( $jobid );
    21682168
    2169                         if( !isset( $this->headerstrlen[id] ) )
    2170                         {
    2171                                 $this->headerstrlen[id] = strlen( strval( $jobid ) );
    2172                         }
    2173                         else if( strlen( strval( $jobid ) ) > $this->headerstrlen[id] )
    2174                         {
    2175                                 $this->headerstrlen[id] = strlen( strval( $jobid ) );
    2176                         }
    2177 
    2178                         if( !isset( $this->headerstrlen[owner] ) )
    2179                         {
    2180                                 $this->headerstrlen[owner]      = strlen( strval( $jobinfo[owner] ) );
    2181                         }
    2182                         else if( strlen( strval( $jobinfo[owner] ) ) > $this->headerstrlen[owner] )
    2183                         {
    2184                                 $this->headerstrlen[owner]      = strlen( strval( $jobinfo[owner] ) );
    2185                         }
    2186 
    2187                         if( !isset( $this->headerstrlen[queue] ) )
    2188                         {
    2189                                 $this->headerstrlen[queue]      = strlen( strval( $jobinfo[queue] ) );
    2190                         }
    2191                         else if( strlen( strval( $jobinfo[queue] ) ) > $this->headerstrlen[queue] )
    2192                         {
    2193                                 $this->headerstrlen[queue]      = strlen( strval( $jobinfo[queue] ) );
    2194                         }
    2195 
    2196                         if( !isset( $jobinfo[ppn] ) )
    2197                         {
    2198                                 $jobinfo[ppn] = 1;
    2199                         }
    2200 
    2201                         $cpus                   = count( $jobinfo[nodes] ) * intval( $jobinfo[ppn] );
    2202 
    2203                         if( !isset( $this->headerstrlen[cpus] ) )
    2204                         {
    2205                                 $this->headerstrlen[cpus]       = strlen( strval( $cpus ) );
    2206                         }
    2207                         else if( strlen( strval( $cpus ) ) > $this->headerstrlen[cpus] )
    2208                         {
    2209                                 $this->headerstrlen[cpus]       = strlen( strval( $cpus ) );
    2210                         }
    2211 
    2212                         $nodes                  = count( $jobinfo[nodes] );
    2213 
    2214                         if( !isset( $this->headerstrlen[nodes] ) )
    2215                         {
    2216                                 $this->headerstrlen[nodes]      = strlen( strval( $nodes ) );
    2217                         }
    2218                         else if( strlen( strval( $nodes) ) > $this->headerstrlen[nodes] )
    2219                         {
    2220                                 $this->headerstrlen[nodes]      = strlen( strval( $nodes ) );
    2221                         }
    2222 
    2223                         $runningtime            = makeTime( intval( $jobinfo[reported] ) - intval( $jobinfo[start_timestamp] ) );
    2224 
    2225                         if( !isset( $this->headerstrlen[runningtime] ) )
    2226                         {
    2227                                 $this->headerstrlen[runningtime]        = strlen( strval( $runningtime) );
    2228                         }
    2229                         else if( strlen( strval( $runningtime) ) > $this->headerstrlen[runningtime] )
    2230                         {
    2231                                 $this->headerstrlen[runningtime]        = strlen( strval( $runningtime) );
    2232                         }
    2233 
    2234                         if( !isset( $this->headerstrlen[name] ) )
    2235                         {
    2236                                 $this->headerstrlen[name]       = strlen( strval( $jobinfo[name] ) );
    2237                         }
    2238                         else if( strlen( strval( $jobinfo[name] ) ) > $this->headerstrlen[name] )
    2239                         {
    2240                                 $this->headerstrlen[name]       = strlen( strval( $jobinfo[name] ) );
     2169                        if( !isset( $this->headerstrlen['id'] ) )
     2170                        {
     2171                                $this->headerstrlen['id']       = strlen( strval( $jobid ) );
     2172                        }
     2173                        else if( strlen( strval( $jobid ) ) > $this->headerstrlen['id'] )
     2174                        {
     2175                                $this->headerstrlen['id']       = strlen( strval( $jobid ) );
     2176                        }
     2177
     2178                        if( !isset( $this->headerstrlen['owner'] ) )
     2179                        {
     2180                                $this->headerstrlen['owner']    = strlen( strval( $jobinfo['owner'] ) );
     2181                        }
     2182                        else if( strlen( strval( $jobinfo['owner'] ) ) > $this->headerstrlen['owner'] )
     2183                        {
     2184                                $this->headerstrlen['owner']    = strlen( strval( $jobinfo['owner'] ) );
     2185                        }
     2186
     2187                        if( !isset( $this->headerstrlen['queue'] ) )
     2188                        {
     2189                                $this->headerstrlen['queue']    = strlen( strval( $jobinfo['queue'] ) );
     2190                        }
     2191                        else if( strlen( strval( $jobinfo['queue'] ) ) > $this->headerstrlen['queue'] )
     2192                        {
     2193                                $this->headerstrlen['queue']    = strlen( strval( $jobinfo['queue'] ) );
     2194                        }
     2195
     2196                        if( !isset( $jobinfo['ppn'] ) )
     2197                        {
     2198                                $jobinfo['ppn'] = 1;
     2199                        }
     2200
     2201                        $cpus                   = count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] );
     2202
     2203                        if( !isset( $this->headerstrlen['cpus'] ) )
     2204                        {
     2205                                $this->headerstrlen['cpus']     = strlen( strval( $cpus ) );
     2206                        }
     2207                        else if( strlen( strval( $cpus ) ) > $this->headerstrlen['cpus'] )
     2208                        {
     2209                                $this->headerstrlen['cpus']     = strlen( strval( $cpus ) );
     2210                        }
     2211
     2212                        $nodes                  = count( $jobinfo['nodes'] );
     2213
     2214                        if( !isset( $this->headerstrlen['nodes'] ) )
     2215                        {
     2216                                $this->headerstrlen['nodes']    = strlen( strval( $nodes ) );
     2217                        }
     2218                        else if( strlen( strval( $nodes) ) > $this->headerstrlen['nodes'] )
     2219                        {
     2220                                $this->headerstrlen['nodes']    = strlen( strval( $nodes ) );
     2221                        }
     2222
     2223                        $runningtime            = makeTime( intval( $jobinfo['reported'] ) - intval( $jobinfo['start_timestamp'] ) );
     2224
     2225                        if( !isset( $this->headerstrlen['runningtime'] ) )
     2226                        {
     2227                                $this->headerstrlen['runningtime']      = strlen( strval( $runningtime) );
     2228                        }
     2229                        else if( strlen( strval( $runningtime) ) > $this->headerstrlen['runningtime'] )
     2230                        {
     2231                                $this->headerstrlen['runningtime']      = strlen( strval( $runningtime) );
     2232                        }
     2233
     2234                        if( !isset( $this->headerstrlen['name'] ) )
     2235                        {
     2236                                $this->headerstrlen['name']     = strlen( strval( $jobinfo['name'] ) );
     2237                        }
     2238                        else if( strlen( strval( $jobinfo['name'] ) ) > $this->headerstrlen['name'] )
     2239                        {
     2240                                $this->headerstrlen['name']     = strlen( strval( $jobinfo['name'] ) );
    22412241                        }
    22422242                }
Note: See TracChangeset for help on using the changeset viewer.