Changeset 650 for branches/0.3
- Timestamp:
- 02/03/10 12:57:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.3/web/addons/job_monarch/libtoga.php
r531 r650 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; … … 607 607 foreach( $this->jobs as $jobid=>$jobattrs ) 608 608 { 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; 611 611 $mycpus = $nodes * $ppn; 612 612 … … 679 679 $nodes = $this->nodes; 680 680 681 if ( $attrs[ TN] )681 if ( $attrs['TN'] ) 682 682 { 683 683 // Ignore dead metrics. Detect and mask failures. 684 if ( $attrs[ TN] > $attrs[TMAX] * 4 )684 if ( $attrs['TN'] > $attrs['TMAX'] * 4 ) 685 685 { 686 686 return; … … 692 692 if( $name == 'CLUSTER' ) 693 693 { 694 $this->proc_cluster = $attrs[ NAME];694 $this->proc_cluster = $attrs['NAME']; 695 695 } 696 696 else if( $name == 'HOST' and $this->proc_cluster == $this->clustername) 697 697 { 698 $hostname = $attrs[ NAME];699 700 $location = $attrs[ LOCATION];698 $hostname = $attrs['NAME']; 699 700 $location = $attrs['LOCATION']; 701 701 702 702 if( !isset( $nodes[$hostname] ) ) … … 705 705 } 706 706 } 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'] ); 716 716 717 717 $nodes_down = array(); … … 747 747 } 748 748 } 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'] ); 752 752 753 753 $nodes_offline = array(); … … 783 783 } 784 784 } 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 ); 788 788 789 789 if( !isset( $jobs[$jobid] ) ) … … 792 792 } 793 793 794 $fields = explode( ' ', $attrs[ VAL] );794 $fields = explode( ' ', $attrs['VAL'] ); 795 795 796 796 foreach( $fields as $f ) … … 803 803 if( $toganame == 'nodes' ) 804 804 { 805 if( $jobs[$jobid][ status] == 'R' )805 if( $jobs[$jobid]['status'] == 'R' ) 806 806 { 807 807 if( !isset( $jobs[$jobid][$toganame] ) ) … … 821 821 822 822 } 823 else if( $jobs[$jobid][ status] == 'Q' )823 else if( $jobs[$jobid]['status'] == 'Q' ) 824 824 { 825 825 $jobs[$jobid][$toganame] = $togavalue; … … 832 832 } 833 833 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'] ); 837 837 838 if( $jobs[$jobid][ status] == 'R' )838 if( $jobs[$jobid]['status'] == 'R' ) 839 839 { 840 840 841 if( isset( $jobs[$jobid][ domain] ) )841 if( isset( $jobs[$jobid]['domain'] ) ) 842 842 { 843 $domain = $jobs[$jobid][ domain];843 $domain = $jobs[$jobid]['domain']; 844 844 $domain_len = 0 - strlen( $domain ); 845 845 … … 860 860 } 861 861 862 foreach( $jobs[$jobid][ nodes] as $node )862 foreach( $jobs[$jobid]['nodes'] as $node ) 863 863 { 864 864 865 865 // Only add domain name to the hostname if Ganglia is doing that too 866 866 // 867 if( $this->fqdn && isset( $jobs[$jobid][ domain] ) )867 if( $this->fqdn && isset( $jobs[$jobid]['domain'] ) ) 868 868 { 869 869 if( substr( $node, $domain_len ) != $domain ) … … 891 891 if( !$my_node->hasJob( $jobid ) ) 892 892 { 893 if( isset( $jobs[$jobid][ ppn] ) )893 if( isset( $jobs[$jobid]['ppn'] ) ) 894 894 { 895 $my_node->addJob( $jobid, ((int) $jobs[$jobid][ ppn]) );895 $my_node->addJob( $jobid, ((int) $jobs[$jobid]['ppn']) ); 896 896 } 897 897 else … … 983 983 printf( "job %s\n", $jobid ); 984 984 985 if( isset( $job[ nodes] ) )986 { 987 foreach( $job[ nodes] as $node )985 if( isset( $job['nodes'] ) ) 986 { 987 foreach( $job['nodes'] as $node ) 988 988 { 989 989 $mynode = $this->nodes[$node]; … … 1266 1266 global $metrics; 1267 1267 1268 $cpus = $metrics[$this->hostname][ cpu_num][VAL];1268 $cpus = $metrics[$this->hostname]['cpu_num']['VAL']; 1269 1269 1270 1270 if (!$cpus) … … 1280 1280 global $metrics; 1281 1281 1282 $load_one = $metrics[$this->hostname][ load_one][VAL];1282 $load_one = $metrics[$this->hostname]['load_one']['VAL']; 1283 1283 $load = ((float) $load_one)/$this->cpus; 1284 1284 … … 2009 2009 if( $headername == 'nodes' ) 2010 2010 { 2011 $attrval = strval( count( $jobinfo[ nodes] ) );2011 $attrval = strval( count( $jobinfo['nodes'] ) ); 2012 2012 } 2013 2013 else if( $headername == 'cpus' ) 2014 2014 { 2015 if( !isset( $jobinfo[ ppn] ) )2015 if( !isset( $jobinfo['ppn'] ) ) 2016 2016 { 2017 $jobinfo[ ppn] = 1;2017 $jobinfo['ppn'] = 1; 2018 2018 } 2019 2019 2020 $attrval = strval( count( $jobinfo[ nodes] ) * intval( $jobinfo[ppn] ) );2020 $attrval = strval( count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] ) ); 2021 2021 } 2022 2022 else if( $headername == 'runningtime' ) 2023 2023 { 2024 $attrval = makeTime( intval( $jobinfo[ reported] ) - intval( $jobinfo[start_timestamp] ) );2024 $attrval = makeTime( intval( $jobinfo['reported'] ) - intval( $jobinfo['start_timestamp'] ) ); 2025 2025 } 2026 2026 else … … 2047 2047 $jobinfo = $dg->getJob( $jobid ); 2048 2048 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'] ) ); 2121 2121 } 2122 2122 }
Note: See TracChangeset
for help on using the changeset viewer.