Index: trunk/web/addons/job_monarch/clusterconf/gina-example.php
===================================================================
--- trunk/web/addons/job_monarch/clusterconf/gina-example.php	(revision 647)
+++ trunk/web/addons/job_monarch/clusterconf/gina-example.php	(revision 648)
@@ -1,5 +1,6 @@
 <?php
 //
-$SORTBY_HOSTNAME = "v{x}-{y}.gina.sara.nl";
+//$SORTBY_HOSTNAME = "v{x}-{y}.gina.sara.nl";
+$SORTBY_HOSTNAME = "{x}-{y}.gina.sara.nl";
 $SORT_ORDER = "asc";
 
Index: trunk/web/addons/job_monarch/conf.php
===================================================================
--- trunk/web/addons/job_monarch/conf.php	(revision 647)
+++ trunk/web/addons/job_monarch/conf.php	(revision 648)
@@ -75,5 +75,5 @@
 // [syntax: <ip>:<port>]
 //
-$DATA_SOURCE = '127.0.0.1:8651';
+$DATA_SOURCE = '127.0.0.1:8652';
 
 // Is there a jobarchive?
Index: trunk/web/addons/job_monarch/image.php
===================================================================
--- trunk/web/addons/job_monarch/image.php	(revision 647)
+++ trunk/web/addons/job_monarch/image.php	(revision 648)
@@ -23,5 +23,5 @@
  */
 
-ini_set("memory_limit","200M");
+ini_set("memory_limit","1G");
 set_time_limit(0);
 
@@ -33,82 +33,4 @@
 }
 
-function makeSession()
-{
-        $ds             = new DataSource();
-        $myxml_data     = &$ds->getData();
-
-        unset( $_SESSION['data'] );
-
-        $_SESSION['data']               = &$myxml_data;
-        $_SESSION['gather_time']        = time();
-}
-
-global $session_active, $_SESSION, $myxml_data;
-
-function checkSessionPollInterval( $poll_interval )
-{
-        global $session_active, $_SESSION;
-
-        if( ! session_active )
-        {
-                return 0;
-        }
-
-        if( isset( $_SESSION['poll_interval'] ) )
-        {
-                if( $poll_interval <> $_SESSION['poll_interval'] )
-                {
-                        $_SESSION['poll_interval']      = $poll_interval;
-                }
-        }
-        else
-        {
-                $_SESSION['poll_interval']      = $poll_interval;
-        }
-
-        session_write_close();
-
-        $session_active = false;
-}
-
-function checkSession()
-{
-        global $session_active, $_SESSION;
-
-        session_start();
-
-        $session_active         = true;
-
-        // I got nothing; create session
-        //
-        if( ! isset( $_SESSION['gather_time'] ) || ! isset( $_SESSION['data'] ) )
-        {
-                makeSession();
-
-                return 0;
-        }
-
-        if( isset( $_SESSION['poll_interval'] ) )
-        {
-                $gather_time    = $_SESSION['gather_time'];
-                $poll_interval  = $_SESSION['poll_interval'];
-
-                $cur_time       = time();
-
-                // If poll_interval time elapsed since last update; recreate session
-                //
-                if( ($cur_time - $gather_time) >= $poll_interval )
-                {
-                        makeSession();
-
-                        return 0;
-                }
-        }
-}
-
-checkSession();
-$myxml_data	= &$_SESSION['data'];
-session_write_close();
-
 $httpvars	= new HTTPVariables( $HTTP_GET_VARS, $_GET );
 $view		= $httpvars->getHttpVar( "view" );
@@ -116,4 +38,22 @@
 $query		= $httpvars->getHttpVar( "query" );
 $clustername	= $httpvars->getClusterName();
+
+global $mySession, $myData, $myXML;
+
+//printf( "c %s\n", $clustername );
+
+$mySession      = new SessionHandler( $clustername );
+$mySession->checkSession();
+
+$session        = &$mySession->getSession();
+$myXML		= $session['data'];
+
+$myData         = new DataGatherer( $clustername );
+$myData->parseXML( $myXML );
+
+$mySession->updatePollInterval( $myData->getPollInterval() );
+$mySession->endSession();
+
+//printf( "%s\n", strlen( $myXML ) );
 
 if( isset($jid) && ($jid!='')) $filter['jid']=$jid;
@@ -124,14 +64,11 @@
 if( isset($query) && ($query!='')) $filter['query']=$query;
 
-$data_gatherer  = new DataGatherer( $clustername );
-$data_gatherer->parseXML( &$myxml_data );
-
 function drawHostImage()
 {
-	global $clustername, $hostname, $data_gatherer;
+	global $clustername, $hostname, $myData;
 
-	if( $data_gatherer->isJobmonRunning() )
+	if( $myData->isJobmonRunning() )
 	{
-		$ic = new HostImage( $data_gatherer, $clustername, $hostname );
+		$ic = new HostImage( $myData, $clustername, $hostname );
 	}
 	else
@@ -145,14 +82,19 @@
 function drawSmallClusterImage() 
 {
-	global $clustername, $data_gatherer, $myxml_data;
+	global $clustername, $myData, $myXML;
 
-	if( $data_gatherer->isJobmonRunning() )
+	//printf( "%s\n", strlen( $myXML ) );
+
+	if( $myData->isJobmonRunning() )
 	{
-		$ic = new ClusterImage( $myxml_data, $clustername );
+		//$ic = new ClusterImage( $myXML, $clustername );
+		$ic = new ClusterImage( $myData, $clustername );
 		$ic->setSmall();
+		//printf( "is running\n" );
 	}
 	else
 	{
 		$ic = new EmptyImage();
+		//printf( "not running\n" );
 	}
 
@@ -162,7 +104,8 @@
 function drawBigClusterImage()
 {
-	global $filter, $clustername, $myxml_data;
+	global $filter, $clustername, $myXML, $myData;
 
-	$ic = new ClusterImage( $myxml_data, $clustername );
+	//$ic = new ClusterImage( $myXML, $clustername );
+	$ic = new ClusterImage( $myData, $clustername );
 	$ic->setBig();
 
Index: trunk/web/addons/job_monarch/index.php
===================================================================
--- trunk/web/addons/job_monarch/index.php	(revision 647)
+++ trunk/web/addons/job_monarch/index.php	(revision 648)
@@ -23,5 +23,6 @@
  */
 
-ini_set("memory_limit","200M");
+//ini_set("memory_limit","200M");
+ini_set("memory_limit","1G");
 set_time_limit(0);
 
@@ -44,7 +45,23 @@
 chdir( $my_dir );
 
-$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
-$clustername = $httpvars->getClusterName();
-$view = $httpvars->getHttpVar( "view" );
+$httpvars	= new HTTPVariables( $HTTP_GET_VARS, $_GET );
+$clustername	= $httpvars->getClusterName();
+$view		= $httpvars->getHttpVar( "view" );
+
+global $mySession, $myData, $myXML;
+
+//printf( "c %s\n", $clustername );
+
+$mySession      = new SessionHandler( $clustername );
+$mySession->checkSession();
+
+$session        = &$mySession->getSession();
+$myXML          = $session['data'];
+
+$myData         = new DataGatherer( $clustername );
+$myData->parseXML( $myXML );
+
+$mySession->updatePollInterval( $myData->getPollInterval() );
+$mySession->endSession();
 
 $filter = array();
@@ -94,314 +111,4 @@
 }
 
-function makeHeader( $page_call, $title, $longtitle )
-{
-	global $tpl, $grid, $context, $initgrid;
-	global $jobrange, $jobstart;
-	global $page, $gridwalk, $clustername;
-	global $parentgrid, $physical, $hostname;
-	global $self, $filter, $cluster_url, $get_metric_string;
-	global $metrics, $reports, $m, $default_metric;
-	global $default_refresh, $filterorder, $view;
-	global $JOB_ARCHIVE, $period_start, $period_stop, $h, $id;
-	global $job_start, $job_stop, $range, $r, $metricname;
-	
-	if( isset($default_metric) and !isset($m) )
-		$metricname = $default_metric;
-	else
-		if( isset( $m ) )
-			$metricname = $m;
-		else
-			$metricname = "load_one";
-
-	$header = "header";
-
-	# Maintain our path through the grid tree.
-	$me = $self . "@" . $grid[$self]['AUTHORITY'];
-
-	$gridstack = array();
-	$gridstack[] = $me;
-
-	if ($gridwalk=="fwd")
-	{
-		# push our info on gridstack, format is "name@url>name2@url".
-		if (end($gridstack) != $me)
-		{
-			$gridstack[] = $me;
-		}
-	}
-	else if ($gridwalk=="back") 
-	{
-		# pop a single grid off stack.
-		if (end($gridstack) != $me) 
-		{
-			array_pop($gridstack);
-		}
-	}
-
-	$gridstack_str = join(">", $gridstack);
-	$gridstack_url = rawurlencode($gridstack_str);
-
-	if ($initgrid or $gridwalk) 
-	{
-		# Use cookie so we dont have to pass gridstack around within this site.
-		# Cookie values are automatically urlencoded. Expires in a day.
-		setcookie("gs", $gridstack_str, time() + 86400);
-	}
-
-	# Invariant: back pointer is second-to-last element of gridstack. Grid stack never
-	# has duplicate entries.
-	list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]);
-
-	# Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell
-	# destination server that we're walking foward in the grid tree.
-	if (strstr($clustername, "http://")) 
-	{
-		$tpl->assign("refresh", "0");
-		$tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url");
-		echo "<h2>Redirecting, please wait...</h2>";
-		$tpl->printToScreen();
-		exit;
-	}
-	$tpl->gotoBlock( "_ROOT" );
-
-	if( $view != "search" )
-		$tpl->assign( "refresh", $default_refresh );
-
-	$tpl->assign( "date", date("r") );
-	//printf("lg %s\n", $longtitle );
-	//printf("title %s\n", $title );
-	$tpl->assign( "longpage_title", $longtitle );
-	$tpl->assign( "page_title", $title );
-
-	# The page to go to when "Get Fresh Data" is pressed.
-	$tpl->assign("page","./");
-
-	# Templated Logo image
-	$tpl->assign("images","./templates/$template_name/images");
-
-	#
-	# Used when making graphs via graph.php. Included in most URLs
-	#
-	$sort_url=rawurlencode($sort);
-	$get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols";
-
-	if ($jobrange and $jobstart)
-		$get_metric_string .= "&jr=$jobrange&js=$jobstart";
-
-	# Set the Alternate view link.
-	$cluster_url=rawurlencode($clustername);
-	$node_url=rawurlencode($hostname);
-
-	# Make some information available to templates.
-	$tpl->assign("cluster_url", $cluster_url);
-	# Build the node_menu
-	$node_menu = "";
-
-	if ($parentgrid) 
-	{
-		$node_menu .= "<B>$parentgrid $meta_designator</B> ";
-		$node_menu .= "<B>&gt;</B>\n";
-	}
-
-	# Show grid.
-	$mygrid =  ($self == "unspecified") ? "" : $self;
-	$node_menu .= "<B><A HREF=\"../..\">$mygrid $meta_designator</A></B> ";
-	$node_menu .= "<B>&gt;</B>\n";
-
-	if ($physical)
-	{
-		$node_menu .= hiddenvar("p", $physical);
-	}
-
-	if ( $clustername ) 
-	{
-		$url = rawurlencode($clustername);
-		$node_menu .= "<B><A HREF=\"../../?c=".rawurlencode($clustername)."\">$clustername</A></B> ";
-		$node_menu .= "<B>&gt;</B>\n";
-		$node_menu .= hiddenvar("c", $clustername);
-	}
-
-	if (!count($metrics)) 
-	{
-		echo "<h4>Cannot find any metrics for selected cluster \"$clustername\", exiting.</h4>\n";
-		echo "Check ganglia XML tree (telnet $ganglia_ip $ganglia_port)\n";
-		exit;
-	}
-	reset($metrics);
-	$firsthost = key($metrics);
-
-	$mmfh	= array();
-
-	$mmfh	= $metrics[$firsthost];
-
-	$context_metrics	= array();
-
-	//foreach ($mmfh as $mm => $mfoo)
-	foreach( $mmfh as $mm => $bla )
-	{
-		$context_metrics[] = $mm;
-	}
-
-	foreach ($reports as $mr => $mfoo)
-		$context_metrics[] = $mr;
-
-	$node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">Joblist</A></B> ";
-
-	if( isset( $hostname ) && ( $view != 'host' ) ) 
-	{
-		$node_menu .= "<B>&gt;</B>\n";
-		$href = "<A HREF=\"./?c=".rawurlencode($clustername)."&h=".$hostname."\">";
-		$node_menu .= "<B>$href";
-		$node_menu .= "host: $hostname</A></B> ";
-	}
-
-	if( count( $filter ) > 0 && $view != "search" ) 
-	{
-		$my_ct = 1;
-		$filter_nr = count( $filter );
-
-		foreach( $filter as $filtername=>$filterval ) 
-		{
-			$node_menu .= "<B>&gt;</B>\n";
-
-			$href = "<A HREF=\"./?c=".rawurlencode($clustername);
-			$temp_ct = 0;
-			$n_filter = $filter;
-			$my_filterorder = "";
-			$my_filters = array_keys( $filter );
-
-			foreach( $n_filter as $n_filtername=>$n_filterval ) 
-			{
-				if( $temp_ct < $my_ct ) 
-				{
-					$href .= "&". $n_filtername . "=" . $n_filterval;
-
-					if( $my_filterorder == "" )
-						$my_filterorder = $my_filters[$temp_ct];
-					else
-						$my_filterorder .= "," . $my_filters[$temp_ct];
-				}
-
-				$temp_ct++;
-			}
-			$href .= "&filterorder=$my_filterorder\">";
-
-			if( $my_ct < $filter_nr )
-				$node_menu .= "<B>$href$filtername: $filterval</A></B> ";
-			else
-				$node_menu .= "<B>$filtername: $filterval</B> ";
-
-			$my_ct++;
-		}
-	}
-
-	$tpl->gotoBlock( "_ROOT" );
-	$tpl->assignGlobal("view", $view);
-
-	if( array_key_exists( "id", $filter ) or isset($hostname) ) 
-	{
-		$range = "job";
-
-		if( $page_call != "host_view" )
-		{
-			if (is_array($context_metrics) ) 
-			{
-				$metric_menu = "<B>Metric</B>&nbsp;&nbsp;"
-					."<SELECT NAME=\"m\" OnChange=\"toga_form.submit();\">\n";
-
-				sort($context_metrics);
-				foreach( $context_metrics as $k ) 
-				{
-					$url = rawurlencode($k);
-					$metric_menu .= "<OPTION VALUE=\"$url\" ";
-					if ($k == $metricname )
-						$metric_menu .= "SELECTED";
-					$metric_menu .= ">$k\n";
-				}
-				$metric_menu .= "</SELECT>\n";
-			}
-
-		}
-
-		$tpl->assign("metric_menu", $metric_menu );
-
-		if( $view == "search" or $view == "host" ) 
-		{
-			$tpl->newBlock("timeperiod");
-			if( is_numeric( $period_start ) ) 
-			{
-				$period_start = epochToDatetime( $period_start );
-			}
-			if( is_numeric( $period_stop ) ) 
-			{
-				$period_stop = epochToDatetime( $period_stop );
-			}
-			$tpl->assign("period_start", $period_start );
-			$tpl->assign("period_stop", $period_stop );
-			$tpl->assign("hostname", $hostname );
-
-			if( $view == "host" ) 
-			{
-				$tpl->newBlock("hostview");
-				$tpl->assign("job_start", $job_start );
-				$tpl->assign("job_stop", $job_stop );
-			}
-		} 
-
-	}
-
-	if( $view != "search" )
-	{
-		$context_ranges[]="hour";
-		$context_ranges[]="day";
-		$context_ranges[]="week";
-		$context_ranges[]="month";
-		$context_ranges[]="year";
-		$context_ranges[]="job";
-
-		$range_menu = "<B>Last</B>&nbsp;&nbsp;" ."<SELECT NAME=\"r\" OnChange=\"toga_form.submit();\">\n";
-		foreach ($context_ranges as $v) 
-		{
-			$url=rawurlencode($v);
-			$range_menu .= "<OPTION VALUE=\"$url\" ";
-			if ($v == $range)
-				$range_menu .= "SELECTED";
-			$range_menu .= ">$v\n";
-		}
-		$range_menu .= "</SELECT>\n";
-
-		$tpl->assign("range_menu", $range_menu);
-
-	}
-
-	if( $view == "search" or $view == "host" ) 
-	{
-		$node_menu .= "<B>&gt;</B>\n";
-		$node_menu .= "<B>Jobarchive</B> ";
-		$form_name = "archive_search_form";
-		$tpl->assignGlobal("form_name", $form_name );
-	}
-	else
-	{
-		$form_name = "toga_form";
-		$tpl->assignGlobal("form_name", $form_name );
-	}
-
-	if( $JOB_ARCHIVE && $page_call == 'overview' ) 
-	{
-		$tpl->newBlock( "search" );
-		$tpl->assignGlobal( "cluster_url", rawurlencode($clustername) );
-		$tpl->assignGlobal( "cluster", $clustername );
-	}
-	$tpl->gotoBlock( "_ROOT" );
-	$tpl->assignGlobal( "cluster", $clustername );
-	$tpl->assign("node_menu", $node_menu);
-
-	# Make sure that no data is cached..
-	header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    # Date in the past
-	header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified
-	header ("Cache-Control: no-cache, must-revalidate");  # HTTP/1.1
-	header ("Pragma: no-cache");                          # HTTP/1.0
-}
 
 function makeFooter() 
@@ -456,4 +163,11 @@
 	$hostname = $h;
 }
+$ic                     = new ClusterImage( $myData, $clustername );
+$ic->setBig();
+$ic->setNoimage();
+$ic->draw();
+
+//printf("%s\n", $ic->getImagemapArea() );
+
 
 switch( $view ) 
@@ -461,20 +175,20 @@
 	case "overview":
 
-		includeOverview();
+		//includeOverview();
 		break;
 
 	case "search":
 
-		includeSearchPage();
+		//includeSearchPage();
 		break;
 
 	case "host":
 
-		includeHostPage();
+		//includeHostPage();
 		break;
 
 	default:
 
-		includeOverview();
+		//includeOverview();
 		break;
 }
@@ -488,27 +202,38 @@
 $tpl->assign("cluster", $clustername );
 
+session_start();
+$tpl->assign( "session_name", session_name() );
+$tpl->assign( "session_id", session_id() );
+
+$rjqj_str .= "./graph.php?z=small&c=$clustername&g=job_report&r=$range&st=$cluster[LOCALTIME]";
+
+$tpl->assign( "rjqj_graph", $rjqj_str );
+$tpl->assign( "uue_clustername", rawurlencode($clustername) );
+
+$tpl->assign( "node_area_map", $ic->getImagemapArea() );
+
 switch( $view ) 
 {
 	case "overview":
 
-		include "./overview.php";
-		makeOverview();
+		//include "./overview.php";
+		//makeOverview();
 		break;
 
 	case "search":
 
-		include "./search.php";
-		makeSearchPage();
+		//include "./search.php";
+		//makeSearchPage();
 		break;
 
 	case "host":
 
-		include "./host_view.php";
-		makeHostView();
+		//include "./host_view.php";
+		//makeHostView();
 		break;
 
 	default:
 
-		makeOverview();
+		//makeOverview();
 		break;
 }
Index: trunk/web/addons/job_monarch/jobstore.php
===================================================================
--- trunk/web/addons/job_monarch/jobstore.php	(revision 647)
+++ trunk/web/addons/job_monarch/jobstore.php	(revision 648)
@@ -1,6 +1,10 @@
 <?php
 
-ini_set("memory_limit","200M");
+ini_set("memory_limit","1G");
 set_time_limit(0);
+
+//ini_set("xdebug.profiler_output_dir","/tmp");
+//ini_set("xdebug.profiler_output_name","timestamp");
+//ini_set("xdebug.profiler_enable","1");
 
 $c			= $_POST['c'];
@@ -53,94 +57,39 @@
 $_GET['c']		= $c;
 
-global $c, $clustername, $cluster;
+global $c, $clustername, $cluster, $mySession;
 
 include_once "./libtoga.php";
 
-function makeSession()
-{
-	$ds             = new DataSource();
-	$myxml_data     = &$ds->getData();
-
-	unset( $_SESSION['data'] );
-
-	$_SESSION['data']		= &$myxml_data;
-	$_SESSION['gather_time']	= time();
-}
-
-global $session_active, $_SESSION;
-
-function checkSessionPollInterval( $poll_interval )
-{
-	global $session_active, $_SESSION;
-
-	if( ! session_active )
-	{
-		return 0;
-	}
-
-	if( isset( $_SESSION['poll_interval'] ) )
-	{
-		if( $poll_interval <> $_SESSION['poll_interval'] )
-		{
-			$_SESSION['poll_interval']	= $poll_interval;
-		}
-	}
-	else
-	{
-		$_SESSION['poll_interval']	= $poll_interval;
-	}	
-
-	session_write_close();
-
-	$session_active	= false;
-}
-
-function checkSession()
-{
-	global $session_active, $_SESSION;
-
-	session_start();
-
-	$session_active 	= true;
-
-	// I got nothing; create session
-	//
-	if( ! isset( $_SESSION['gather_time'] ) || ! isset( $_SESSION['data'] ) )
-	{
-		makeSession();
-
-		return 0;	
-	}
-
-	if( isset( $_SESSION['poll_interval'] ) )
-	{
-		$gather_time	= $_SESSION['gather_time'];
-		$poll_interval	= $_SESSION['poll_interval'];
-
-		$cur_time	= time();
-
-		// If poll_interval time elapsed since last update; recreate session
-		//
-		if( ($cur_time - $gather_time) >= $poll_interval )
-		{
-			makeSession();
-
-			return 0;	
-		}
-	}
-}
-
-checkSession();
-
-global $jobs, $metrics;
-
-$data_gatherer  = new DataGatherer( $clustername );
-$data_gatherer->parseXML( &$_SESSION['data'] );
-
-$heartbeat      = &$data_gatherer->getHeartbeat();
-$jobs           = &$data_gatherer->getJobs();
-//$gnodes         = $data_gatherer->getNodes();
-$cpus           = &$data_gatherer->getCpus();
-$use_fqdn       = &$data_gatherer->getUsingFQDN();
+
+global $jobs, $metrics, $session;
+
+//printf( "c %s\n", $clustername );
+
+$mySession	= new SessionHandler( $clustername );
+$mySession->checkSession();
+
+$session	= &$mySession->getSession();
+$myXML		= $session['data'];
+
+//printf( "gt %s\n", $session['gather_time'] );
+//printf( "pi %s\n", $session['poll_interval'] );
+
+$myData		= new DataGatherer( $clustername );
+$myData->parseXML( $myXML );
+
+$mySession->updatePollInterval( $myData->getPollInterval() );
+//printf( "pi %s\n", $myData->getPollInterval() );
+//printf( "pi %s\n", $session['poll_interval'] );
+$mySession->endSession();
+
+
+$heartbeat      = &$myData->getHeartbeat();
+$jobs           = &$myData->getJobs();
+$cpus           = &$myData->getCpus();
+$use_fqdn       = &$myData->getUsingFQDN();
+
+//print_r( $jobs );
+
+//print_r( $session );
 
 // The ext grid script will send  a task field which will specify what it wants to do
@@ -518,5 +467,5 @@
 {
 	global $jobs, $jobids, $clustername, $metrics, $jid, $p_metricname;
-	global $always_timestamp, $always_constant;
+	global $always_timestamp, $always_constant, $mySession;
 
 	$display_nodes	= array();
@@ -566,5 +515,5 @@
 		$poll_interval	= (int) $jobs[$jid]['poll_interval'];
 
-		checkSessionPollInterval( $poll_interval );
+		//$mySession->updatePollInterval( $poll_interval );
 
 		$time		= time();
@@ -636,5 +585,5 @@
 	global $jobs, $hearbeat, $pstart, $pend;
 	global $sortfield, $sortorder, $query, $host;
-	global $jid, $owner, $queue,  $status;
+	global $jid, $owner, $queue,  $status, $mySession;
 
 	$job_count		= count( $jobs );
@@ -686,5 +635,5 @@
 		$poll_interval		= (int) $jobs[$jobid]['poll_interval'];
 
-		checkSessionPollInterval( $poll_interval );
+		//$mySession->updatePollInterval( $poll_interval );
 
 		if( $jr['status'] == 'R' )
Index: trunk/web/addons/job_monarch/libtoga.php
===================================================================
--- trunk/web/addons/job_monarch/libtoga.php	(revision 647)
+++ trunk/web/addons/job_monarch/libtoga.php	(revision 648)
@@ -137,4 +137,88 @@
 }
 
+class SessionHandler
+{
+	var $cluster, $poll_stored;
+
+	function SessionHandler( $cluster )
+	{
+		$this->cluster		= $cluster;
+		$this->ds		= new DataSource( $this->cluster );
+
+		//ob_start();
+		session_start();
+	}
+
+	function refreshSession()
+	{
+		$ds			= &$this->ds;
+		$myxml_data		= $ds->getData();
+
+		$_SESSION['data']		= &$myxml_data;
+		$_SESSION['gather_time']	= time();
+	}
+
+	function hasSession()
+	{
+		return ( $this->have_session );
+	}
+
+	function getSession()
+	{
+		return $_SESSION;
+
+	}
+
+	function endSession()
+	{
+		session_write_close();
+		//ob_end_flush();
+		//session_unlock();
+		//session_destroy();
+	}
+
+	function updatePollInterval( $poll_interval )
+	{
+		//if( ! isset( $_SESSION['poll_interval'] ) )
+		//{
+			$_SESSION['poll_interval']      = $poll_interval;
+		//}
+	}
+
+	function checkSession()
+	{
+		// I got nothing; create session
+		//
+		//if( ! $this->have_session )
+		//{
+		//	$this->refreshSession();
+		//
+		//	return 0;
+		//}
+
+		//if( $this->poll_stored )
+		//{
+		//	session_start();
+
+			if( isset( $_SESSION['gather_time'] ) && isset( $_SESSION['poll_interval'] ) )
+			{
+
+				$gather_time    = $_SESSION['gather_time'];
+				$poll_interval  = $_SESSION['poll_interval'];
+
+				// If poll_interval time elapsed since last update; recreate session
+				//
+				if( (time() - $gather_time) >= $poll_interval )
+				{
+					$this->refreshSession();
+				}
+			}
+			else
+			{
+				$this->refreshSession();
+			}
+		//}
+	}
+}
 
 class TarchDbase
@@ -459,5 +543,5 @@
 	var $data, $ip, $port;
 
-	function DataSource()
+	function DataSource( $cluster )
 	{
 		global $DATA_SOURCE;
@@ -470,5 +554,5 @@
 		$this->ip 	= $ds_ip;
 		$this->port 	= $ds_port;
-
+		$this->cluster	= $cluster;
 	}
 
@@ -487,4 +571,14 @@
 		}
 
+		$clustername	= $this->cluster;
+
+		$rc = fputs($fp, "/$clustername"."\n" );
+
+		if (!$rc)
+		{
+			echo "Could not sent request to gmetad: $errstr";
+			return;
+		}
+
 		stream_set_timeout( $fp, 30 );
 
@@ -515,4 +609,5 @@
 		$this->xmlhandler 	= new TorqueXMLHandler( $this->cluster );
 
+		xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
 		xml_set_element_handler( $this->parser, array( &$this->xmlhandler, 'startElement' ), array( &$this->xmlhandler, 'stopElement' ) );
 
@@ -521,4 +616,12 @@
 			$error = sprintf( 'XML error: %s at %d', xml_error_string( xml_get_error_code( $this->parser ) ), xml_get_current_line_number( $this->parser ) );
 		}
+	}
+
+	function getPollInterval()
+	{
+		$handler = $this->xmlhandler;
+		//printf("d i %s\n", $handler->getPollInterval() );
+
+		return $handler->getPollInterval();
 	}
 
@@ -555,6 +658,6 @@
 	function getJobs()
 	{
-		$handler = $this->xmlhandler;
-		return $handler->getJobs();
+		$handler = &$this->xmlhandler;
+		return ( $handler->getJobs() );
 	}
 
@@ -593,4 +696,11 @@
 		$this->fqdn		= 0;
 		$this->fqdnFound	= 0;
+		$this->pollinterval	= 0;
+	}
+
+	function getPollInterval()
+	{
+		//printf( "t pi %s\n", $this->pollinterval );
+		return ( $this->pollinterval );
 	}
 
@@ -621,9 +731,9 @@
 		if (isset( $this->heartbeat['time'] ))
 		{
-			return 1;
+			return true;
 		}
 		else
 		{
-			return 0;
+			return false;
 		}
 	}
@@ -633,5 +743,5 @@
 		// Should hostname be FQDN or short w/o domain
 		//
-		$nodes = &$this->nodes;
+		//$nodes = &$this->nodes;
 
 		$domain_len	= 0 - strlen( $tdomain );
@@ -640,4 +750,5 @@
 		{
 			if( substr( $thostname, $domain_len ) != $tdomain )
+			//if( strpos( $thostname, $tdomain ) !== false )
 			{
 				$thostname = $thostname . '.'.$tdomain;
@@ -650,6 +761,6 @@
 	function startElement( $parser, $name, $attrs )
 	{
-		$jobs = $this->jobs;
-		$nodes = $this->nodes;
+		$jobs	= $this->jobs;
+		$nodes	= $this->nodes;
 
 		if ( $attrs['TN'] )
@@ -664,9 +775,10 @@
 		$jobid = null;
 
-		if( $name == 'CLUSTER' )
-		{
-			$this->proc_cluster = $attrs['NAME'];
-		}
-		else if( $name == 'HOST' and $this->proc_cluster == $this->clustername)
+		//if( $name == 'CLUSTER' )
+		//{
+		//	$this->proc_cluster = $attrs['NAME'];
+		//}
+		//else if( $name == 'HOST' and $this->proc_cluster == $this->clustername)
+		if( $name == 'HOST' )
 		{
 			$hostname = $attrs['NAME'];
@@ -698,11 +810,12 @@
 			}
 		}
-		else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
-		{
-			if( strstr( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) )
+		//else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
+		else if( ($name == 'METRIC') && (strpos( $attrs['NAME'], 'MONARCH' ) !== false) )
+		{
+			if( strpos( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) !== false )
 			{
 				$this->heartbeat['time'] = $attrs['VAL'];
 			}
-			else if( strstr( $attrs['NAME'], 'MONARCH-DOWN' ) )
+			else if( strpos( $attrs['NAME'], 'MONARCH-DOWN' ) !== false)
 			{
 				$fields		= explode( ' ', $attrs['VAL'] );
@@ -717,4 +830,5 @@
 					$toganame	= $togavalues[0];
 					$togavalue	= $togavalues[1];
+
 
 					if( $toganame == 'nodes' )
@@ -746,5 +860,5 @@
 				}
 			}
-			else if( strstr( $attrs['NAME'], 'MONARCH-OFFLINE' ) )
+			else if( strpos( $attrs['NAME'], 'MONARCH-OFFLINE' ) !== false )
 			{
 				$fields		= explode( ' ', $attrs['VAL'] );
@@ -788,5 +902,5 @@
 				}
 			}
-			else if( strstr( $attrs['NAME'], 'MONARCH-JOB' ) )
+			else if( strpos( $attrs['NAME'], 'MONARCH-JOB' ) !== false )
 			{
 				sscanf( $attrs['NAME'], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
@@ -805,4 +919,6 @@
 					$toganame = $togavalues[0];
 					$togavalue = $togavalues[1];
+
+					//printf( "tn %s\n", $toganame );
 
 					if( $toganame == 'nodes' )
@@ -830,4 +946,9 @@
 							$jobs[$jobid][$toganame] = $togavalue;
 						}
+					}
+					else if( $toganame == 'poll_interval' )
+					{
+						$this->pollinterval	= $togavalue;
+						//printf("u pi %s\n", $togavalue );
 					}
 					else
@@ -1352,8 +1473,9 @@
 	var $filtername, $filters;
 
-	function ClusterImage( $data, $clustername )
-	{
-		$this->dataget		= new DataGatherer( $clustername );
-		$this->data		= $data;
+	function ClusterImage( $datag, $clustername )
+	{
+		//$this->dataget		= new DataGatherer( $clustername );
+		$this->dataget		= $datag;
+		//$this->data		= $data;
 		$this->clustername	= $clustername;
 		$this->filters		= array();
@@ -1503,6 +1625,6 @@
 		}
 
-		$mydatag = $this->dataget;
-		$mydatag->parseXML( $this->data );
+		$mydatag		= &$this->dataget;
+		//$mydatag->parseXML( $this->data );
 
 		if( $this->isSmall() )
@@ -1518,4 +1640,5 @@
 
 		$nodes		= $mydatag->getNodes();
+		//print_r( $nodes);
 		$nodes_hosts	= array_keys( $nodes );
 
@@ -1556,5 +1679,5 @@
 		$this->height	= ($y_offset + (($node_rows*$node_width)+1) );
 
-		$jobs = $mydatag->getJobs();
+		$jobs		= $mydatag->getJobs();
 		$filtered_nodes = $this->filterNodes( $jobs, $nodes );
 		$selected_host	= $this->selected;
Index: trunk/web/addons/job_monarch/overview.php
===================================================================
--- trunk/web/addons/job_monarch/overview.php	(revision 647)
+++ trunk/web/addons/job_monarch/overview.php	(revision 648)
@@ -35,8 +35,8 @@
 
 $ds		= new DataSource();
-$myxml_data	= $ds->getData();
+//$myxml_data	= $ds->getData();
 
 $data_gatherer	= new DataGatherer( $clustername );
-$data_gatherer->parseXML( $myxml_data );
+//$data_gatherer->parseXML( $myxml_data );
 
 $heartbeat	= $data_gatherer->getHeartbeat();
Index: trunk/web/addons/job_monarch/templates/header.tpl
===================================================================
--- trunk/web/addons/job_monarch/templates/header.tpl	(revision 647)
+++ trunk/web/addons/job_monarch/templates/header.tpl	(revision 648)
@@ -47,5 +47,5 @@
 	GraphSummaryWindow.show();
 
-	ClusterImageWindow.html			= '<IMG ID="clusterimage" SRC="{clusterimage}" USEMAP="#MONARCH_CLUSTER_BIG" BORDER="0">';
+	ClusterImageWindow.html			= '<IMG ID="clusterimage" SRC="./image.php?{session_name}={session_id}" USEMAP="#MONARCH_CLUSTER_BIG" BORDER="0">';
 	ClusterImageWindow.show();
 	setClusterImagePosition();
@@ -59,5 +59,5 @@
 
 	Ext.get( 'rjqjgraph' ).update( '<IMG ID="rjqj_graph" SRC="{rjqj_graph}" BORDER=0>' );
-	Ext.get( 'pie' ).update( '<IMG ID="pie" SRC="{pie}" BORDER=0>' );
+	//Ext.get( 'pie' ).update( '<IMG ID="pie" SRC="./image.php?{session_name}={session_id}&c={uue_clustername}&view=big-clusterimage" BORDER=0>' );
 });
 </script>
@@ -73,6 +73,4 @@
 
     <MAP NAME="MONARCH_CLUSTER_BIG">
-    <!-- START BLOCK : node_clustermap -->
     {node_area_map}
-    <!-- END BLOCK : node_clustermap -->
     </MAP> 
