Changeset 732
- Timestamp:
- 03/24/13 14:00:01 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/web/addons/job_monarch/overview.php
r731 r732 4 4 * This file is part of Jobmonarch 5 5 * 6 * Copyright (C) 2006 Ramon Bastiaans6 * Copyright (C) 2006-2013 Ramon Bastiaans 7 7 * 8 8 * Jobmonarch is free software; you can redistribute it and/or modify … … 34 34 } 35 35 36 $ds = new DataSource();37 $myxml_data 38 39 $data_gatherer 36 $ds = new DataSource(); 37 $myxml_data = $ds->getData(); 38 39 $data_gatherer = new DataGatherer( $clustername ); 40 40 $data_gatherer->parseXML( $myxml_data ); 41 41 42 $heartbeat 43 $jobs 44 $gnodes 45 $cpus 46 $use_fqdn 42 $heartbeat = $data_gatherer->getHeartbeat(); 43 $jobs = $data_gatherer->getJobs(); 44 $gnodes = $data_gatherer->getNodes(); 45 $cpus = $data_gatherer->getCpus(); 46 $use_fqdn = $data_gatherer->getUsingFQDN(); 47 47 48 48 function setupFilterSettings() … … 65 65 66 66 unset( $_SESSION["data"] ); 67 $_SESSION["data"] 68 69 $ic 67 $_SESSION["data"] = &$myxml_data; 68 69 $ic = new ClusterImage( $myxml_data, $clustername ); 70 70 71 71 $ic->setBig(); … … 101 101 function timeToEpoch( $time ) 102 102 { 103 $time_fields 103 $time_fields = explode( ':', $time ); 104 104 105 105 if( count( $time_fields ) == 3 ) 106 106 { 107 $hours 108 $minutes 109 $seconds 107 $hours = $time_fields[0]; 108 $minutes = $time_fields[1]; 109 $seconds = $time_fields[2]; 110 110 111 111 } 112 112 else if( count( $time_fields ) == 2 ) 113 113 { 114 $hours 115 $minutes 116 $seconds 114 $hours = 0; 115 $minutes = $time_fields[0]; 116 $seconds = $time_fields[1]; 117 117 118 118 } 119 119 else if( count( $time_fields ) == 1 ) 120 120 { 121 $hours 122 $minutes 123 $seconds 124 } 125 126 $myepoch 121 $hours = 0; 122 $minutes = 0; 123 $seconds = $time_fields[0]; 124 } 125 126 $myepoch = intval( $seconds + (intval( $minutes * 60 )) + (intval( $hours * 3600 )) ); 127 127 128 128 return $myepoch; … … 149 149 $min_diff = 50; 150 150 151 $c1r 152 $c1g 153 $c1b 154 155 $c2r 156 $c2g 157 $c2b 158 159 $rdiff 160 $gdiff 161 $bdiff 151 $c1r = hexDec( colorRed( $first ) ); 152 $c1g = hexDec( colorGreen( $first ) ); 153 $c1b = hexDec( colorBlue( $first ) ); 154 155 $c2r = hexDec( colorRed( $second ) ); 156 $c2g = hexDec( colorGreen( $second ) ); 157 $c2b = hexDec( colorBlue( $second ) ); 158 159 $rdiff = ($c1r >= $c2r) ? $c1r - $c2r : $c2r - $c1r; 160 $gdiff = ($c1g >= $c2g) ? $c1g - $c2g : $c2g - $c1g; 161 $bdiff = ($c1b >= $c2b) ? $c1b - $c2b : $c2b - $c1b; 162 162 163 163 if( $rdiff >= $min_diff or $gdiff >= $min_diff or $bdiff >= $min_diff ) … … 175 175 { 176 176 // White (000000) would be invisible 177 $start 177 $start = "004E00"; 178 178 179 $start_red 180 $start_green 181 $start_blue 179 $start_red = colorRed( $start ); 180 $start_green = colorGreen( $start ); 181 $start_blue = colorBlue( $start ); 182 182 183 $end = "FFFFFF";184 185 $end_red = colorRed( $end );186 $end_green 183 $end = "FFFFFF"; 184 185 $end_red = colorRed( $end ); 186 $end_green = colorGreen( $end ); 187 187 $end_blue = colorBlue( $end ); 188 188 189 $change_color 189 $change_color= TRUE; 190 190 191 191 while( $change_color ) 192 192 { 193 $change_color 193 $change_color= FALSE; 194 194 195 195 $new_red = rand( hexDec( $start_red ), hexDec( $end_red ) ); 196 $new_green 197 $new_blue 196 $new_green = rand( hexDec( $start_green ), hexDec( $end_green ) ); 197 $new_blue = rand( hexDec( $start_blue ), hexDec( $end_blue ) ); 198 198 199 199 $new = decHex( $new_red ) . decHex( $new_green ) . decHex( $new_blue ); … … 219 219 function drawQueuePie() { } 220 220 221 222 221 function drawPie() 223 222 { 224 223 global $jobs, $gnodes, $piefilter, $filter, $metrics; 225 224 226 $nodes 225 $nodes = $gnodes; 227 226 228 227 if( isset($piefilter) ) 229 228 { 230 $pie_args 229 $pie_args = "title=" . rawurlencode("Cluster ".$piefilter." usage"); 231 230 } 232 231 else 233 232 { 234 $pie_args 235 } 236 237 $pie_args 238 239 $queues 240 $nr_jobs 241 $nr_nodes 242 243 $nr_cpus 244 245 $empty_cpus 246 $used_cpus 247 248 $job_weight 233 $pie_args = "title=" . rawurlencode("Cluster queue usage"); 234 } 235 236 $pie_args .= "&size=250x150"; 237 238 $queues = array(); 239 $nr_jobs = count( $jobs ); 240 $nr_nodes = count( $nodes ); 241 242 $nr_cpus = cluster_sum("cpu_num", $metrics); 243 244 $empty_cpus= 0; 245 $used_cpus = 0; 246 247 $job_weight= array(); 249 248 250 249 foreach( $nodes as $node ) 251 250 { 252 $myjobs 253 $myhost 254 $node_cpus 255 $job_cpu 251 $myjobs = $node->getJobs(); 252 $myhost = $node->getHostname(); 253 $node_cpus = $metrics[$myhost]["cpu_num"]['VAL']; 254 $job_cpu = 0; 256 255 257 256 foreach( $myjobs as $myjob ) 258 257 { 259 $job_cpu 258 $job_cpu += isset( $jobs[$myjob]['ppn'] ) ? $jobs[$myjob]['ppn'] : 1; 260 259 } 261 260 262 $node_freecpu 263 264 $empty_cpus 265 } 266 267 $empty_cpus 268 $used_cpus 269 270 $empty_percentage 271 272 $qcolors 273 $color 274 $qcolors[] 275 $pie_args 261 $node_freecpu= $node_cpus - $job_cpu; 262 263 $empty_cpus += $node_freecpu; 264 } 265 266 $empty_cpus = ( $empty_cpus >= 0 ) ? $empty_cpus : 0; 267 $used_cpus = $nr_cpus - $empty_cpus; 268 269 $empty_percentage= $empty_cpus; 270 271 $qcolors = array(); 272 $color = randomColor( $qcolors ); 273 $qcolors[] = $color; 274 $pie_args .= "&free=$empty_percentage,$color"; 276 275 277 276 if( isset( $piefilter ) ) … … 282 281 foreach( $nodes as $node ) 283 282 { 284 $node_jobs 285 $nr_node_jobs 286 $myhost = $node->getHostname();283 $node_jobs = $node->getJobs(); 284 $nr_node_jobs = count( $node_jobs ); 285 $myhost = $node->getHostname(); 287 286 $node_cpus = $metrics[$myhost]["cpu_num"]['VAL']; 288 287 289 288 foreach( $node_jobs as $myjob ) 290 289 { 291 $job_cpu 290 $job_cpu = isset( $jobs[$myjob]['ppn'] ) ? $jobs[$myjob]['ppn'] : 1; 292 291 293 292 // Determine the weight of this job … … 353 352 { 354 353 355 $qname 354 $qname = $jobs[$myjob]['queue']; 356 355 357 356 if( !isset( $queues[$qname] ) ) … … 378 377 foreach( $graphvals as $name => $totalweight) 379 378 { 380 $percentage 379 $percentage = $totalweight; 381 380 382 381 $color = randomColor( $qcolors ); … … 408 407 foreach( $jobs as $jobid => $jobattrs ) 409 408 { 410 $state 411 $owner 412 $queue 413 $name 414 $req_cpu 415 $req_memory 409 $state = $jobattrs['status']; 410 $owner = $jobattrs['owner']; 411 $queue = $jobattrs['queue']; 412 $name = $jobattrs['name']; 413 $req_cpu = $jobattrs['requested_time']; 414 $req_memory= $jobattrs['requested_memory']; 416 415 417 416 if( $state == 'R' ) … … 519 518 $tpl->assign("sortby", $sortby ); 520 519 521 $sorted_jobs 522 523 $even = 1;524 525 $used_jobs = 0;526 $used_cpus = 0;520 $sorted_jobs = sortJobs( $jobs, $sortby, $sortorder ); 521 522 $even = 1; 523 524 $used_jobs = 0; 525 $used_cpus = 0; 527 526 $used_nodes = 0; 528 527 529 $queued_jobs 530 $queued_nodes 531 $queued_cpus 532 533 $total_nodes 528 $queued_jobs = 0; 529 $queued_nodes = 0; 530 $queued_cpus = 0; 531 532 $total_nodes = 0; 534 533 $total_cpus = 0; 535 534 $total_jobs = 0; 536 535 537 536 $all_used_nodes = array(); 538 $total_used_nodes 539 540 $running_name_nodes 541 542 $running_nodes 543 $running_jobs 544 $running_cpus 545 546 $avail_nodes 537 $total_used_nodes = array(); 538 539 $running_name_nodes = array(); 540 541 $running_nodes = 0; 542 $running_jobs = 0; 543 $running_cpus = 0; 544 545 $avail_nodes = count( $gnodes ); 547 546 $avail_cpus = cluster_sum("cpu_num", $metrics); 548 547 549 $view_cpus = 0;550 $view_jobs = 0;548 $view_cpus = 0; 549 $view_jobs = 0; 551 550 $view_nodes = 0; 552 551 553 $all_nodes = 0;554 $all_jobs = 0;555 $all_cpus = 0;556 557 $view_name_nodes 552 $all_nodes = 0; 553 $all_jobs = 0; 554 $all_cpus = 0; 555 556 $view_name_nodes = array(); 558 557 559 558 // Is the "requested memory" column enabled in the config … … 578 577 } 579 578 580 $last_displayed_job 581 582 $rjqj_host 583 584 $na_nodes 585 $na_cpus 579 $last_displayed_job = null; 580 581 $rjqj_host = null; 582 583 $na_nodes = 0; 584 $na_cpus = 0; 586 585 587 586 foreach( $metrics as $bhost => $bmetric ) … … 591 590 if( ( $mname == 'zplugin_monarch_rj' ) || ($mname == 'zplugin_monarch_qj') ) 592 591 { 593 $rjqj_host 592 $rjqj_host = $bhost; 594 593 } 595 594 } … … 600 599 if( $gnode->isDown() || $gnode->isOffline() ) 601 600 { 602 $na_nodes 603 $na_cpus 601 $na_nodes += 1; 602 $na_cpus += $metrics[$ghost]['cpu_num']['VAL']; 604 603 } 605 604 } … … 632 631 } 633 632 634 $ppn 635 $cpus 633 $ppn = isset( $jobs[$jobid]['ppn'] ) ? $jobs[$jobid]['ppn'] : 1; 634 $cpus = $nodes * $ppn; 636 635 637 636 if( $report_time == $heartbeat ) … … 694 693 } 695 694 696 $queued_cpus 697 $queued_nodes 695 $queued_cpus += $cpus; 696 $queued_nodes += $nodes; 698 697 699 698 $queued_jobs++; … … 804 803 } 805 804 806 $ppn 807 $cpus 805 $ppn = isset( $jobs[$jobid]['ppn'] ) ? $jobs[$jobid]['ppn'] : 1; 806 $cpus = $nodes * $ppn; 808 807 809 808 $tpl->assign( "nodes", $nodes ); 810 809 $tpl->assign( "cpus", $cpus ); 811 810 812 $start_time 813 $job_start 814 815 $view_cpus 811 $start_time= (int) $jobs[$jobid]['start_timestamp']; 812 $job_start = $start_time; 813 814 $view_cpus += $cpus; 816 815 817 816 $view_jobs++; … … 834 833 if( $use_fqdn == 1) 835 834 { 836 $mynode = $shortnode.".".$jobs[$jobid]['domain'];835 $mynode = $shortnode.".".$jobs[$jobid]['domain']; 837 836 } 838 $myhost_href 839 $mynodehosts[] 837 $myhost_href = "./?c=".$clustername."&h=".$mynode; 838 $mynodehosts[] = "<A HREF=\"".$myhost_href."\">".$shortnode."</A>"; 840 839 } 841 840 842 $nodes_hostnames 841 $nodes_hostnames = implode( " ", $mynodehosts ); 843 842 844 843 $tpl->assign( "nodes_hostnames", $nodes_hostnames ); … … 866 865 if( $start_time ) 867 866 { 868 $runningtime 867 $runningtime = makeTime( $report_time - $start_time ); 869 868 $job_runningtime = $heartbeat - $start_time; 870 869 … … 877 876 878 877 $all_used_nodes = array_unique( $all_used_nodes ); 879 $view_name_nodes 880 $running_name_nodes 878 $view_name_nodes = array_unique( $view_name_nodes ); 879 $running_name_nodes = array_unique( $running_name_nodes ); 881 880 882 881 $used_nodes = count( $all_used_nodes ); 883 $view_nodes 884 $running_nodes 885 886 $total_nodes 882 $view_nodes += count( $view_name_nodes ); 883 $running_nodes += count( $running_name_nodes ); 884 885 $total_nodes = $queued_nodes + $running_nodes; 887 886 $total_cpus = $queued_cpus + $running_cpus; 888 887 $total_jobs = $queued_jobs + $running_jobs; 889 888 890 889 $free_nodes = $avail_nodes - $running_nodes - $na_nodes; 891 $free_nodes = ( $free_nodes >= 0 ) ? $free_nodes : 0;892 $free_cpus = $avail_cpus - $running_cpus - $na_cpus;893 $free_cpus = ( $free_cpus >= 0 ) ? $free_cpus : 0;890 $free_nodes = ( $free_nodes >= 0 ) ? $free_nodes : 0; 891 $free_cpus = $avail_cpus - $running_cpus - $na_cpus; 892 $free_cpus = ( $free_cpus >= 0 ) ? $free_cpus : 0; 894 893 895 894 $tpl->assignGlobal( "avail_nodes", $avail_nodes );
Note: See TracChangeset
for help on using the changeset viewer.