- Timestamp:
- 05/31/05 16:13:43 (18 years ago)
- Location:
- trunk/web/addons/toga
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/image.php
r114 r117 2 2 include_once "./libtoga.php"; 3 3 4 $httpvars = new HTTPVariables( $HTTP_GET_VARS );4 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); 5 5 $view = $httpvars->getHttpVar( "view" ); 6 6 $clustername = $httpvars->getClusterName(); -
trunk/web/addons/toga/index.php
r113 r117 1 1 <?php 2 2 3 if ( !empty( $_GET ) ) { 4 extract( $_GET ); 5 } 6 3 7 $my_dir = getcwd(); 4 8 5 9 include_once "./libtoga.php"; 6 10 7 global $GANGLIA_PATH , $context;11 global $GANGLIA_PATH; 8 12 chdir( $GANGLIA_PATH ); 9 $context = 'cluster'; 10 11 $title = "Torque Report"; 12 include_once "./get_context.php"; 13 13 14 include_once "./class.TemplatePower.inc.php"; 14 15 chdir( $my_dir ); 15 include_once "header.php"; 16 17 include_once "overview.php"; 18 19 include_once "footer.php"; 16 17 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); 18 $clustername = $httpvars->getClusterName(); 19 $view = $httpvars->getHttpVar( "view" ); 20 21 if( !isset($view) ) $view = "overview"; 22 if( !isset($sortorder) ) $sortorder = "asc"; 23 if( !isset($sortby) ) $sortby = "id"; 24 25 function makeHeader() { 26 27 global $tpl, $grid, $context, $initgrid; 28 global $jobrange, $jobstart, $title; 29 global $page, $gridwalk, $clustername; 30 global $parentgrid, $physical, $hostname; 31 global $self; 32 33 if ( $context == "control" && $controlroom < 0 ) 34 $header = "header-nobanner"; 35 else 36 $header = "header"; 37 38 # Maintain our path through the grid tree. 39 $me = $self . "@" . $grid[$self][AUTHORITY]; 40 41 if ($initgrid) { 42 $gridstack = array(); 43 $gridstack[] = $me; 44 } else if ($gridwalk=="fwd") { 45 # push our info on gridstack, format is "name@url>name2@url". 46 if (end($gridstack) != $me) { 47 $gridstack[] = $me; 48 } 49 } else if ($gridwalk=="back") { 50 # pop a single grid off stack. 51 if (end($gridstack) != $me) { 52 array_pop($gridstack); 53 } 54 } 55 56 $gridstack_str = join(">", $gridstack); 57 $gridstack_url = rawurlencode($gridstack_str); 58 59 if ($initgrid or $gridwalk) { 60 # Use cookie so we dont have to pass gridstack around within this site. 61 # Cookie values are automatically urlencoded. Expires in a day. 62 setcookie("gs", $gridstack_str, time() + 86400); 63 } 64 65 # Invariant: back pointer is second-to-last element of gridstack. Grid stack never 66 # has duplicate entries. 67 list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]); 68 69 # Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell 70 # destination server that we're walking foward in the grid tree. 71 if (strstr($clustername, "http://")) { 72 $tpl->assign("refresh", "0"); 73 $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url"); 74 echo "<h2>Redirecting, please wait...</h2>"; 75 $tpl->printToScreen(); 76 exit; 77 } 78 79 $tpl->assign( "refresh", $default_refresh ); 80 $tpl->assign( "date", date("r") ); 81 $tpl->assign( "page_title", $title ); 82 83 # The page to go to when "Get Fresh Data" is pressed. 84 if (isset($page)) 85 $tpl->assign("page",$page); 86 else 87 $tpl->assign("page","./"); 88 89 # Templated Logo image 90 $tpl->assign("images","./templates/$template_name/images"); 91 92 # 93 # Used when making graphs via graph.php. Included in most URLs 94 # 95 $sort_url=rawurlencode($sort); 96 $get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols"; 97 98 if ($jobrange and $jobstart) 99 $get_metric_string .= "&jr=$jobrange&js=$jobstart"; 100 101 # Set the Alternate view link. 102 $cluster_url=rawurlencode($clustername); 103 $node_url=rawurlencode($hostname); 104 105 # Make some information available to templates. 106 $tpl->assign("cluster_url", $cluster_url); 107 # Build the node_menu 108 $node_menu = ""; 109 110 if ($parentgrid) { 111 $node_menu .= "<B>$parentgrid $meta_designator</B> "; 112 $node_menu .= "<B>></B>\n"; 113 } 114 115 # Show grid. 116 $mygrid = ($self == "unspecified") ? "" : $self; 117 $node_menu .= "<B>$mygrid $meta_designator</A> "; 118 $node_menu .= "<B>></B>\n"; 119 120 if ($physical) 121 $node_menu .= hiddenvar("p", $physical); 122 123 if ( $clustername ) { 124 $url = rawurlencode($clustername); 125 $node_menu .= "<B>$clustername</B> "; 126 //$node_menu .= "<B>></B>\n"; 127 $node_menu .= hiddenvar("c", $clustername); 128 } 129 130 $tpl->assign("node_menu", $node_menu); 131 132 # Make sure that no data is cached.. 133 header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Date in the past 134 header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified 135 header ("Cache-Control: no-cache, must-revalidate"); # HTTP/1.1 136 header ("Pragma: no-cache"); # HTTP/1.0 137 } 138 139 function makeFooter() { 140 global $tpl, $version, $parsetime; 141 142 $tpl->assign("webfrontend-version",$version["webfrontend"]); 143 $tpl->assign("togaweb-version", "0.1"); 144 $tpl->assign("togaarch-version", "0.1"); 145 $tpl->assign("togaplug-version", "0.1"); 146 147 if ($version["gmetad"]) { 148 $tpl->assign("webbackend-component", "gmetad"); 149 $tpl->assign("webbackend-version",$version["gmetad"]); 150 } else if ($version["gmond"]) { 151 $tpl->assign("webbackend-component", "gmond"); 152 $tpl->assign("webbackend-version", $version["gmond"]); 153 } 154 155 $tpl->assign("parsetime", sprintf("%.4f", $parsetime) . "s"); 156 } 157 158 function includeJobview() { 159 global $tpl; 160 161 $tpl->assignInclude( "main", "templates/jobview.tpl" ); 162 } 163 164 function includeOverview() { 165 global $tpl; 166 167 $tpl->assignInclude( "main", "templates/overview.tpl" ); 168 } 169 170 function makeJobview() { 171 172 } 173 174 //function makeOverview() { 175 // 176 // global $jobs, $nodes, $heartbeat, $clustername; 177 178 // foreach( $jobs as $jobid => $jobattrs ) { 179 // 180 // $report_time = $jobattrs[reported]; 181 182 // if( $report_time == $heartbeat ) { 183 184 // $tpl->newBlock("node"); 185 // $tpl->assign( "clustername", $clustername ); 186 // $tpl->assign("id", $jobid ); 187 // $tpl->assign("state", $jobattrs[status] ); 188 // $tpl->assign("user", $jobattrs[owner] ); 189 // $tpl->assign("queue", $jobattrs[queue] ); 190 // $tpl->assign("name", $jobattrs[name] ); 191 // $tpl->assign("req_cpu", $jobattrs[requested_time] ); 192 // $tpl->assign("req_memory", $jobattrs[requested_memory] ); 193 // $nodes = count( $jobattrs[nodes] ); 194 // $ppn = (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1; 195 // $cpus = $nodes * $ppn; 196 // $tpl->assign("nodes", $nodes ); 197 // $tpl->assign("cpus", $cpus ); 198 // $start_time = (int) $jobattrs[start_timestamp]; 199 200 // if( $start_time ) { 201 202 // $runningtime = makeTime( $report_time - $start_time ); 203 // $tpl->assign("started", makeDate( $start_time ) ); 204 // $tpl->assign("runningtime", $runningtime ); 205 // } 206 // } 207 // } 208 //} 209 210 $tpl = new TemplatePower( "templates/index.tpl" ); 211 212 $tpl->assignInclude( "header", "templates/header.tpl" ); 213 214 switch( $view ) { 215 216 case "overview": 217 218 includeOverview(); 219 break; 220 221 case "jobview": 222 223 includeJobview(); 224 break; 225 226 default: 227 228 includeOverview(); 229 break; 230 } 231 232 $tpl->assignInclude( "footer", "templates/footer.tpl" ); 233 $tpl->prepare(); 234 235 $title = "Torque Report"; 236 makeHeader(); 237 238 switch( $view ) { 239 240 case "overview": 241 242 include "./overview.php"; 243 makeOverview(); 244 break; 245 246 case "jobview": 247 248 makeJobview(); 249 break; 250 251 default: 252 253 makeOverview(); 254 break; 255 } 256 257 makeFooter(); 258 259 $tpl->printToScreen(); 20 260 ?> -
trunk/web/addons/toga/libtoga.php
r115 r117 1 1 <?php 2 // If php is compiled without globals 3 // 4 if ( !empty( $_GET ) ) { 5 extract( $_GET ); 6 } 7 2 8 class HTTPVariables { 3 9 … … 5 11 var $restvars, $httpvars; 6 12 7 function HTTPVariables( $ vars ) {13 function HTTPVariables( $httpvars, $getvars ) { 8 14 9 15 $this->restvars = array(); 10 16 11 $this->clustername = $ vars["c"] ? $vars["c"] : null;12 $this->metricname = $ vars["m"] ? $vars["m"] : null;13 14 foreach( $ vars as $httpvar => $httpval ) {17 $this->clustername = $httpvars["c"] ? $httpvars["c"] : null; 18 $this->metricname = $httpvars["m"] ? $httpvars["m"] : null; 19 20 foreach( $httpvars as $httpvar => $httpval ) { 15 21 16 22 if( $httpval ) { 17 23 $this->restvars[$httpvar] = $httpval; 24 } 25 } 26 27 foreach( $getvars as $getvar => $getval ) { 28 29 if( $getval ) { 30 $this->restvars[$getvar] = $getval; 18 31 } 19 32 } … … 40 53 include_once "./conf.php"; 41 54 42 global $GANGLIA_PATH, $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH, $DATA_SOURCE; 43 44 include_once "$GANGLIA_PATH/conf.php"; 45 include_once "$GANGLIA_PATH/functions.php"; 46 include_once "$GANGLIA_PATH/ganglia.php"; 47 48 global $HTTP_GET_VARS; 49 $httpvars = new HTTPVariables( $HTTP_GET_VARS ); 55 global $GANGLIA_PATH; 56 57 $my_dir = getcwd(); 58 59 // Load Ganglia's PHP 60 chdir( $GANGLIA_PATH ); 61 62 include_once "./conf.php"; 63 include_once "./functions.php"; 64 include_once "./ganglia.php"; 65 include_once "./get_context.php"; 66 include_once "./get_ganglia.php"; 67 68 // Back to our PHP 69 chdir( $my_dir ); 70 71 global $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH, $DATA_SOURCE, $HTTP_GET_VARS, $_GET; 72 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); 50 73 51 74 // Set cluster context so that Ganglia will … … 53 76 // 54 77 global $context, $clustername; 55 $clustername = $httpvars->getClusterName(); 56 $context = 'cluster'; 57 58 include_once "$GANGLIA_PATH/get_ganglia.php"; 78 //$clustername = $httpvars->getClusterName(); 79 //$context = 'cluster'; 59 80 60 81 // Ganglia's array of host metrics … … 62 83 global $metrics; 63 84 64 // If php is compiled without globals65 //66 if ( !empty( $_GET ) ) {67 extract( $_GET );68 }69 85 70 86 class DataSource { -
trunk/web/addons/toga/overview.php
r116 r117 1 1 <?php 2 3 $my_dir = getcwd(); 4 5 include_once "./libtoga.php"; 6 7 global $GANGLIA_PATH; 8 chdir( $GANGLIA_PATH ); 9 include_once "./class.TemplatePower.inc.php"; 10 chdir( $my_dir ); 11 12 $httpvars = new HTTPVariables( $HTTP_GET_VARS ); 13 $clustername = $httpvars->getClusterName(); 14 printf( "clustername = %s\n", $clustername ); 15 $queue_select = $httpvars->getHttpVar( "queue" ); 16 printf( "queue = %s\n", $queue ); 2 global $GANGLIA_PATH, $clustername, $tpl; 17 3 18 4 $data_gatherer = new DataGatherer(); 19 5 20 $tpl = new TemplatePower("templates/overview.tpl"); 21 $tpl->prepare(); 22 23 $tpl->assign( "self", "./index.php" ); 6 //$tpl->assign( "self", "./index.php" ); 24 7 $tpl->assign( "clustername", $clustername ); 25 26 8 $tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage" ); 27 9 28 10 $data_gatherer->parseXML(); 11 29 12 $heartbeat = $data_gatherer->getHeartbeat(); 30 13 $jobs = $data_gatherer->getJobs(); … … 214 197 } 215 198 216 foreach( $jobs as $jobid => $jobattrs ) { 217 218 $report_time = $jobattrs[reported]; 219 220 if( $report_time == $heartbeat ) { 221 222 $tpl->newBlock("node"); 223 $tpl->assign( "clustername", $clustername ); 224 $tpl->assign("id", $jobid ); 225 $tpl->assign("state", $jobattrs[status] ); 226 $tpl->assign("user", $jobattrs[owner] ); 227 $tpl->assign("queue", $jobattrs[queue] ); 228 $tpl->assign("name", $jobattrs[name] ); 229 $tpl->assign("req_cpu", $jobattrs[requested_time] ); 230 $tpl->assign("req_memory", $jobattrs[requested_memory] ); 231 $nodes = count( $jobattrs[nodes] ); 232 $ppn = (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1; 233 $cpus = $nodes * $ppn; 234 $tpl->assign("nodes", $nodes ); 235 $tpl->assign("cpus", $cpus ); 236 $start_time = (int) $jobattrs[start_timestamp]; 237 238 if( $start_time ) { 239 240 $runningtime = makeTime( $report_time - $start_time ); 241 $tpl->assign("started", makeDate( $start_time ) ); 242 $tpl->assign("runningtime", $runningtime ); 199 200 function sortJobs( $jobs, $sortby, $sortorder ) { 201 202 $sorted = array(); 203 204 $cmp = create_function( '$a, $b', 205 "global \$sortby, \$sortorder;". 206 207 "if( \$a == \$b ) return 0;". 208 209 "if (\$sortorder==\"desc\")". 210 "return ( \$a < \$b ) ? 1 : -1;". 211 "else if (\$sortorder==\"asc\")". 212 "return ( \$a > \$b ) ? 1 : -1;" ); 213 214 foreach( $jobs as $jobid => $jobattrs ) { 215 216 $state = $jobattrs[status]; 217 $user = $jobattrs[owner]; 218 $queue = $jobattrs[queue]; 219 $name = $jobattrs[name]; 220 $req_cpu = $jobattrs[requested_time]; 221 $req_memory = $jobattrs[requested_memory]; 222 $nodes = count( $jobattrs[nodes] ); 223 $ppn = (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1; 224 $cpus = $nodes * $ppn; 225 $start_time = (int) $jobattrs[start_timestamp]; 226 $runningtime = $report_time - $start_time; 227 228 switch( $sortby ) { 229 case "id": 230 $sorted[$jobid] = $jobid; 231 break; 232 233 case "state": 234 $sorted[$jobid] = $state; 235 break; 236 237 case "user": 238 $sorted[$jobid] = $user; 239 break; 240 241 case "queue": 242 $sorted[$jobid] = $queue; 243 break; 244 245 case "name": 246 $sorted[$jobid] = $name; 247 break; 248 249 case "req_cpu": 250 $sorted[$jobid] = $req_cpu; 251 break; 252 253 case "req_mem": 254 $sorted[$jobid] = $req_memory; 255 break; 256 257 case "nodes": 258 $sorted[$jobid] = $nodes; 259 break; 260 261 case "cpus": 262 $sorted[$jobid] = $cpus; 263 break; 264 265 case "start": 266 $sorted[$jobid] = $start_time; 267 break; 268 269 case "runningtime": 270 $sorted[$jobid] = $runningtime; 271 break; 272 273 default: 274 break; 275 276 } 277 } 278 279 uasort( $sorted, $cmp ); 280 281 return $sorted; 282 } 283 284 function makeOverview() { 285 286 global $jobs, $nodes, $heartbeat, $clustername, $tpl; 287 global $sortorder, $sortby; 288 289 $tpl->assign("sortorder", $sortorder ); 290 $tpl->assign("sortby", $sortby ); 291 292 293 $sorted_jobs = sortJobs( $jobs, $sortby, $sortorder ); 294 295 foreach( $sorted_jobs as $jobid => $sortdec ) { 296 297 $report_time = $jobs[$jobid][reported]; 298 299 if( $report_time == $heartbeat ) { 300 301 $tpl->newBlock("node"); 302 $tpl->assign( "clustername", $clustername ); 303 $tpl->assign("id", $jobid ); 304 $tpl->assign("state", $jobs[$jobid][status] ); 305 $tpl->assign("user", $jobs[$jobid][owner] ); 306 $tpl->assign("queue", $jobs[$jobid][queue] ); 307 $tpl->assign("name", $jobs[$jobid][name] ); 308 $tpl->assign("req_cpu", $jobs[$jobid][requested_time] ); 309 $tpl->assign("req_memory", $jobs[$jobid][requested_memory] ); 310 $nodes = count( $jobs[$jobid][nodes] ); 311 $ppn = (int) $jobs[$jobid][ppn] ? $jobs[$jobid][ppn] : 1; 312 $cpus = $nodes * $ppn; 313 $tpl->assign("nodes", $nodes ); 314 $tpl->assign("cpus", $cpus ); 315 $start_time = (int) $jobs[$jobid][start_timestamp]; 316 317 if( $start_time ) { 318 319 $runningtime = makeTime( $report_time - $start_time ); 320 $tpl->assign("started", makeDate( $start_time ) ); 321 $tpl->assign("runningtime", $runningtime ); 322 } 243 323 } 244 324 } 245 325 } 246 247 $tpl->printToScreen();248 249 326 ?> -
trunk/web/addons/toga/templates/header.tpl
r113 r117 45 45 </TR> 46 46 </TABLE> 47 </FORM> 47 48 48 49 <FONT SIZE="+1">
Note: See TracChangeset
for help on using the changeset viewer.