- Timestamp:
- 04/18/07 11:11:43 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/job_monarch/overview.php
r311 r315 182 182 function drawPie() { 183 183 184 global $jobs, $gnodes, $piefilter, $filter ;185 186 $nodes = $gnodes;184 global $jobs, $gnodes, $piefilter, $filter, $metrics; 185 186 $nodes = $gnodes; 187 187 188 188 if( isset($piefilter) ) 189 $pie_args 189 $pie_args = "title=" . rawurlencode("Cluster ".$piefilter." usage"); 190 190 else 191 $pie_args = "title=" . rawurlencode("Cluster queue usage");191 $pie_args = "title=" . rawurlencode("Cluster queue usage"); 192 192 193 $pie_args .= "&size=250x150"; 194 195 $queues = array(); 196 $nr_jobs = count( $jobs ); 197 $nr_nodes = count( $nodes ); 198 199 $emptynodes = 0; 200 201 $job_weight = array(); 193 $pie_args .= "&size=250x150"; 194 195 $queues = array(); 196 $nr_jobs = count( $jobs ); 197 $nr_nodes = count( $nodes ); 198 199 $nr_cpus = cluster_sum("cpu_num", $metrics); 200 201 $empty_cpus = 0; 202 $used_cpus = 0; 203 204 $job_weight = array(); 202 205 203 206 foreach( $nodes as $node ) { 204 207 205 $myjobs = $node->getJobs(); 206 207 if( count( $myjobs ) == 0 ) 208 $emptynodes++; 209 } 210 $used_nodes = $nr_nodes - $emptynodes; 211 212 $empty_percentage = ($emptynodes / $nr_nodes) * 100; 213 $job_percentage = 100 - $empty_percentage; 214 215 $qcolors = array(); 216 $color = randomColor( $qcolors ); 217 $qcolors[] = $color; 218 $pie_args .= "&free=$empty_percentage,$color"; 208 $myjobs = $node->getJobs(); 209 $myhost = $node->getHostname(); 210 $node_cpus = $metrics[$myhost]["cpu_num"][VAL]; 211 $job_cpu = 0; 212 213 foreach( $myjobs as $myjob ) { 214 215 $job_cpu += (int) $jobs[$myjob][ppn] ? $jobs[$myjob][ppn] : 1; 216 } 217 218 $node_freecpu = $node_cpus - $job_cpu; 219 220 $empty_cpus += $node_freecpu; 221 } 222 223 $used_cpus = $nr_cpus - $empty_cpus; 224 225 $empty_percentage = ($empty_cpus / $nr_cpus) * 100; 226 227 $qcolors = array(); 228 $color = randomColor( $qcolors ); 229 $qcolors[] = $color; 230 $pie_args .= "&free=$empty_percentage,$color"; 219 231 220 232 if( isset( $piefilter ) ) … … 223 235 foreach( $nodes as $node ) { 224 236 225 $node_jobs = $node->getJobs(); 226 $nr_node_jobs = count( $node_jobs ); 227 $myhost = $node->getHostname(); 237 $node_jobs = $node->getJobs(); 238 $nr_node_jobs = count( $node_jobs ); 239 $myhost = $node->getHostname(); 240 $node_cpus = $metrics[$myhost]["cpu_num"][VAL]; 228 241 229 242 foreach( $node_jobs as $myjob ) { 230 243 231 // Determine the weight of this job on the node it is running 232 // - what percentage of the node is in use by this job 244 $job_cpu = (int) $jobs[$myjob][ppn] ? $jobs[$myjob][ppn] : 1; 245 246 // Determine the weight of this job 247 // - what percentage of the cpus is in use by this job 233 248 // 234 $job_weight[$myjob] = ( 100 / count( $node_jobs ) ) / 100;235 $qname = $jobs[$myjob][queue]; 249 $job_weight[$myjob] = ( $job_cpu / $nr_cpus ); 250 236 251 237 252 if( isset($piefilter) ) { … … 264 279 } else { 265 280 281 $qname = $jobs[$myjob][queue]; 282 266 283 if( !isset( $queues[$qname] ) ) 267 284 $queues[$qname] = $job_weight[$myjob]; … … 272 289 } 273 290 274 //$qcolors = array();275 291 if( isset( $piefilter ) ) 276 292 $graphvals = $filterpie; … … 280 296 foreach( $graphvals as $name => $totalweight) { 281 297 282 $percentage = ( $totalweight / $used_nodes ) * $job_percentage;298 $percentage = ( $totalweight * 100 ); 283 299 284 $color = randomColor( $qcolors );285 $qcolors[] = $color;286 $pie_args .= "&$name=$percentage,$color";300 $color = randomColor( $qcolors ); 301 $qcolors[] = $color; 302 $pie_args .= "&$name=$percentage,$color"; 287 303 } 288 304 $pie = "../../pie.php?$pie_args";
Note: See TracChangeset
for help on using the changeset viewer.