Ignore:
Timestamp:
02/03/10 12:57:02 (14 years ago)
Author:
ramonb
Message:

web/addons/job_monarch/libtoga.php:

  • fix php warnings due to incorrect array key usage from PHP4 style
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.3/web/addons/job_monarch/libtoga.php

    r531 r650  
    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;
     
    607607                        foreach( $this->jobs as $jobid=>$jobattrs )
    608608                        {
    609                                 $nodes  = count( $jobattrs[nodes] );
    610                                 $ppn    = (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1;
     609                                $nodes  = count( $jobattrs['nodes'] );
     610                                $ppn    = (int) $jobattrs['ppn'] ? $jobattrs['ppn'] : 1;
    611611                                $mycpus = $nodes * $ppn;
    612612
     
    679679                $nodes = $this->nodes;
    680680
    681                 if ( $attrs[TN] )
     681                if ( $attrs['TN'] )
    682682                {
    683683                        // Ignore dead metrics. Detect and mask failures.
    684                         if ( $attrs[TN] > $attrs[TMAX] * 4 )
     684                        if ( $attrs['TN'] > $attrs['TMAX'] * 4 )
    685685                        {
    686686                                return;
     
    692692                if( $name == 'CLUSTER' )
    693693                {
    694                         $this->proc_cluster = $attrs[NAME];
     694                        $this->proc_cluster = $attrs['NAME'];
    695695                }
    696696                else if( $name == 'HOST' and $this->proc_cluster == $this->clustername)
    697697                {
    698                         $hostname = $attrs[NAME];
    699 
    700                         $location = $attrs[LOCATION];
     698                        $hostname = $attrs['NAME'];
     699
     700                        $location = $attrs['LOCATION'];
    701701
    702702                        if( !isset( $nodes[$hostname] ) )
     
    705705                        }
    706706                }
    707                 else if( $name == 'METRIC' and strstr( $attrs[NAME], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
    708                 {
    709                         if( strstr( $attrs[NAME], 'MONARCH-HEARTBEAT' ) )
    710                         {
    711                                 $this->heartbeat['time'] = $attrs[VAL];
    712                         }
    713                         else if( strstr( $attrs[NAME], 'MONARCH-DOWN' ) )
    714                         {
    715                                 $fields         = explode( ' ', $attrs[VAL] );
     707                else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
     708                {
     709                        if( strstr( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) )
     710                        {
     711                                $this->heartbeat['time'] = $attrs['VAL'];
     712                        }
     713                        else if( strstr( $attrs['NAME'], 'MONARCH-DOWN' ) )
     714                        {
     715                                $fields         = explode( ' ', $attrs['VAL'] );
    716716
    717717                                $nodes_down     = array();
     
    747747                                }
    748748                        }
    749                         else if( strstr( $attrs[NAME], 'MONARCH-OFFLINE' ) )
    750                         {
    751                                 $fields         = explode( ' ', $attrs[VAL] );
     749                        else if( strstr( $attrs['NAME'], 'MONARCH-OFFLINE' ) )
     750                        {
     751                                $fields         = explode( ' ', $attrs['VAL'] );
    752752
    753753                                $nodes_offline  = array();
     
    783783                                }
    784784                        }
    785                         else if( strstr( $attrs[NAME], 'MONARCH-JOB' ) )
    786                         {
    787                                 sscanf( $attrs[NAME], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
     785                        else if( strstr( $attrs['NAME'], 'MONARCH-JOB' ) )
     786                        {
     787                                sscanf( $attrs['NAME'], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
    788788
    789789                                if( !isset( $jobs[$jobid] ) )
     
    792792                                }
    793793
    794                                 $fields = explode( ' ', $attrs[VAL] );
     794                                $fields = explode( ' ', $attrs['VAL'] );
    795795
    796796                                foreach( $fields as $f )
     
    803803                                        if( $toganame == 'nodes' )
    804804                                        {
    805                                                 if( $jobs[$jobid][status] == 'R' )
     805                                                if( $jobs[$jobid]['status'] == 'R' )
    806806                                                {
    807807                                                        if( !isset( $jobs[$jobid][$toganame] ) )
     
    821821
    822822                                                }
    823                                                 else if( $jobs[$jobid][status] == 'Q' )
     823                                                else if( $jobs[$jobid]['status'] == 'Q' )
    824824                                                {
    825825                                                        $jobs[$jobid][$toganame] = $togavalue;
     
    832832                                }
    833833
    834                                 if( isset( $jobs[$jobid][nodes] ) )
    835                                 {
    836                                         $nr_nodes = count( $jobs[$jobid][nodes] );
     834                                if( isset( $jobs[$jobid]['nodes'] ) )
     835                                {
     836                                        $nr_nodes = count( $jobs[$jobid]['nodes'] );
    837837               
    838                                         if( $jobs[$jobid][status] == 'R' )
     838                                        if( $jobs[$jobid]['status'] == 'R' )
    839839                                        {
    840840
    841                                                 if( isset( $jobs[$jobid][domain] ) )
     841                                                if( isset( $jobs[$jobid]['domain'] ) )
    842842                                                {
    843                                                         $domain         = $jobs[$jobid][domain];
     843                                                        $domain         = $jobs[$jobid]['domain'];
    844844                                                        $domain_len     = 0 - strlen( $domain );
    845845
     
    860860                                                }
    861861
    862                                                 foreach( $jobs[$jobid][nodes] as $node )
     862                                                foreach( $jobs[$jobid]['nodes'] as $node )
    863863                                                {
    864864
    865865                                                        // Only add domain name to the hostname if Ganglia is doing that too
    866866                                                        //
    867                                                         if( $this->fqdn && isset( $jobs[$jobid][domain] ) )
     867                                                        if( $this->fqdn && isset( $jobs[$jobid]['domain'] ) )
    868868                                                        {
    869869                                                                if( substr( $node, $domain_len ) != $domain )
     
    891891                                                        if( !$my_node->hasJob( $jobid ) )
    892892                                                        {
    893                                                                 if( isset( $jobs[$jobid][ppn] ) )
     893                                                                if( isset( $jobs[$jobid]['ppn'] ) )
    894894                                                                {
    895                                                                         $my_node->addJob( $jobid, ((int) $jobs[$jobid][ppn]) );
     895                                                                        $my_node->addJob( $jobid, ((int) $jobs[$jobid]['ppn']) );
    896896                                                                }
    897897                                                                else
     
    983983                        printf( "job %s\n", $jobid );
    984984
    985                         if( isset( $job[nodes] ) )
    986                         {
    987                                 foreach( $job[nodes] as $node )
     985                        if( isset( $job['nodes'] ) )
     986                        {
     987                                foreach( $job['nodes'] as $node )
    988988                                {
    989989                                        $mynode = $this->nodes[$node];
     
    12661266                global $metrics;
    12671267
    1268                 $cpus = $metrics[$this->hostname][cpu_num][VAL];
     1268                $cpus = $metrics[$this->hostname]['cpu_num']['VAL'];
    12691269
    12701270                if (!$cpus)
     
    12801280                global $metrics;
    12811281
    1282                 $load_one       = $metrics[$this->hostname][load_one][VAL];
     1282                $load_one       = $metrics[$this->hostname]['load_one']['VAL'];
    12831283                $load           = ((float) $load_one)/$this->cpus;
    12841284
     
    20092009                                if( $headername == 'nodes' )
    20102010                                {
    2011                                         $attrval        = strval( count( $jobinfo[nodes] ) );
     2011                                        $attrval        = strval( count( $jobinfo['nodes'] ) );
    20122012                                }
    20132013                                else if( $headername == 'cpus' )
    20142014                                {
    2015                                         if( !isset( $jobinfo[ppn] ) )
     2015                                        if( !isset( $jobinfo['ppn'] ) )
    20162016                                        {
    2017                                                 $jobinfo[ppn] = 1;
     2017                                                $jobinfo['ppn'] = 1;
    20182018                                        }
    20192019
    2020                                         $attrval        = strval( count( $jobinfo[nodes] ) * intval( $jobinfo[ppn] ) );
     2020                                        $attrval        = strval( count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] ) );
    20212021                                }
    20222022                                else if( $headername == 'runningtime' )
    20232023                                {
    2024                                         $attrval        = makeTime( intval( $jobinfo[reported] ) - intval( $jobinfo[start_timestamp] ) );
     2024                                        $attrval        = makeTime( intval( $jobinfo['reported'] ) - intval( $jobinfo['start_timestamp'] ) );
    20252025                                }
    20262026                                else
     
    20472047                        $jobinfo                = $dg->getJob( $jobid );
    20482048
    2049                         if( !isset( $this->headerstrlen[id] ) )
    2050                         {
    2051                                 $this->headerstrlen[id] = strlen( strval( $jobid ) );
    2052                         }
    2053                         else if( strlen( strval( $jobid ) ) > $this->headerstrlen[id] )
    2054                         {
    2055                                 $this->headerstrlen[id] = strlen( strval( $jobid ) );
    2056                         }
    2057 
    2058                         if( !isset( $this->headerstrlen[owner] ) )
    2059                         {
    2060                                 $this->headerstrlen[owner]      = strlen( strval( $jobinfo[owner] ) );
    2061                         }
    2062                         else if( strlen( strval( $jobinfo[owner] ) ) > $this->headerstrlen[owner] )
    2063                         {
    2064                                 $this->headerstrlen[owner]      = strlen( strval( $jobinfo[owner] ) );
    2065                         }
    2066 
    2067                         if( !isset( $this->headerstrlen[queue] ) )
    2068                         {
    2069                                 $this->headerstrlen[queue]      = strlen( strval( $jobinfo[queue] ) );
    2070                         }
    2071                         else if( strlen( strval( $jobinfo[queue] ) ) > $this->headerstrlen[queue] )
    2072                         {
    2073                                 $this->headerstrlen[queue]      = strlen( strval( $jobinfo[queue] ) );
    2074                         }
    2075 
    2076                         if( !isset( $jobinfo[ppn] ) )
    2077                         {
    2078                                 $jobinfo[ppn] = 1;
    2079                         }
    2080 
    2081                         $cpus                   = count( $jobinfo[nodes] ) * intval( $jobinfo[ppn] );
    2082 
    2083                         if( !isset( $this->headerstrlen[cpus] ) )
    2084                         {
    2085                                 $this->headerstrlen[cpus]       = strlen( strval( $cpus ) );
    2086                         }
    2087                         else if( strlen( strval( $cpus ) ) > $this->headerstrlen[cpus] )
    2088                         {
    2089                                 $this->headerstrlen[cpus]       = strlen( strval( $cpus ) );
    2090                         }
    2091 
    2092                         $nodes                  = count( $jobinfo[nodes] );
    2093 
    2094                         if( !isset( $this->headerstrlen[nodes] ) )
    2095                         {
    2096                                 $this->headerstrlen[nodes]      = strlen( strval( $nodes ) );
    2097                         }
    2098                         else if( strlen( strval( $nodes) ) > $this->headerstrlen[nodes] )
    2099                         {
    2100                                 $this->headerstrlen[nodes]      = strlen( strval( $nodes ) );
    2101                         }
    2102 
    2103                         $runningtime            = makeTime( intval( $jobinfo[reported] ) - intval( $jobinfo[start_timestamp] ) );
    2104 
    2105                         if( !isset( $this->headerstrlen[runningtime] ) )
    2106                         {
    2107                                 $this->headerstrlen[runningtime]        = strlen( strval( $runningtime) );
    2108                         }
    2109                         else if( strlen( strval( $runningtime) ) > $this->headerstrlen[runningtime] )
    2110                         {
    2111                                 $this->headerstrlen[runningtime]        = strlen( strval( $runningtime) );
    2112                         }
    2113 
    2114                         if( !isset( $this->headerstrlen[name] ) )
    2115                         {
    2116                                 $this->headerstrlen[name]       = strlen( strval( $jobinfo[name] ) );
    2117                         }
    2118                         else if( strlen( strval( $jobinfo[name] ) ) > $this->headerstrlen[name] )
    2119                         {
    2120                                 $this->headerstrlen[name]       = strlen( strval( $jobinfo[name] ) );
     2049                        if( !isset( $this->headerstrlen['id'] ) )
     2050                        {
     2051                                $this->headerstrlen['id']       = strlen( strval( $jobid ) );
     2052                        }
     2053                        else if( strlen( strval( $jobid ) ) > $this->headerstrlen['id'] )
     2054                        {
     2055                                $this->headerstrlen['id']       = strlen( strval( $jobid ) );
     2056                        }
     2057
     2058                        if( !isset( $this->headerstrlen['owner'] ) )
     2059                        {
     2060                                $this->headerstrlen['owner']    = strlen( strval( $jobinfo['owner'] ) );
     2061                        }
     2062                        else if( strlen( strval( $jobinfo['owner'] ) ) > $this->headerstrlen['owner'] )
     2063                        {
     2064                                $this->headerstrlen['owner']    = strlen( strval( $jobinfo['owner'] ) );
     2065                        }
     2066
     2067                        if( !isset( $this->headerstrlen['queue'] ) )
     2068                        {
     2069                                $this->headerstrlen['queue']    = strlen( strval( $jobinfo['queue'] ) );
     2070                        }
     2071                        else if( strlen( strval( $jobinfo['queue'] ) ) > $this->headerstrlen['queue'] )
     2072                        {
     2073                                $this->headerstrlen['queue']    = strlen( strval( $jobinfo['queue'] ) );
     2074                        }
     2075
     2076                        if( !isset( $jobinfo['ppn'] ) )
     2077                        {
     2078                                $jobinfo['ppn'] = 1;
     2079                        }
     2080
     2081                        $cpus                   = count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] );
     2082
     2083                        if( !isset( $this->headerstrlen['cpus'] ) )
     2084                        {
     2085                                $this->headerstrlen['cpus']     = strlen( strval( $cpus ) );
     2086                        }
     2087                        else if( strlen( strval( $cpus ) ) > $this->headerstrlen['cpus'] )
     2088                        {
     2089                                $this->headerstrlen['cpus']     = strlen( strval( $cpus ) );
     2090                        }
     2091
     2092                        $nodes                  = count( $jobinfo['nodes'] );
     2093
     2094                        if( !isset( $this->headerstrlen['nodes'] ) )
     2095                        {
     2096                                $this->headerstrlen['nodes']    = strlen( strval( $nodes ) );
     2097                        }
     2098                        else if( strlen( strval( $nodes) ) > $this->headerstrlen['nodes'] )
     2099                        {
     2100                                $this->headerstrlen['nodes']    = strlen( strval( $nodes ) );
     2101                        }
     2102
     2103                        $runningtime            = makeTime( intval( $jobinfo[reported] ) - intval( $jobinfo['start_timestamp'] ) );
     2104
     2105                        if( !isset( $this->headerstrlen['runningtime'] ) )
     2106                        {
     2107                                $this->headerstrlen['runningtime']      = strlen( strval( $runningtime) );
     2108                        }
     2109                        else if( strlen( strval( $runningtime) ) > $this->headerstrlen['runningtime'] )
     2110                        {
     2111                                $this->headerstrlen['runningtime']      = strlen( strval( $runningtime) );
     2112                        }
     2113
     2114                        if( !isset( $this->headerstrlen['name'] ) )
     2115                        {
     2116                                $this->headerstrlen['name']     = strlen( strval( $jobinfo['name'] ) );
     2117                        }
     2118                        else if( strlen( strval( $jobinfo['name'] ) ) > $this->headerstrlen['name'] )
     2119                        {
     2120                                $this->headerstrlen['name']     = strlen( strval( $jobinfo['name'] ) );
    21212121                        }
    21222122                }
Note: See TracChangeset for help on using the changeset viewer.