Ticket #68: jobmonarch-arrays.patch

File jobmonarch-arrays.patch, 12.8 KB (added by felix@…, 15 years ago)

just some sed to quote named arrays

  • addons/job_monarch/index.php

    diff -u web/addons/job_monarch/index.php /var/www/html/ganglia/addons/job_monarch/index.php
    old new  
    119119        $header = "header";
    120120
    121121        # Maintain our path through the grid tree.
    122         $me = $self . "@" . $grid[$self][AUTHORITY];
     122        $me = $self . "@" . $grid[$self]['AUTHORITY'];
    123123
    124124        $gridstack = array();
    125125        $gridstack[] = $me;
  • addons/job_monarch/libtoga.php

    diff -u web/addons/job_monarch/libtoga.php /var/www/html/ganglia/addons/job_monarch/libtoga.php
    old new  
    235235                        $count_query = "SELECT " . $count_result_idname . " " . $query;
    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;
    241241                }
     
    606606                {
    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
    613613                                $cpus   = $cpus + $mycpus;
     
    678678                $jobs = $this->jobs;
    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;
    687687                        }
     
    691691
    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];
     698                        $hostname = $attrs['NAME'];
    699699
    700                         $location = $attrs[LOCATION];
     700                        $location = $attrs['LOCATION'];
    701701
    702702                        if( !isset( $nodes[$hostname] ) )
    703703                        {
    704704                                $nodes[$hostname] = new NodeImage( $this->proc_cluster, $hostname );
    705705                        }
    706706                }
    707                 else if( $name == 'METRIC' and strstr( $attrs[NAME], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
     707                else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
    708708                {
    709                         if( strstr( $attrs[NAME], 'MONARCH-HEARTBEAT' ) )
     709                        if( strstr( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) )
    710710                        {
    711                                 $this->heartbeat['time'] = $attrs[VAL];
     711                                $this->heartbeat['time'] = $attrs['VAL'];
    712712                        }
    713                         else if( strstr( $attrs[NAME], 'MONARCH-DOWN' ) )
     713                        else if( strstr( $attrs['NAME'], 'MONARCH-DOWN' ) )
    714714                        {
    715                                 $fields         = explode( ' ', $attrs[VAL] );
     715                                $fields         = explode( ' ', $attrs['VAL'] );
    716716
    717717                                $nodes_down     = array();
    718718                                $down_domain    = null;
     
    746746                                        }
    747747                                }
    748748                        }
    749                         else if( strstr( $attrs[NAME], 'MONARCH-OFFLINE' ) )
     749                        else if( strstr( $attrs['NAME'], 'MONARCH-OFFLINE' ) )
    750750                        {
    751                                 $fields         = explode( ' ', $attrs[VAL] );
     751                                $fields         = explode( ' ', $attrs['VAL'] );
    752752
    753753                                $nodes_offline  = array();
    754754                                $offline_domain = null;
     
    782782                                        }
    783783                                }
    784784                        }
    785                         else if( strstr( $attrs[NAME], 'MONARCH-JOB' ) )
     785                        else if( strstr( $attrs['NAME'], 'MONARCH-JOB' ) )
    786786                        {
    787                                 sscanf( $attrs[NAME], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
     787                                sscanf( $attrs['NAME'], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
    788788
    789789                                if( !isset( $jobs[$jobid] ) )
    790790                                {
    791791                                        $jobs[$jobid] = array();
    792792                                }
    793793
    794                                 $fields = explode( ' ', $attrs[VAL] );
     794                                $fields = explode( ' ', $attrs['VAL'] );
    795795
    796796                                foreach( $fields as $f )
    797797                                {
     
    802802
    803803                                        if( $toganame == 'nodes' )
    804804                                        {
    805                                                 if( $jobs[$jobid][status] == 'R' )
     805                                                if( $jobs[$jobid]['status'] == 'R' )
    806806                                                {
    807807                                                        if( !isset( $jobs[$jobid][$toganame] ) )
    808808                                                        {
     
    820820                                                        }
    821821
    822822                                                }
    823                                                 else if( $jobs[$jobid][status] == 'Q' )
     823                                                else if( $jobs[$jobid]['status'] == 'Q' )
    824824                                                {
    825825                                                        $jobs[$jobid][$toganame] = $togavalue;
    826826                                                }
     
    831831                                        }
    832832                                }
    833833
    834                                 if( isset( $jobs[$jobid][nodes] ) )
     834                                if( isset( $jobs[$jobid]['nodes'] ) )
    835835                                {
    836                                         $nr_nodes = count( $jobs[$jobid][nodes] );
     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
    846846                                                        // Let's see if Ganglia use's FQDN or short hostnames
     
    859859                                                        $this->fqdn     = 0;
    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 )
    870870                                                                {
     
    890890
    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
    898898                                                                {
     
    982982                {
    983983                        printf( "job %s\n", $jobid );
    984984
    985                         if( isset( $job[nodes] ) )
     985                        if( isset( $job['nodes'] ) )
    986986                        {
    987                                 foreach( $job[nodes] as $node )
     987                                foreach( $job['nodes'] as $node )
    988988                                {
    989989                                        $mynode = $this->nodes[$node];
    990990                                        $hostname = $mynode->getHostname();
     
    12651265        {
    12661266                global $metrics;
    12671267
    1268                 $cpus = $metrics[$this->hostname][cpu_num][VAL];
     1268                $cpus = $metrics[$this->hostname]['cpu_num']['VAL'];
    12691269
    12701270                if (!$cpus)
    12711271                {
     
    12791279        {
    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
    12851285                return $load;
     
    20082008                        {
    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
    20272027                                {
     
    20462046                        $jobid                  = $this->njobs[$n];
    20472047                        $jobinfo                = $dg->getJob( $jobid );
    20482048
    2049                         if( !isset( $this->headerstrlen[id] ) )
     2049                        if( !isset( $this->headerstrlen['id'] ) )
    20502050                        {
    2051                                 $this->headerstrlen[id] = strlen( strval( $jobid ) );
     2051                                $this->headerstrlen['id']       = strlen( strval( $jobid ) );
    20522052                        }
    2053                         else if( strlen( strval( $jobid ) ) > $this->headerstrlen[id] )
     2053                        else if( strlen( strval( $jobid ) ) > $this->headerstrlen['id'] )
    20542054                        {
    2055                                 $this->headerstrlen[id] = strlen( strval( $jobid ) );
     2055                                $this->headerstrlen['id']       = strlen( strval( $jobid ) );
    20562056                        }
    20572057
    2058                         if( !isset( $this->headerstrlen[owner] ) )
     2058                        if( !isset( $this->headerstrlen['owner'] ) )
    20592059                        {
    2060                                 $this->headerstrlen[owner]      = strlen( strval( $jobinfo[owner] ) );
     2060                                $this->headerstrlen['owner']    = strlen( strval( $jobinfo['owner'] ) );
    20612061                        }
    2062                         else if( strlen( strval( $jobinfo[owner] ) ) > $this->headerstrlen[owner] )
     2062                        else if( strlen( strval( $jobinfo['owner'] ) ) > $this->headerstrlen['owner'] )
    20632063                        {
    2064                                 $this->headerstrlen[owner]      = strlen( strval( $jobinfo[owner] ) );
     2064                                $this->headerstrlen['owner']    = strlen( strval( $jobinfo['owner'] ) );
    20652065                        }
    20662066
    2067                         if( !isset( $this->headerstrlen[queue] ) )
     2067                        if( !isset( $this->headerstrlen['queue'] ) )
    20682068                        {
    2069                                 $this->headerstrlen[queue]      = strlen( strval( $jobinfo[queue] ) );
     2069                                $this->headerstrlen['queue']    = strlen( strval( $jobinfo['queue'] ) );
    20702070                        }
    2071                         else if( strlen( strval( $jobinfo[queue] ) ) > $this->headerstrlen[queue] )
     2071                        else if( strlen( strval( $jobinfo['queue'] ) ) > $this->headerstrlen['queue'] )
    20722072                        {
    2073                                 $this->headerstrlen[queue]      = strlen( strval( $jobinfo[queue] ) );
     2073                                $this->headerstrlen['queue']    = strlen( strval( $jobinfo['queue'] ) );
    20742074                        }
    20752075
    2076                         if( !isset( $jobinfo[ppn] ) )
     2076                        if( !isset( $jobinfo['ppn'] ) )
    20772077                        {
    2078                                 $jobinfo[ppn] = 1;
     2078                                $jobinfo['ppn'] = 1;
    20792079                        }
    20802080
    2081                         $cpus                   = count( $jobinfo[nodes] ) * intval( $jobinfo[ppn] );
     2081                        $cpus                   = count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] );
    20822082
    2083                         if( !isset( $this->headerstrlen[cpus] ) )
     2083                        if( !isset( $this->headerstrlen['cpus'] ) )
    20842084                        {
    2085                                 $this->headerstrlen[cpus]       = strlen( strval( $cpus ) );
     2085                                $this->headerstrlen['cpus']     = strlen( strval( $cpus ) );
    20862086                        }
    2087                         else if( strlen( strval( $cpus ) ) > $this->headerstrlen[cpus] )
     2087                        else if( strlen( strval( $cpus ) ) > $this->headerstrlen['cpus'] )
    20882088                        {
    2089                                 $this->headerstrlen[cpus]       = strlen( strval( $cpus ) );
     2089                                $this->headerstrlen['cpus']     = strlen( strval( $cpus ) );
    20902090                        }
    20912091
    2092                         $nodes                  = count( $jobinfo[nodes] );
     2092                        $nodes                  = count( $jobinfo['nodes'] );
    20932093
    2094                         if( !isset( $this->headerstrlen[nodes] ) )
     2094                        if( !isset( $this->headerstrlen['nodes'] ) )
    20952095                        {
    2096                                 $this->headerstrlen[nodes]      = strlen( strval( $nodes ) );
     2096                                $this->headerstrlen['nodes']    = strlen( strval( $nodes ) );
    20972097                        }
    2098                         else if( strlen( strval( $nodes) ) > $this->headerstrlen[nodes] )
     2098                        else if( strlen( strval( $nodes) ) > $this->headerstrlen['nodes'] )
    20992099                        {
    2100                                 $this->headerstrlen[nodes]      = strlen( strval( $nodes ) );
     2100                                $this->headerstrlen['nodes']    = strlen( strval( $nodes ) );
    21012101                        }
    21022102
    2103                         $runningtime            = makeTime( intval( $jobinfo[reported] ) - intval( $jobinfo[start_timestamp] ) );
     2103                        $runningtime            = makeTime( intval( $jobinfo['reported'] ) - intval( $jobinfo[start_timestamp] ) );
    21042104
    2105                         if( !isset( $this->headerstrlen[runningtime] ) )
     2105                        if( !isset( $this->headerstrlen['runningtime'] ) )
    21062106                        {
    2107                                 $this->headerstrlen[runningtime]        = strlen( strval( $runningtime) );
     2107                                $this->headerstrlen['runningtime']      = strlen( strval( $runningtime) );
    21082108                        }
    2109                         else if( strlen( strval( $runningtime) ) > $this->headerstrlen[runningtime] )
     2109                        else if( strlen( strval( $runningtime) ) > $this->headerstrlen['runningtime'] )
    21102110                        {
    2111                                 $this->headerstrlen[runningtime]        = strlen( strval( $runningtime) );
     2111                                $this->headerstrlen['runningtime']      = strlen( strval( $runningtime) );
    21122112                        }
    21132113
    2114                         if( !isset( $this->headerstrlen[name] ) )
     2114                        if( !isset( $this->headerstrlen['name'] ) )
    21152115                        {
    2116                                 $this->headerstrlen[name]       = strlen( strval( $jobinfo[name] ) );
     2116                                $this->headerstrlen['name']     = strlen( strval( $jobinfo['name'] ) );
    21172117                        }
    2118                         else if( strlen( strval( $jobinfo[name] ) ) > $this->headerstrlen[name] )
     2118                        else if( strlen( strval( $jobinfo['name'] ) ) > $this->headerstrlen['name'] )
    21192119                        {
    2120                                 $this->headerstrlen[name]       = strlen( strval( $jobinfo[name] ) );
     2120                                $this->headerstrlen['name']     = strlen( strval( $jobinfo['name'] ) );
    21212121                        }
    21222122                }
    21232123
  • addons/job_monarch/overview.php

    diff -u web/addons/job_monarch/overview.php /var/www/html/ganglia/addons/job_monarch/overview.php
    old new  
    257257        {
    258258                $myjobs         = $node->getJobs();
    259259                $myhost         = $node->getHostname();
    260                 $node_cpus      = $metrics[$myhost]["cpu_num"][VAL];
     260                $node_cpus      = $metrics[$myhost]['cpu_num']['VAL'];
    261261                $job_cpu        = 0;
    262262
    263263                foreach( $myjobs as $myjob )
    264264                {
    265                         $job_cpu        += (int) $jobs[$myjob][ppn] ? $jobs[$myjob][ppn] : 1;
     265                        $job_cpu        += (int) $jobs[$myjob]['ppn'] ? $jobs[$myjob]['ppn'] : 1;
    266266                }
    267267
    268268                $node_freecpu   = $node_cpus - $job_cpu;
     
    291291                $node_jobs      = $node->getJobs();
    292292                $nr_node_jobs   = count( $node_jobs );
    293293                $myhost         = $node->getHostname();
    294                 $node_cpus      = $metrics[$myhost]["cpu_num"][VAL];
     294                $node_cpus      = $metrics[$myhost]['cpu_num']['VAL'];
    295295
    296296                foreach( $node_jobs as $myjob )
    297297                {
    298                         $job_cpu                = (int) $jobs[$myjob][ppn] ? $jobs[$myjob][ppn] : 1;
     298                        $job_cpu                = (int) $jobs[$myjob]['ppn'] ? $jobs[$myjob]['ppn'] : 1;
    299299
    300300                        // Determine the weight of this job
    301301                        // - what percentage of the cpus is in use by this job
     
    316316                                }
    317317                                else if( $piefilter == 'user' )
    318318                                {
    319                                         if( $jobs[$myjob][owner] != $filter[$piefilter] )
     319                                        if( $jobs[$myjob]['owner'] != $filter[$piefilter] )
    320320                                        {
    321321                                                $countjob = 0;
    322322                                        }