Changeset 592
- Timestamp:
- 02/05/09 09:35:18 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web2/addons/job_monarch/index.php
r555 r592 33 33 include_once "./libtoga.php"; 34 34 35 if ( !empty( $_GET ) ) { 35 if ( !empty( $_GET ) ) 36 { 36 37 extract( $_GET ); 37 38 } 38 39 //printf( "r2%s\n", $range );40 39 41 40 global $GANGLIA_PATH; … … 55 54 if( !isset($sortby) ) $sortby = "id"; 56 55 57 if( isset( $filterorder ) && ($filterorder!='') ) { 56 if( isset( $filterorder ) && ($filterorder!='') ) 57 { 58 58 $myfilter_fields = explode( ",", $filterorder ); 59 } else { 60 if( isset($queue) && ($queue!='')) $filter[queue]=$queue; 61 if( isset($state) && ($state!='')) $filter[state]=$state; 62 if( isset($user) && ($user!='')) $filter[user]=$user; 63 if( isset($id) && ($id!='')) $filter[id]=$id; 59 } 60 else 61 { 62 if( isset($queue) && ($queue!='')) $filter['queue']=$queue; 63 if( isset($state) && ($state!='')) $filter['state']=$state; 64 if( isset($user) && ($user!='')) $filter['user']=$user; 65 if( isset($id) && ($id!='')) $filter['id']=$id; 64 66 } 65 67 66 68 // Fill filter array in order they were picked by user 67 if( isset($myfilter_fields) ) {68 69 foreach( $myfilter_fields as $myfilter ) {70 71 switch( $myfilter ) {72 69 if( isset($myfilter_fields) ) 70 { 71 foreach( $myfilter_fields as $myfilter ) 72 { 73 switch( $myfilter ) 74 { 73 75 case "queue": 74 $filter[ queue]=$queue;76 $filter['queue']=$queue; 75 77 break; 76 78 case "state": 77 $filter[ state]=$state;79 $filter['state']=$state; 78 80 break; 79 81 case "user": 80 $filter[ user]=$user;82 $filter['user']=$user; 81 83 break; 82 84 case "id": 83 $filter[ id]=$id;85 $filter['id']=$id; 84 86 break; 85 87 } … … 87 89 } 88 90 89 //if( isset($queue) && ($queue!='')) $filter[queue]=$queue; 90 //if( isset($state) && ($state!='')) $filter[state]=$state; 91 //if( isset($user) && ($user!='')) $filter[user]=$user; 92 //if( isset($id) && ($id!='')) $filter[id]=$id; 93 94 function epochToDatetime( $epoch ) { 95 91 function epochToDatetime( $epoch ) 92 { 96 93 return strftime( "%d-%m-%Y %H:%M:%S", $epoch ); 97 94 } 98 95 99 function makeHeader( $page_call, $title, $longtitle ) {100 96 function makeHeader( $page_call, $title, $longtitle ) 97 { 101 98 global $tpl, $grid, $context, $initgrid; 102 99 global $jobrange, $jobstart; … … 120 117 121 118 # Maintain our path through the grid tree. 122 $me = $self . "@" . $grid[$self][ AUTHORITY];119 $me = $self . "@" . $grid[$self]['AUTHORITY']; 123 120 124 121 $gridstack = array(); 125 122 $gridstack[] = $me; 126 123 127 if ($gridwalk=="fwd") { 124 if ($gridwalk=="fwd") 125 { 128 126 # push our info on gridstack, format is "name@url>name2@url". 129 if (end($gridstack) != $me) { 127 if (end($gridstack) != $me) 128 { 130 129 $gridstack[] = $me; 131 130 } 132 } else if ($gridwalk=="back") { 131 } 132 else if ($gridwalk=="back") 133 { 133 134 # pop a single grid off stack. 134 if (end($gridstack) != $me) { 135 if (end($gridstack) != $me) 136 { 135 137 array_pop($gridstack); 136 138 } … … 140 142 $gridstack_url = rawurlencode($gridstack_str); 141 143 142 if ($initgrid or $gridwalk) { 144 if ($initgrid or $gridwalk) 145 { 143 146 # Use cookie so we dont have to pass gridstack around within this site. 144 147 # Cookie values are automatically urlencoded. Expires in a day. … … 152 155 # Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell 153 156 # destination server that we're walking foward in the grid tree. 154 if (strstr($clustername, "http://")) { 157 if (strstr($clustername, "http://")) 158 { 155 159 $tpl->assign("refresh", "0"); 156 160 $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url"); … … 194 198 $node_menu = ""; 195 199 196 if ($parentgrid) { 200 if ($parentgrid) 201 { 197 202 $node_menu .= "<B>$parentgrid $meta_designator</B> "; 198 203 $node_menu .= "<B>></B>\n"; … … 205 210 206 211 if ($physical) 212 { 207 213 $node_menu .= hiddenvar("p", $physical); 208 209 if ( $clustername ) { 214 } 215 216 if ( $clustername ) 217 { 210 218 $url = rawurlencode($clustername); 211 219 $node_menu .= "<B><A HREF=\"../../?c=".rawurlencode($clustername)."\">$clustername</A></B> "; … … 214 222 } 215 223 216 if (!count($metrics)) { 224 if (!count($metrics)) 225 { 217 226 echo "<h4>Cannot find any metrics for selected cluster \"$clustername\", exiting.</h4>\n"; 218 227 echo "Check ganglia XML tree (telnet $ganglia_ip $ganglia_port)\n"; … … 239 248 $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">Joblist</A></B> "; 240 249 241 if( isset( $hostname ) && ( $view != 'host' ) ) {242 250 if( isset( $hostname ) && ( $view != 'host' ) ) 251 { 243 252 $node_menu .= "<B>></B>\n"; 244 253 $href = "<A HREF=\"./?c=".rawurlencode($clustername)."&h=".$hostname."\">"; … … 247 256 } 248 257 249 if( count( $filter ) > 0 && $view != "search" ) {250 258 if( count( $filter ) > 0 && $view != "search" ) 259 { 251 260 $my_ct = 1; 252 261 $filter_nr = count( $filter ); 253 262 254 foreach( $filter as $filtername=>$filterval ) {255 263 foreach( $filter as $filtername=>$filterval ) 264 { 256 265 $node_menu .= "<B>></B>\n"; 257 266 … … 262 271 $my_filters = array_keys( $filter ); 263 272 264 foreach( $n_filter as $n_filtername=>$n_filterval ) { 265 266 if( $temp_ct < $my_ct ) { 273 foreach( $n_filter as $n_filtername=>$n_filterval ) 274 { 275 if( $temp_ct < $my_ct ) 276 { 267 277 $href .= "&". $n_filtername . "=" . $n_filterval; 268 278 … … 286 296 } 287 297 288 //$m = $metricname;289 290 291 298 $tpl->gotoBlock( "_ROOT" ); 292 299 $tpl->assignGlobal("view", $view); 293 300 294 295 if( array_key_exists( "id", $filter ) or isset($hostname) ) { 296 301 if( array_key_exists( "id", $filter ) or isset($hostname) ) 302 { 297 303 $range = "job"; 298 304 299 //print_r( $context_metrics );300 301 305 if( $page_call != "host_view" ) 302 306 { 303 304 if (is_array($context_metrics) ){307 if (is_array($context_metrics) ) 308 { 305 309 $metric_menu = "<B>Metric</B> " 306 310 ."<SELECT NAME=\"m\" OnChange=\"toga_form.submit();\">\n"; 307 311 308 312 sort($context_metrics); 309 foreach( $context_metrics as $k ) { 313 foreach( $context_metrics as $k ) 314 { 310 315 $url = rawurlencode($k); 311 316 $metric_menu .= "<OPTION VALUE=\"$url\" "; … … 321 326 $tpl->assign("metric_menu", $metric_menu ); 322 327 323 if( $view == "search" or $view == "host" ) { 328 if( $view == "search" or $view == "host" ) 329 { 324 330 $tpl->newBlock("timeperiod"); 325 if( is_numeric( $period_start ) ) { 331 if( is_numeric( $period_start ) ) 332 { 326 333 $period_start = epochToDatetime( $period_start ); 327 334 } 328 if( is_numeric( $period_stop ) ) { 335 if( is_numeric( $period_stop ) ) 336 { 329 337 $period_stop = epochToDatetime( $period_stop ); 330 338 } … … 333 341 $tpl->assign("hostname", $hostname ); 334 342 335 if( $view == "host" ) { 343 if( $view == "host" ) 344 { 336 345 $tpl->newBlock("hostview"); 337 346 $tpl->assign("job_start", $job_start ); … … 341 350 342 351 } 343 344 //$ex_fn = $tpl->getVarValue( "_ROOT", "form_name" );345 352 346 353 if( $view != "search" ) … … 354 361 355 362 $range_menu = "<B>Last</B> " ."<SELECT NAME=\"r\" OnChange=\"toga_form.submit();\">\n"; 356 foreach ($context_ranges as $v) { 363 foreach ($context_ranges as $v) 364 { 357 365 $url=rawurlencode($v); 358 366 $range_menu .= "<OPTION VALUE=\"$url\" "; … … 367 375 } 368 376 369 if( $view == "search" or $view == "host" ) {370 377 if( $view == "search" or $view == "host" ) 378 { 371 379 $node_menu .= "<B>></B>\n"; 372 380 $node_menu .= "<B>Jobarchive</B> "; 373 381 $form_name = "archive_search_form"; 374 382 $tpl->assignGlobal("form_name", $form_name ); 375 376 } else { 383 } 384 else 385 { 377 386 $form_name = "toga_form"; 378 387 $tpl->assignGlobal("form_name", $form_name ); 379 388 } 380 389 381 if( $JOB_ARCHIVE && $page_call == 'overview' ) { 390 if( $JOB_ARCHIVE && $page_call == 'overview' ) 391 { 382 392 $tpl->newBlock( "search" ); 383 393 $tpl->assignGlobal( "cluster_url", rawurlencode($clustername) ); … … 395 405 } 396 406 397 function makeFooter() { 407 function makeFooter() 408 { 398 409 global $tpl, $version, $parsetime, $monarchversion; 399 410 … … 402 413 $tpl->assign("monarch-version", $monarchversion); 403 414 404 if ($version["gmetad"]) { 415 if ($version["gmetad"]) 416 { 405 417 $tpl->assign("webbackend-component", "gmetad"); 406 418 $tpl->assign("webbackend-version",$version["gmetad"]); 407 } else if ($version["gmond"]) { 419 } 420 else if ($version["gmond"]) 421 { 408 422 $tpl->assign("webbackend-component", "gmond"); 409 423 $tpl->assign("webbackend-version", $version["gmond"]); … … 413 427 } 414 428 415 function includeSearchpage() { 429 function includeSearchpage() 430 { 416 431 global $tpl; 417 432 418 433 $tpl->assignInclude( "main", "templates/search.tpl" ); 419 420 } 421 422 function includeOverview(){434 } 435 436 function includeOverview() 437 { 423 438 global $tpl; 424 439 … … 426 441 } 427 442 428 function includeHostPage() {429 443 function includeHostPage() 444 { 430 445 global $tpl; 431 446 … … 437 452 $tpl->assignInclude( "header", "templates/header.tpl" ); 438 453 439 if( isset( $h ) and $h != '' ) { 454 if( isset( $h ) and $h != '' ) 455 { 440 456 $hostname = $h; 441 //$view = "host"; 442 } 443 444 switch( $view ) { 445 457 } 458 459 switch( $view ) 460 { 446 461 case "overview": 447 462 … … 470 485 $longtitle = "Batch Report :: Powered by Job Monarch!"; 471 486 $title = "Batch Report"; 472 //makeHeader( 'index' );473 487 $tpl->assign("cluster_url", rawurlencode($clustername) ); 474 488 $tpl->assign("cluster", $clustername ); 475 489 476 switch( $view ) {477 490 switch( $view ) 491 { 478 492 case "overview": 479 493
Note: See TracChangeset
for help on using the changeset viewer.