Changeset 577
- Timestamp:
- 02/03/09 17:04:28 (15 years ago)
- Location:
- trunk/web2/addons/job_monarch
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web2/addons/job_monarch/libtoga.php
r576 r577 236 236 237 237 $count_result = $this->queryDbase( $count_query ); 238 $this->resultcount = (int) $count_result[0][ count];238 $this->resultcount = (int) $count_result[0]['count']; 239 239 240 240 $select_query = "SELECT " . $select_result_idname . " " . $query . " ORDER BY job_id DESC LIMIT " . $SEARCH_RESULT_LIMIT; … … 247 247 foreach( $ids as $crow) 248 248 { 249 $ret[] = $crow[ job_id];249 $ret[] = $crow['job_id']; 250 250 } 251 251 … … 261 261 foreach( $result as $result_row ) 262 262 { 263 $nodes[] = $this->getNodeArray( $result_row[ node_id] );263 $nodes[] = $this->getNodeArray( $result_row['node_id'] ); 264 264 } 265 265 … … 275 275 foreach( $result as $result_row ) 276 276 { 277 $jobs[] = $this->getJobArray( $result_row[ job_id] );277 $jobs[] = $this->getJobArray( $result_row['job_id'] ); 278 278 } 279 279 return $jobs; … … 608 608 foreach( $this->jobs as $jobid=>$jobattrs ) 609 609 { 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; 612 612 $mycpus = $nodes * $ppn; 613 613 … … 653 653 $nodes = $this->nodes; 654 654 655 if ( $attrs[ TN] )655 if ( $attrs['TN'] ) 656 656 { 657 657 // Ignore dead metrics. Detect and mask failures. 658 if ( $attrs[ TN] > $attrs[TMAX] * 4 )658 if ( $attrs['TN'] > $attrs['TMAX'] * 4 ) 659 659 { 660 660 return; … … 666 666 if( $name == 'CLUSTER' ) 667 667 { 668 $this->proc_cluster = $attrs[ NAME];668 $this->proc_cluster = $attrs['NAME']; 669 669 } 670 670 else if( $name == 'HOST' and $this->proc_cluster == $this->clustername) 671 671 { 672 $hostname = $attrs[ NAME];672 $hostname = $attrs['NAME']; 673 673 674 674 // Assume to use FQDN if we find a '.' in the hostname … … 691 691 } 692 692 693 $location = $attrs[ LOCATION];693 $location = $attrs['LOCATION']; 694 694 695 695 if( !isset( $nodes[$hostname] ) ) … … 698 698 } 699 699 } 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'] ); 709 709 710 710 $nodes_down = array(); … … 746 746 } 747 747 } 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'] ); 751 751 752 752 $nodes_offline = array(); … … 788 788 } 789 789 } 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 ); 793 793 794 794 if( !isset( $jobs[$jobid] ) ) … … 797 797 } 798 798 799 $fields = explode( ' ', $attrs[ VAL] );799 $fields = explode( ' ', $attrs['VAL'] ); 800 800 801 801 foreach( $fields as $f ) … … 808 808 if( $toganame == 'nodes' ) 809 809 { 810 if( $jobs[$jobid][ status] == 'R' )810 if( $jobs[$jobid]['status'] == 'R' ) 811 811 { 812 812 if( !isset( $jobs[$jobid][$toganame] ) ) … … 826 826 827 827 } 828 else if( $jobs[$jobid][ status] == 'Q' )828 else if( $jobs[$jobid]['status'] == 'Q' ) 829 829 { 830 830 $jobs[$jobid][$toganame] = $togavalue; … … 837 837 } 838 838 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'] ); 842 842 843 if( $jobs[$jobid][ status] == 'R' )843 if( $jobs[$jobid]['status'] == 'R' ) 844 844 { 845 if( isset( $jobs[$jobid][ domain] ) )845 if( isset( $jobs[$jobid]['domain'] ) ) 846 846 { 847 $domain = $jobs[$jobid][ domain];847 $domain = $jobs[$jobid]['domain']; 848 848 } 849 849 $job_nodes = array(); 850 850 851 foreach( $jobs[$jobid][ nodes] as $node )851 foreach( $jobs[$jobid]['nodes'] as $node ) 852 852 { 853 853 // Only add domain name to the hostname if Ganglia is doing that too … … 866 866 if( !$my_node->hasJob( $jobid ) ) 867 867 { 868 if( isset( $jobs[$jobid][ ppn] ) )868 if( isset( $jobs[$jobid]['ppn'] ) ) 869 869 { 870 $my_node->addJob( $jobid, ((int) $jobs[$jobid][ ppn]) );870 $my_node->addJob( $jobid, ((int) $jobs[$jobid]['ppn']) ); 871 871 } 872 872 else … … 879 879 $job_nodes[] = $host; 880 880 } 881 $jobs[$jobid][ nodes] = $job_nodes;881 $jobs[$jobid]['nodes'] = $job_nodes; 882 882 } 883 883 } … … 960 960 printf( "job %s\n", $jobid ); 961 961 962 if( isset( $job[ nodes] ) )963 { 964 foreach( $job[ nodes] as $node )962 if( isset( $job['nodes'] ) ) 963 { 964 foreach( $job['nodes'] as $node ) 965 965 { 966 966 $mynode = $this->nodes[$node]; … … 1326 1326 global $metrics; 1327 1327 1328 $cpus = $metrics[$this->hostname][cpu_num][ VAL];1328 $cpus = $metrics[$this->hostname][cpu_num]['VAL']; 1329 1329 1330 1330 if (!$cpus) … … 1340 1340 global $metrics; 1341 1341 1342 $load_one = $metrics[$this->hostname][load_one][ VAL];1342 $load_one = $metrics[$this->hostname][load_one]['VAL']; 1343 1343 $load = ((float) $load_one)/$this->cpus; 1344 1344 … … 2129 2129 if( $headername == 'nodes' ) 2130 2130 { 2131 $attrval = strval( count( $jobinfo[ nodes] ) );2131 $attrval = strval( count( $jobinfo['nodes'] ) ); 2132 2132 } 2133 2133 else if( $headername == 'cpus' ) 2134 2134 { 2135 if( !isset( $jobinfo[ ppn] ) )2135 if( !isset( $jobinfo['ppn'] ) ) 2136 2136 { 2137 $jobinfo[ ppn] = 1;2137 $jobinfo['ppn'] = 1; 2138 2138 } 2139 2139 2140 $attrval = strval( count( $jobinfo[ nodes] ) * intval( $jobinfo[ppn] ) );2140 $attrval = strval( count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] ) ); 2141 2141 } 2142 2142 else if( $headername == 'runningtime' ) 2143 2143 { 2144 $attrval = makeTime( intval( $jobinfo[ reported] ) - intval( $jobinfo[start_timestamp] ) );2144 $attrval = makeTime( intval( $jobinfo['reported'] ) - intval( $jobinfo['start_timestamp'] ) ); 2145 2145 } 2146 2146 else … … 2167 2167 $jobinfo = $dg->getJob( $jobid ); 2168 2168 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'] ) ); 2241 2241 } 2242 2242 }
Note: See TracChangeset
for help on using the changeset viewer.