- Timestamp:
- 11/12/09 17:08:03 (14 years ago)
- Location:
- trunk/web/addons/job_monarch
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/job_monarch/clusterconf/gina-example.php
r532 r648 1 1 <?php 2 2 // 3 $SORTBY_HOSTNAME = "v{x}-{y}.gina.sara.nl"; 3 //$SORTBY_HOSTNAME = "v{x}-{y}.gina.sara.nl"; 4 $SORTBY_HOSTNAME = "{x}-{y}.gina.sara.nl"; 4 5 $SORT_ORDER = "asc"; 5 6 -
trunk/web/addons/job_monarch/conf.php
r573 r648 75 75 // [syntax: <ip>:<port>] 76 76 // 77 $DATA_SOURCE = '127.0.0.1:865 1';77 $DATA_SOURCE = '127.0.0.1:8652'; 78 78 79 79 // Is there a jobarchive? -
trunk/web/addons/job_monarch/image.php
r646 r648 23 23 */ 24 24 25 ini_set("memory_limit"," 200M");25 ini_set("memory_limit","1G"); 26 26 set_time_limit(0); 27 27 … … 33 33 } 34 34 35 function makeSession()36 {37 $ds = new DataSource();38 $myxml_data = &$ds->getData();39 40 unset( $_SESSION['data'] );41 42 $_SESSION['data'] = &$myxml_data;43 $_SESSION['gather_time'] = time();44 }45 46 global $session_active, $_SESSION, $myxml_data;47 48 function checkSessionPollInterval( $poll_interval )49 {50 global $session_active, $_SESSION;51 52 if( ! session_active )53 {54 return 0;55 }56 57 if( isset( $_SESSION['poll_interval'] ) )58 {59 if( $poll_interval <> $_SESSION['poll_interval'] )60 {61 $_SESSION['poll_interval'] = $poll_interval;62 }63 }64 else65 {66 $_SESSION['poll_interval'] = $poll_interval;67 }68 69 session_write_close();70 71 $session_active = false;72 }73 74 function checkSession()75 {76 global $session_active, $_SESSION;77 78 session_start();79 80 $session_active = true;81 82 // I got nothing; create session83 //84 if( ! isset( $_SESSION['gather_time'] ) || ! isset( $_SESSION['data'] ) )85 {86 makeSession();87 88 return 0;89 }90 91 if( isset( $_SESSION['poll_interval'] ) )92 {93 $gather_time = $_SESSION['gather_time'];94 $poll_interval = $_SESSION['poll_interval'];95 96 $cur_time = time();97 98 // If poll_interval time elapsed since last update; recreate session99 //100 if( ($cur_time - $gather_time) >= $poll_interval )101 {102 makeSession();103 104 return 0;105 }106 }107 }108 109 checkSession();110 $myxml_data = &$_SESSION['data'];111 session_write_close();112 113 35 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); 114 36 $view = $httpvars->getHttpVar( "view" ); … … 116 38 $query = $httpvars->getHttpVar( "query" ); 117 39 $clustername = $httpvars->getClusterName(); 40 41 global $mySession, $myData, $myXML; 42 43 //printf( "c %s\n", $clustername ); 44 45 $mySession = new SessionHandler( $clustername ); 46 $mySession->checkSession(); 47 48 $session = &$mySession->getSession(); 49 $myXML = $session['data']; 50 51 $myData = new DataGatherer( $clustername ); 52 $myData->parseXML( $myXML ); 53 54 $mySession->updatePollInterval( $myData->getPollInterval() ); 55 $mySession->endSession(); 56 57 //printf( "%s\n", strlen( $myXML ) ); 118 58 119 59 if( isset($jid) && ($jid!='')) $filter['jid']=$jid; … … 124 64 if( isset($query) && ($query!='')) $filter['query']=$query; 125 65 126 $data_gatherer = new DataGatherer( $clustername );127 $data_gatherer->parseXML( &$myxml_data );128 129 66 function drawHostImage() 130 67 { 131 global $clustername, $hostname, $ data_gatherer;68 global $clustername, $hostname, $myData; 132 69 133 if( $ data_gatherer->isJobmonRunning() )70 if( $myData->isJobmonRunning() ) 134 71 { 135 $ic = new HostImage( $ data_gatherer, $clustername, $hostname );72 $ic = new HostImage( $myData, $clustername, $hostname ); 136 73 } 137 74 else … … 145 82 function drawSmallClusterImage() 146 83 { 147 global $clustername, $ data_gatherer, $myxml_data;84 global $clustername, $myData, $myXML; 148 85 149 if( $data_gatherer->isJobmonRunning() ) 86 //printf( "%s\n", strlen( $myXML ) ); 87 88 if( $myData->isJobmonRunning() ) 150 89 { 151 $ic = new ClusterImage( $myxml_data, $clustername ); 90 //$ic = new ClusterImage( $myXML, $clustername ); 91 $ic = new ClusterImage( $myData, $clustername ); 152 92 $ic->setSmall(); 93 //printf( "is running\n" ); 153 94 } 154 95 else 155 96 { 156 97 $ic = new EmptyImage(); 98 //printf( "not running\n" ); 157 99 } 158 100 … … 162 104 function drawBigClusterImage() 163 105 { 164 global $filter, $clustername, $my xml_data;106 global $filter, $clustername, $myXML, $myData; 165 107 166 $ic = new ClusterImage( $myxml_data, $clustername ); 108 //$ic = new ClusterImage( $myXML, $clustername ); 109 $ic = new ClusterImage( $myData, $clustername ); 167 110 $ic->setBig(); 168 111 -
trunk/web/addons/job_monarch/index.php
r592 r648 23 23 */ 24 24 25 ini_set("memory_limit","200M"); 25 //ini_set("memory_limit","200M"); 26 ini_set("memory_limit","1G"); 26 27 set_time_limit(0); 27 28 … … 44 45 chdir( $my_dir ); 45 46 46 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); 47 $clustername = $httpvars->getClusterName(); 48 $view = $httpvars->getHttpVar( "view" ); 47 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); 48 $clustername = $httpvars->getClusterName(); 49 $view = $httpvars->getHttpVar( "view" ); 50 51 global $mySession, $myData, $myXML; 52 53 //printf( "c %s\n", $clustername ); 54 55 $mySession = new SessionHandler( $clustername ); 56 $mySession->checkSession(); 57 58 $session = &$mySession->getSession(); 59 $myXML = $session['data']; 60 61 $myData = new DataGatherer( $clustername ); 62 $myData->parseXML( $myXML ); 63 64 $mySession->updatePollInterval( $myData->getPollInterval() ); 65 $mySession->endSession(); 49 66 50 67 $filter = array(); … … 94 111 } 95 112 96 function makeHeader( $page_call, $title, $longtitle )97 {98 global $tpl, $grid, $context, $initgrid;99 global $jobrange, $jobstart;100 global $page, $gridwalk, $clustername;101 global $parentgrid, $physical, $hostname;102 global $self, $filter, $cluster_url, $get_metric_string;103 global $metrics, $reports, $m, $default_metric;104 global $default_refresh, $filterorder, $view;105 global $JOB_ARCHIVE, $period_start, $period_stop, $h, $id;106 global $job_start, $job_stop, $range, $r, $metricname;107 108 if( isset($default_metric) and !isset($m) )109 $metricname = $default_metric;110 else111 if( isset( $m ) )112 $metricname = $m;113 else114 $metricname = "load_one";115 116 $header = "header";117 118 # Maintain our path through the grid tree.119 $me = $self . "@" . $grid[$self]['AUTHORITY'];120 121 $gridstack = array();122 $gridstack[] = $me;123 124 if ($gridwalk=="fwd")125 {126 # push our info on gridstack, format is "name@url>name2@url".127 if (end($gridstack) != $me)128 {129 $gridstack[] = $me;130 }131 }132 else if ($gridwalk=="back")133 {134 # pop a single grid off stack.135 if (end($gridstack) != $me)136 {137 array_pop($gridstack);138 }139 }140 141 $gridstack_str = join(">", $gridstack);142 $gridstack_url = rawurlencode($gridstack_str);143 144 if ($initgrid or $gridwalk)145 {146 # Use cookie so we dont have to pass gridstack around within this site.147 # Cookie values are automatically urlencoded. Expires in a day.148 setcookie("gs", $gridstack_str, time() + 86400);149 }150 151 # Invariant: back pointer is second-to-last element of gridstack. Grid stack never152 # has duplicate entries.153 list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]);154 155 # Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell156 # destination server that we're walking foward in the grid tree.157 if (strstr($clustername, "http://"))158 {159 $tpl->assign("refresh", "0");160 $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url");161 echo "<h2>Redirecting, please wait...</h2>";162 $tpl->printToScreen();163 exit;164 }165 $tpl->gotoBlock( "_ROOT" );166 167 if( $view != "search" )168 $tpl->assign( "refresh", $default_refresh );169 170 $tpl->assign( "date", date("r") );171 //printf("lg %s\n", $longtitle );172 //printf("title %s\n", $title );173 $tpl->assign( "longpage_title", $longtitle );174 $tpl->assign( "page_title", $title );175 176 # The page to go to when "Get Fresh Data" is pressed.177 $tpl->assign("page","./");178 179 # Templated Logo image180 $tpl->assign("images","./templates/$template_name/images");181 182 #183 # Used when making graphs via graph.php. Included in most URLs184 #185 $sort_url=rawurlencode($sort);186 $get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols";187 188 if ($jobrange and $jobstart)189 $get_metric_string .= "&jr=$jobrange&js=$jobstart";190 191 # Set the Alternate view link.192 $cluster_url=rawurlencode($clustername);193 $node_url=rawurlencode($hostname);194 195 # Make some information available to templates.196 $tpl->assign("cluster_url", $cluster_url);197 # Build the node_menu198 $node_menu = "";199 200 if ($parentgrid)201 {202 $node_menu .= "<B>$parentgrid $meta_designator</B> ";203 $node_menu .= "<B>></B>\n";204 }205 206 # Show grid.207 $mygrid = ($self == "unspecified") ? "" : $self;208 $node_menu .= "<B><A HREF=\"../..\">$mygrid $meta_designator</A></B> ";209 $node_menu .= "<B>></B>\n";210 211 if ($physical)212 {213 $node_menu .= hiddenvar("p", $physical);214 }215 216 if ( $clustername )217 {218 $url = rawurlencode($clustername);219 $node_menu .= "<B><A HREF=\"../../?c=".rawurlencode($clustername)."\">$clustername</A></B> ";220 $node_menu .= "<B>></B>\n";221 $node_menu .= hiddenvar("c", $clustername);222 }223 224 if (!count($metrics))225 {226 echo "<h4>Cannot find any metrics for selected cluster \"$clustername\", exiting.</h4>\n";227 echo "Check ganglia XML tree (telnet $ganglia_ip $ganglia_port)\n";228 exit;229 }230 reset($metrics);231 $firsthost = key($metrics);232 233 $mmfh = array();234 235 $mmfh = $metrics[$firsthost];236 237 $context_metrics = array();238 239 //foreach ($mmfh as $mm => $mfoo)240 foreach( $mmfh as $mm => $bla )241 {242 $context_metrics[] = $mm;243 }244 245 foreach ($reports as $mr => $mfoo)246 $context_metrics[] = $mr;247 248 $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">Joblist</A></B> ";249 250 if( isset( $hostname ) && ( $view != 'host' ) )251 {252 $node_menu .= "<B>></B>\n";253 $href = "<A HREF=\"./?c=".rawurlencode($clustername)."&h=".$hostname."\">";254 $node_menu .= "<B>$href";255 $node_menu .= "host: $hostname</A></B> ";256 }257 258 if( count( $filter ) > 0 && $view != "search" )259 {260 $my_ct = 1;261 $filter_nr = count( $filter );262 263 foreach( $filter as $filtername=>$filterval )264 {265 $node_menu .= "<B>></B>\n";266 267 $href = "<A HREF=\"./?c=".rawurlencode($clustername);268 $temp_ct = 0;269 $n_filter = $filter;270 $my_filterorder = "";271 $my_filters = array_keys( $filter );272 273 foreach( $n_filter as $n_filtername=>$n_filterval )274 {275 if( $temp_ct < $my_ct )276 {277 $href .= "&". $n_filtername . "=" . $n_filterval;278 279 if( $my_filterorder == "" )280 $my_filterorder = $my_filters[$temp_ct];281 else282 $my_filterorder .= "," . $my_filters[$temp_ct];283 }284 285 $temp_ct++;286 }287 $href .= "&filterorder=$my_filterorder\">";288 289 if( $my_ct < $filter_nr )290 $node_menu .= "<B>$href$filtername: $filterval</A></B> ";291 else292 $node_menu .= "<B>$filtername: $filterval</B> ";293 294 $my_ct++;295 }296 }297 298 $tpl->gotoBlock( "_ROOT" );299 $tpl->assignGlobal("view", $view);300 301 if( array_key_exists( "id", $filter ) or isset($hostname) )302 {303 $range = "job";304 305 if( $page_call != "host_view" )306 {307 if (is_array($context_metrics) )308 {309 $metric_menu = "<B>Metric</B> "310 ."<SELECT NAME=\"m\" OnChange=\"toga_form.submit();\">\n";311 312 sort($context_metrics);313 foreach( $context_metrics as $k )314 {315 $url = rawurlencode($k);316 $metric_menu .= "<OPTION VALUE=\"$url\" ";317 if ($k == $metricname )318 $metric_menu .= "SELECTED";319 $metric_menu .= ">$k\n";320 }321 $metric_menu .= "</SELECT>\n";322 }323 324 }325 326 $tpl->assign("metric_menu", $metric_menu );327 328 if( $view == "search" or $view == "host" )329 {330 $tpl->newBlock("timeperiod");331 if( is_numeric( $period_start ) )332 {333 $period_start = epochToDatetime( $period_start );334 }335 if( is_numeric( $period_stop ) )336 {337 $period_stop = epochToDatetime( $period_stop );338 }339 $tpl->assign("period_start", $period_start );340 $tpl->assign("period_stop", $period_stop );341 $tpl->assign("hostname", $hostname );342 343 if( $view == "host" )344 {345 $tpl->newBlock("hostview");346 $tpl->assign("job_start", $job_start );347 $tpl->assign("job_stop", $job_stop );348 }349 }350 351 }352 353 if( $view != "search" )354 {355 $context_ranges[]="hour";356 $context_ranges[]="day";357 $context_ranges[]="week";358 $context_ranges[]="month";359 $context_ranges[]="year";360 $context_ranges[]="job";361 362 $range_menu = "<B>Last</B> " ."<SELECT NAME=\"r\" OnChange=\"toga_form.submit();\">\n";363 foreach ($context_ranges as $v)364 {365 $url=rawurlencode($v);366 $range_menu .= "<OPTION VALUE=\"$url\" ";367 if ($v == $range)368 $range_menu .= "SELECTED";369 $range_menu .= ">$v\n";370 }371 $range_menu .= "</SELECT>\n";372 373 $tpl->assign("range_menu", $range_menu);374 375 }376 377 if( $view == "search" or $view == "host" )378 {379 $node_menu .= "<B>></B>\n";380 $node_menu .= "<B>Jobarchive</B> ";381 $form_name = "archive_search_form";382 $tpl->assignGlobal("form_name", $form_name );383 }384 else385 {386 $form_name = "toga_form";387 $tpl->assignGlobal("form_name", $form_name );388 }389 390 if( $JOB_ARCHIVE && $page_call == 'overview' )391 {392 $tpl->newBlock( "search" );393 $tpl->assignGlobal( "cluster_url", rawurlencode($clustername) );394 $tpl->assignGlobal( "cluster", $clustername );395 }396 $tpl->gotoBlock( "_ROOT" );397 $tpl->assignGlobal( "cluster", $clustername );398 $tpl->assign("node_menu", $node_menu);399 400 # Make sure that no data is cached..401 header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Date in the past402 header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified403 header ("Cache-Control: no-cache, must-revalidate"); # HTTP/1.1404 header ("Pragma: no-cache"); # HTTP/1.0405 }406 113 407 114 function makeFooter() … … 456 163 $hostname = $h; 457 164 } 165 $ic = new ClusterImage( $myData, $clustername ); 166 $ic->setBig(); 167 $ic->setNoimage(); 168 $ic->draw(); 169 170 //printf("%s\n", $ic->getImagemapArea() ); 171 458 172 459 173 switch( $view ) … … 461 175 case "overview": 462 176 463 includeOverview();177 //includeOverview(); 464 178 break; 465 179 466 180 case "search": 467 181 468 includeSearchPage();182 //includeSearchPage(); 469 183 break; 470 184 471 185 case "host": 472 186 473 includeHostPage();187 //includeHostPage(); 474 188 break; 475 189 476 190 default: 477 191 478 includeOverview();192 //includeOverview(); 479 193 break; 480 194 } … … 488 202 $tpl->assign("cluster", $clustername ); 489 203 204 session_start(); 205 $tpl->assign( "session_name", session_name() ); 206 $tpl->assign( "session_id", session_id() ); 207 208 $rjqj_str .= "./graph.php?z=small&c=$clustername&g=job_report&r=$range&st=$cluster[LOCALTIME]"; 209 210 $tpl->assign( "rjqj_graph", $rjqj_str ); 211 $tpl->assign( "uue_clustername", rawurlencode($clustername) ); 212 213 $tpl->assign( "node_area_map", $ic->getImagemapArea() ); 214 490 215 switch( $view ) 491 216 { 492 217 case "overview": 493 218 494 include "./overview.php";495 makeOverview();219 //include "./overview.php"; 220 //makeOverview(); 496 221 break; 497 222 498 223 case "search": 499 224 500 include "./search.php";501 makeSearchPage();225 //include "./search.php"; 226 //makeSearchPage(); 502 227 break; 503 228 504 229 case "host": 505 230 506 include "./host_view.php";507 makeHostView();231 //include "./host_view.php"; 232 //makeHostView(); 508 233 break; 509 234 510 235 default: 511 236 512 makeOverview();237 //makeOverview(); 513 238 break; 514 239 } -
trunk/web/addons/job_monarch/jobstore.php
r646 r648 1 1 <?php 2 2 3 ini_set("memory_limit"," 200M");3 ini_set("memory_limit","1G"); 4 4 set_time_limit(0); 5 6 //ini_set("xdebug.profiler_output_dir","/tmp"); 7 //ini_set("xdebug.profiler_output_name","timestamp"); 8 //ini_set("xdebug.profiler_enable","1"); 5 9 6 10 $c = $_POST['c']; … … 53 57 $_GET['c'] = $c; 54 58 55 global $c, $clustername, $cluster ;59 global $c, $clustername, $cluster, $mySession; 56 60 57 61 include_once "./libtoga.php"; 58 62 59 function makeSession() 60 { 61 $ds = new DataSource(); 62 $myxml_data = &$ds->getData(); 63 64 unset( $_SESSION['data'] ); 65 66 $_SESSION['data'] = &$myxml_data; 67 $_SESSION['gather_time'] = time(); 68 } 69 70 global $session_active, $_SESSION; 71 72 function checkSessionPollInterval( $poll_interval ) 73 { 74 global $session_active, $_SESSION; 75 76 if( ! session_active ) 77 { 78 return 0; 79 } 80 81 if( isset( $_SESSION['poll_interval'] ) ) 82 { 83 if( $poll_interval <> $_SESSION['poll_interval'] ) 84 { 85 $_SESSION['poll_interval'] = $poll_interval; 86 } 87 } 88 else 89 { 90 $_SESSION['poll_interval'] = $poll_interval; 91 } 92 93 session_write_close(); 94 95 $session_active = false; 96 } 97 98 function checkSession() 99 { 100 global $session_active, $_SESSION; 101 102 session_start(); 103 104 $session_active = true; 105 106 // I got nothing; create session 107 // 108 if( ! isset( $_SESSION['gather_time'] ) || ! isset( $_SESSION['data'] ) ) 109 { 110 makeSession(); 111 112 return 0; 113 } 114 115 if( isset( $_SESSION['poll_interval'] ) ) 116 { 117 $gather_time = $_SESSION['gather_time']; 118 $poll_interval = $_SESSION['poll_interval']; 119 120 $cur_time = time(); 121 122 // If poll_interval time elapsed since last update; recreate session 123 // 124 if( ($cur_time - $gather_time) >= $poll_interval ) 125 { 126 makeSession(); 127 128 return 0; 129 } 130 } 131 } 132 133 checkSession(); 134 135 global $jobs, $metrics; 136 137 $data_gatherer = new DataGatherer( $clustername ); 138 $data_gatherer->parseXML( &$_SESSION['data'] ); 139 140 $heartbeat = &$data_gatherer->getHeartbeat(); 141 $jobs = &$data_gatherer->getJobs(); 142 //$gnodes = $data_gatherer->getNodes(); 143 $cpus = &$data_gatherer->getCpus(); 144 $use_fqdn = &$data_gatherer->getUsingFQDN(); 63 64 global $jobs, $metrics, $session; 65 66 //printf( "c %s\n", $clustername ); 67 68 $mySession = new SessionHandler( $clustername ); 69 $mySession->checkSession(); 70 71 $session = &$mySession->getSession(); 72 $myXML = $session['data']; 73 74 //printf( "gt %s\n", $session['gather_time'] ); 75 //printf( "pi %s\n", $session['poll_interval'] ); 76 77 $myData = new DataGatherer( $clustername ); 78 $myData->parseXML( $myXML ); 79 80 $mySession->updatePollInterval( $myData->getPollInterval() ); 81 //printf( "pi %s\n", $myData->getPollInterval() ); 82 //printf( "pi %s\n", $session['poll_interval'] ); 83 $mySession->endSession(); 84 85 86 $heartbeat = &$myData->getHeartbeat(); 87 $jobs = &$myData->getJobs(); 88 $cpus = &$myData->getCpus(); 89 $use_fqdn = &$myData->getUsingFQDN(); 90 91 //print_r( $jobs ); 92 93 //print_r( $session ); 145 94 146 95 // The ext grid script will send a task field which will specify what it wants to do … … 518 467 { 519 468 global $jobs, $jobids, $clustername, $metrics, $jid, $p_metricname; 520 global $always_timestamp, $always_constant ;469 global $always_timestamp, $always_constant, $mySession; 521 470 522 471 $display_nodes = array(); … … 566 515 $poll_interval = (int) $jobs[$jid]['poll_interval']; 567 516 568 checkSessionPollInterval( $poll_interval );517 //$mySession->updatePollInterval( $poll_interval ); 569 518 570 519 $time = time(); … … 636 585 global $jobs, $hearbeat, $pstart, $pend; 637 586 global $sortfield, $sortorder, $query, $host; 638 global $jid, $owner, $queue, $status ;587 global $jid, $owner, $queue, $status, $mySession; 639 588 640 589 $job_count = count( $jobs ); … … 686 635 $poll_interval = (int) $jobs[$jobid]['poll_interval']; 687 636 688 checkSessionPollInterval( $poll_interval );637 //$mySession->updatePollInterval( $poll_interval ); 689 638 690 639 if( $jr['status'] == 'R' ) -
trunk/web/addons/job_monarch/libtoga.php
r602 r648 137 137 } 138 138 139 class SessionHandler 140 { 141 var $cluster, $poll_stored; 142 143 function SessionHandler( $cluster ) 144 { 145 $this->cluster = $cluster; 146 $this->ds = new DataSource( $this->cluster ); 147 148 //ob_start(); 149 session_start(); 150 } 151 152 function refreshSession() 153 { 154 $ds = &$this->ds; 155 $myxml_data = $ds->getData(); 156 157 $_SESSION['data'] = &$myxml_data; 158 $_SESSION['gather_time'] = time(); 159 } 160 161 function hasSession() 162 { 163 return ( $this->have_session ); 164 } 165 166 function getSession() 167 { 168 return $_SESSION; 169 170 } 171 172 function endSession() 173 { 174 session_write_close(); 175 //ob_end_flush(); 176 //session_unlock(); 177 //session_destroy(); 178 } 179 180 function updatePollInterval( $poll_interval ) 181 { 182 //if( ! isset( $_SESSION['poll_interval'] ) ) 183 //{ 184 $_SESSION['poll_interval'] = $poll_interval; 185 //} 186 } 187 188 function checkSession() 189 { 190 // I got nothing; create session 191 // 192 //if( ! $this->have_session ) 193 //{ 194 // $this->refreshSession(); 195 // 196 // return 0; 197 //} 198 199 //if( $this->poll_stored ) 200 //{ 201 // session_start(); 202 203 if( isset( $_SESSION['gather_time'] ) && isset( $_SESSION['poll_interval'] ) ) 204 { 205 206 $gather_time = $_SESSION['gather_time']; 207 $poll_interval = $_SESSION['poll_interval']; 208 209 // If poll_interval time elapsed since last update; recreate session 210 // 211 if( (time() - $gather_time) >= $poll_interval ) 212 { 213 $this->refreshSession(); 214 } 215 } 216 else 217 { 218 $this->refreshSession(); 219 } 220 //} 221 } 222 } 139 223 140 224 class TarchDbase … … 459 543 var $data, $ip, $port; 460 544 461 function DataSource( )545 function DataSource( $cluster ) 462 546 { 463 547 global $DATA_SOURCE; … … 470 554 $this->ip = $ds_ip; 471 555 $this->port = $ds_port; 472 556 $this->cluster = $cluster; 473 557 } 474 558 … … 487 571 } 488 572 573 $clustername = $this->cluster; 574 575 $rc = fputs($fp, "/$clustername"."\n" ); 576 577 if (!$rc) 578 { 579 echo "Could not sent request to gmetad: $errstr"; 580 return; 581 } 582 489 583 stream_set_timeout( $fp, 30 ); 490 584 … … 515 609 $this->xmlhandler = new TorqueXMLHandler( $this->cluster ); 516 610 611 xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 ); 517 612 xml_set_element_handler( $this->parser, array( &$this->xmlhandler, 'startElement' ), array( &$this->xmlhandler, 'stopElement' ) ); 518 613 … … 521 616 $error = sprintf( 'XML error: %s at %d', xml_error_string( xml_get_error_code( $this->parser ) ), xml_get_current_line_number( $this->parser ) ); 522 617 } 618 } 619 620 function getPollInterval() 621 { 622 $handler = $this->xmlhandler; 623 //printf("d i %s\n", $handler->getPollInterval() ); 624 625 return $handler->getPollInterval(); 523 626 } 524 627 … … 555 658 function getJobs() 556 659 { 557 $handler = $this->xmlhandler;558 return $handler->getJobs();660 $handler = &$this->xmlhandler; 661 return ( $handler->getJobs() ); 559 662 } 560 663 … … 593 696 $this->fqdn = 0; 594 697 $this->fqdnFound = 0; 698 $this->pollinterval = 0; 699 } 700 701 function getPollInterval() 702 { 703 //printf( "t pi %s\n", $this->pollinterval ); 704 return ( $this->pollinterval ); 595 705 } 596 706 … … 621 731 if (isset( $this->heartbeat['time'] )) 622 732 { 623 return 1;733 return true; 624 734 } 625 735 else 626 736 { 627 return 0;737 return false; 628 738 } 629 739 } … … 633 743 // Should hostname be FQDN or short w/o domain 634 744 // 635 $nodes = &$this->nodes;745 //$nodes = &$this->nodes; 636 746 637 747 $domain_len = 0 - strlen( $tdomain ); … … 640 750 { 641 751 if( substr( $thostname, $domain_len ) != $tdomain ) 752 //if( strpos( $thostname, $tdomain ) !== false ) 642 753 { 643 754 $thostname = $thostname . '.'.$tdomain; … … 650 761 function startElement( $parser, $name, $attrs ) 651 762 { 652 $jobs 653 $nodes 763 $jobs = $this->jobs; 764 $nodes = $this->nodes; 654 765 655 766 if ( $attrs['TN'] ) … … 664 775 $jobid = null; 665 776 666 if( $name == 'CLUSTER' ) 667 { 668 $this->proc_cluster = $attrs['NAME']; 669 } 670 else if( $name == 'HOST' and $this->proc_cluster == $this->clustername) 777 //if( $name == 'CLUSTER' ) 778 //{ 779 // $this->proc_cluster = $attrs['NAME']; 780 //} 781 //else if( $name == 'HOST' and $this->proc_cluster == $this->clustername) 782 if( $name == 'HOST' ) 671 783 { 672 784 $hostname = $attrs['NAME']; … … 698 810 } 699 811 } 700 else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername ) 701 { 702 if( strstr( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) ) 812 //else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername ) 813 else if( ($name == 'METRIC') && (strpos( $attrs['NAME'], 'MONARCH' ) !== false) ) 814 { 815 if( strpos( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) !== false ) 703 816 { 704 817 $this->heartbeat['time'] = $attrs['VAL']; 705 818 } 706 else if( str str( $attrs['NAME'], 'MONARCH-DOWN' ))819 else if( strpos( $attrs['NAME'], 'MONARCH-DOWN' ) !== false) 707 820 { 708 821 $fields = explode( ' ', $attrs['VAL'] ); … … 717 830 $toganame = $togavalues[0]; 718 831 $togavalue = $togavalues[1]; 832 719 833 720 834 if( $toganame == 'nodes' ) … … 746 860 } 747 861 } 748 else if( str str( $attrs['NAME'], 'MONARCH-OFFLINE' ))862 else if( strpos( $attrs['NAME'], 'MONARCH-OFFLINE' ) !== false ) 749 863 { 750 864 $fields = explode( ' ', $attrs['VAL'] ); … … 788 902 } 789 903 } 790 else if( str str( $attrs['NAME'], 'MONARCH-JOB' ))904 else if( strpos( $attrs['NAME'], 'MONARCH-JOB' ) !== false ) 791 905 { 792 906 sscanf( $attrs['NAME'], 'MONARCH-JOB-%d-%d', $jobid, $monincr ); … … 805 919 $toganame = $togavalues[0]; 806 920 $togavalue = $togavalues[1]; 921 922 //printf( "tn %s\n", $toganame ); 807 923 808 924 if( $toganame == 'nodes' ) … … 830 946 $jobs[$jobid][$toganame] = $togavalue; 831 947 } 948 } 949 else if( $toganame == 'poll_interval' ) 950 { 951 $this->pollinterval = $togavalue; 952 //printf("u pi %s\n", $togavalue ); 832 953 } 833 954 else … … 1352 1473 var $filtername, $filters; 1353 1474 1354 function ClusterImage( $data, $clustername ) 1355 { 1356 $this->dataget = new DataGatherer( $clustername ); 1357 $this->data = $data; 1475 function ClusterImage( $datag, $clustername ) 1476 { 1477 //$this->dataget = new DataGatherer( $clustername ); 1478 $this->dataget = $datag; 1479 //$this->data = $data; 1358 1480 $this->clustername = $clustername; 1359 1481 $this->filters = array(); … … 1503 1625 } 1504 1626 1505 $mydatag =$this->dataget;1506 $mydatag->parseXML( $this->data );1627 $mydatag = &$this->dataget; 1628 //$mydatag->parseXML( $this->data ); 1507 1629 1508 1630 if( $this->isSmall() ) … … 1518 1640 1519 1641 $nodes = $mydatag->getNodes(); 1642 //print_r( $nodes); 1520 1643 $nodes_hosts = array_keys( $nodes ); 1521 1644 … … 1556 1679 $this->height = ($y_offset + (($node_rows*$node_width)+1) ); 1557 1680 1558 $jobs 1681 $jobs = $mydatag->getJobs(); 1559 1682 $filtered_nodes = $this->filterNodes( $jobs, $nodes ); 1560 1683 $selected_host = $this->selected; -
trunk/web/addons/job_monarch/overview.php
r617 r648 35 35 36 36 $ds = new DataSource(); 37 $myxml_data = $ds->getData();37 //$myxml_data = $ds->getData(); 38 38 39 39 $data_gatherer = new DataGatherer( $clustername ); 40 $data_gatherer->parseXML( $myxml_data );40 //$data_gatherer->parseXML( $myxml_data ); 41 41 42 42 $heartbeat = $data_gatherer->getHeartbeat(); -
trunk/web/addons/job_monarch/templates/header.tpl
r646 r648 47 47 GraphSummaryWindow.show(); 48 48 49 ClusterImageWindow.html = '<IMG ID="clusterimage" SRC=" {clusterimage}" USEMAP="#MONARCH_CLUSTER_BIG" BORDER="0">';49 ClusterImageWindow.html = '<IMG ID="clusterimage" SRC="./image.php?{session_name}={session_id}" USEMAP="#MONARCH_CLUSTER_BIG" BORDER="0">'; 50 50 ClusterImageWindow.show(); 51 51 setClusterImagePosition(); … … 59 59 60 60 Ext.get( 'rjqjgraph' ).update( '<IMG ID="rjqj_graph" SRC="{rjqj_graph}" BORDER=0>' ); 61 Ext.get( 'pie' ).update( '<IMG ID="pie" SRC="{pie}" BORDER=0>' );61 //Ext.get( 'pie' ).update( '<IMG ID="pie" SRC="./image.php?{session_name}={session_id}&c={uue_clustername}&view=big-clusterimage" BORDER=0>' ); 62 62 }); 63 63 </script> … … 73 73 74 74 <MAP NAME="MONARCH_CLUSTER_BIG"> 75 <!-- START BLOCK : node_clustermap -->76 75 {node_area_map} 77 <!-- END BLOCK : node_clustermap -->78 76 </MAP>
Note: See TracChangeset
for help on using the changeset viewer.