Index: trunk/web2/addons/job_monarch/libtoga.php
===================================================================
--- trunk/web2/addons/job_monarch/libtoga.php	(revision 576)
+++ trunk/web2/addons/job_monarch/libtoga.php	(revision 577)
@@ -236,5 +236,5 @@
 
 			$count_result = $this->queryDbase( $count_query );
-			$this->resultcount = (int) $count_result[0][count];
+			$this->resultcount = (int) $count_result[0]['count'];
 
 			$select_query = "SELECT " . $select_result_idname . " " . $query . " ORDER BY job_id DESC LIMIT " . $SEARCH_RESULT_LIMIT;
@@ -247,5 +247,5 @@
 		foreach( $ids as $crow)
 		{
-			$ret[] = $crow[job_id];
+			$ret[] = $crow['job_id'];
 		}
 
@@ -261,5 +261,5 @@
 		foreach( $result as $result_row ) 
 		{
-			$nodes[] = $this->getNodeArray( $result_row[node_id] );
+			$nodes[] = $this->getNodeArray( $result_row['node_id'] );
 		}
 
@@ -275,5 +275,5 @@
 		foreach( $result as $result_row )
 		{
-			$jobs[] = $this->getJobArray( $result_row[job_id] );
+			$jobs[] = $this->getJobArray( $result_row['job_id'] );
 		}
 		return $jobs;
@@ -608,6 +608,6 @@
 			foreach( $this->jobs as $jobid=>$jobattrs )
 			{
-				$nodes	= count( $jobattrs[nodes] );
-				$ppn	= (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1;
+				$nodes	= count( $jobattrs['nodes'] );
+				$ppn	= (int) $jobattrs['ppn'] ? $jobattrs['ppn'] : 1;
 				$mycpus	= $nodes * $ppn;
 
@@ -653,8 +653,8 @@
 		$nodes = $this->nodes;
 
-		if ( $attrs[TN] )
+		if ( $attrs['TN'] )
 		{
 			// Ignore dead metrics. Detect and mask failures.
-			if ( $attrs[TN] > $attrs[TMAX] * 4 )
+			if ( $attrs['TN'] > $attrs['TMAX'] * 4 )
 			{
 				return;
@@ -666,9 +666,9 @@
 		if( $name == 'CLUSTER' )
 		{
-			$this->proc_cluster = $attrs[NAME];
+			$this->proc_cluster = $attrs['NAME'];
 		}
 		else if( $name == 'HOST' and $this->proc_cluster == $this->clustername)
 		{
-			$hostname = $attrs[NAME];
+			$hostname = $attrs['NAME'];
 
 			// Assume to use FQDN if we find a '.' in the hostname
@@ -691,5 +691,5 @@
 			}
 
-			$location = $attrs[LOCATION];
+			$location = $attrs['LOCATION'];
 
 			if( !isset( $nodes[$hostname] ) )
@@ -698,13 +698,13 @@
 			}
 		}
-		else if( $name == 'METRIC' and strstr( $attrs[NAME], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
-		{
-			if( strstr( $attrs[NAME], 'MONARCH-HEARTBEAT' ) )
-			{
-				$this->heartbeat['time'] = $attrs[VAL];
-			}
-			else if( strstr( $attrs[NAME], 'MONARCH-DOWN' ) )
-			{
-				$fields		= explode( ' ', $attrs[VAL] );
+		else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
+		{
+			if( strstr( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) )
+			{
+				$this->heartbeat['time'] = $attrs['VAL'];
+			}
+			else if( strstr( $attrs['NAME'], 'MONARCH-DOWN' ) )
+			{
+				$fields		= explode( ' ', $attrs['VAL'] );
 
 				$nodes_down	= array();
@@ -746,7 +746,7 @@
 				}
 			}
-			else if( strstr( $attrs[NAME], 'MONARCH-OFFLINE' ) )
-			{
-				$fields		= explode( ' ', $attrs[VAL] );
+			else if( strstr( $attrs['NAME'], 'MONARCH-OFFLINE' ) )
+			{
+				$fields		= explode( ' ', $attrs['VAL'] );
 
 				$nodes_offline	= array();
@@ -788,7 +788,7 @@
 				}
 			}
-			else if( strstr( $attrs[NAME], 'MONARCH-JOB' ) )
-			{
-				sscanf( $attrs[NAME], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
+			else if( strstr( $attrs['NAME'], 'MONARCH-JOB' ) )
+			{
+				sscanf( $attrs['NAME'], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
 
 				if( !isset( $jobs[$jobid] ) )
@@ -797,5 +797,5 @@
 				}
 
-				$fields = explode( ' ', $attrs[VAL] );
+				$fields = explode( ' ', $attrs['VAL'] );
 
 				foreach( $fields as $f )
@@ -808,5 +808,5 @@
 					if( $toganame == 'nodes' )
 					{
-						if( $jobs[$jobid][status] == 'R' )
+						if( $jobs[$jobid]['status'] == 'R' )
 						{
 							if( !isset( $jobs[$jobid][$toganame] ) )
@@ -826,5 +826,5 @@
 
 						}
-						else if( $jobs[$jobid][status] == 'Q' )
+						else if( $jobs[$jobid]['status'] == 'Q' )
 						{
 							$jobs[$jobid][$toganame] = $togavalue;
@@ -837,17 +837,17 @@
 				}
 
-				if( isset( $jobs[$jobid][nodes] ) )
-				{
-					$nr_nodes = count( $jobs[$jobid][nodes] );
+				if( isset( $jobs[$jobid]['nodes'] ) )
+				{
+					$nr_nodes = count( $jobs[$jobid]['nodes'] );
 		
-					if( $jobs[$jobid][status] == 'R' )
+					if( $jobs[$jobid]['status'] == 'R' )
 					{
-						if( isset( $jobs[$jobid][domain] ) )
+						if( isset( $jobs[$jobid]['domain'] ) )
 						{
-							$domain		= $jobs[$jobid][domain];
+							$domain		= $jobs[$jobid]['domain'];
 						}
 						$job_nodes	= array();
 
-						foreach( $jobs[$jobid][nodes] as $node )
+						foreach( $jobs[$jobid]['nodes'] as $node )
 						{
 							// Only add domain name to the hostname if Ganglia is doing that too
@@ -866,7 +866,7 @@
 							if( !$my_node->hasJob( $jobid ) )
 							{
-								if( isset( $jobs[$jobid][ppn] ) )
+								if( isset( $jobs[$jobid]['ppn'] ) )
 								{
-									$my_node->addJob( $jobid, ((int) $jobs[$jobid][ppn]) );
+									$my_node->addJob( $jobid, ((int) $jobs[$jobid]['ppn']) );
 								}
 								else
@@ -879,5 +879,5 @@
 							$job_nodes[]	= $host;
 						}
-						$jobs[$jobid][nodes]	= $job_nodes;
+						$jobs[$jobid]['nodes']	= $job_nodes;
 					}
 				}
@@ -960,7 +960,7 @@
 			printf( "job %s\n", $jobid );
 
-			if( isset( $job[nodes] ) )
-			{
-				foreach( $job[nodes] as $node )
+			if( isset( $job['nodes'] ) )
+			{
+				foreach( $job['nodes'] as $node )
 				{
 					$mynode = $this->nodes[$node];
@@ -1326,5 +1326,5 @@
 		global $metrics;
 
-		$cpus = $metrics[$this->hostname][cpu_num][VAL];
+		$cpus = $metrics[$this->hostname][cpu_num]['VAL'];
 
 		if (!$cpus)
@@ -1340,5 +1340,5 @@
 		global $metrics;
 
-		$load_one	= $metrics[$this->hostname][load_one][VAL];
+		$load_one	= $metrics[$this->hostname][load_one]['VAL'];
 		$load		= ((float) $load_one)/$this->cpus;
 
@@ -2129,18 +2129,18 @@
 				if( $headername == 'nodes' )
 				{
-					$attrval	= strval( count( $jobinfo[nodes] ) );
+					$attrval	= strval( count( $jobinfo['nodes'] ) );
 				}
 				else if( $headername == 'cpus' )
 				{
-					if( !isset( $jobinfo[ppn] ) )
+					if( !isset( $jobinfo['ppn'] ) )
 					{
-						$jobinfo[ppn] = 1;
+						$jobinfo['ppn'] = 1;
 					}
 
-					$attrval	= strval( count( $jobinfo[nodes] ) * intval( $jobinfo[ppn] ) );
+					$attrval	= strval( count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] ) );
 				}
 				else if( $headername == 'runningtime' )
 				{
-					$attrval	= makeTime( intval( $jobinfo[reported] ) - intval( $jobinfo[start_timestamp] ) );
+					$attrval	= makeTime( intval( $jobinfo['reported'] ) - intval( $jobinfo['start_timestamp'] ) );
 				}
 				else
@@ -2167,76 +2167,76 @@
 			$jobinfo		= $dg->getJob( $jobid );
 
-			if( !isset( $this->headerstrlen[id] ) )
-			{
-				$this->headerstrlen[id]	= strlen( strval( $jobid ) );
-			}
-			else if( strlen( strval( $jobid ) ) > $this->headerstrlen[id] )
-			{
-				$this->headerstrlen[id]	= strlen( strval( $jobid ) );
-			}
-
-			if( !isset( $this->headerstrlen[owner] ) )
-			{
-				$this->headerstrlen[owner]	= strlen( strval( $jobinfo[owner] ) );
-			}
-			else if( strlen( strval( $jobinfo[owner] ) ) > $this->headerstrlen[owner] )
-			{
-				$this->headerstrlen[owner]	= strlen( strval( $jobinfo[owner] ) );
-			}
-
-			if( !isset( $this->headerstrlen[queue] ) )
-			{
-				$this->headerstrlen[queue]	= strlen( strval( $jobinfo[queue] ) );
-			}
-			else if( strlen( strval( $jobinfo[queue] ) ) > $this->headerstrlen[queue] )
-			{
-				$this->headerstrlen[queue]	= strlen( strval( $jobinfo[queue] ) );
-			}
-
-			if( !isset( $jobinfo[ppn] ) )
-			{
-				$jobinfo[ppn] = 1;
-			}
-
-			$cpus			= count( $jobinfo[nodes] ) * intval( $jobinfo[ppn] );
-
-			if( !isset( $this->headerstrlen[cpus] ) )
-			{
-				$this->headerstrlen[cpus]	= strlen( strval( $cpus ) );
-			}
-			else if( strlen( strval( $cpus ) ) > $this->headerstrlen[cpus] )
-			{
-				$this->headerstrlen[cpus]	= strlen( strval( $cpus ) );
-			}
-
-			$nodes			= count( $jobinfo[nodes] );
-
-			if( !isset( $this->headerstrlen[nodes] ) )
-			{
-				$this->headerstrlen[nodes]	= strlen( strval( $nodes ) );
-			}
-			else if( strlen( strval( $nodes) ) > $this->headerstrlen[nodes] )
-			{
-				$this->headerstrlen[nodes]	= strlen( strval( $nodes ) );
-			}
-
-			$runningtime		= makeTime( intval( $jobinfo[reported] ) - intval( $jobinfo[start_timestamp] ) );
-
-			if( !isset( $this->headerstrlen[runningtime] ) )
-			{
-				$this->headerstrlen[runningtime]	= strlen( strval( $runningtime) );
-			}
-			else if( strlen( strval( $runningtime) ) > $this->headerstrlen[runningtime] )
-			{
-				$this->headerstrlen[runningtime]	= strlen( strval( $runningtime) );
-			}
-
-			if( !isset( $this->headerstrlen[name] ) )
-			{
-				$this->headerstrlen[name]	= strlen( strval( $jobinfo[name] ) );
-			}
-			else if( strlen( strval( $jobinfo[name] ) ) > $this->headerstrlen[name] )
-			{
-				$this->headerstrlen[name]	= strlen( strval( $jobinfo[name] ) );
+			if( !isset( $this->headerstrlen['id'] ) )
+			{
+				$this->headerstrlen['id']	= strlen( strval( $jobid ) );
+			}
+			else if( strlen( strval( $jobid ) ) > $this->headerstrlen['id'] )
+			{
+				$this->headerstrlen['id']	= strlen( strval( $jobid ) );
+			}
+
+			if( !isset( $this->headerstrlen['owner'] ) )
+			{
+				$this->headerstrlen['owner']	= strlen( strval( $jobinfo['owner'] ) );
+			}
+			else if( strlen( strval( $jobinfo['owner'] ) ) > $this->headerstrlen['owner'] )
+			{
+				$this->headerstrlen['owner']	= strlen( strval( $jobinfo['owner'] ) );
+			}
+
+			if( !isset( $this->headerstrlen['queue'] ) )
+			{
+				$this->headerstrlen['queue']	= strlen( strval( $jobinfo['queue'] ) );
+			}
+			else if( strlen( strval( $jobinfo['queue'] ) ) > $this->headerstrlen['queue'] )
+			{
+				$this->headerstrlen['queue']	= strlen( strval( $jobinfo['queue'] ) );
+			}
+
+			if( !isset( $jobinfo['ppn'] ) )
+			{
+				$jobinfo['ppn'] = 1;
+			}
+
+			$cpus			= count( $jobinfo['nodes'] ) * intval( $jobinfo['ppn'] );
+
+			if( !isset( $this->headerstrlen['cpus'] ) )
+			{
+				$this->headerstrlen['cpus']	= strlen( strval( $cpus ) );
+			}
+			else if( strlen( strval( $cpus ) ) > $this->headerstrlen['cpus'] )
+			{
+				$this->headerstrlen['cpus']	= strlen( strval( $cpus ) );
+			}
+
+			$nodes			= count( $jobinfo['nodes'] );
+
+			if( !isset( $this->headerstrlen['nodes'] ) )
+			{
+				$this->headerstrlen['nodes']	= strlen( strval( $nodes ) );
+			}
+			else if( strlen( strval( $nodes) ) > $this->headerstrlen['nodes'] )
+			{
+				$this->headerstrlen['nodes']	= strlen( strval( $nodes ) );
+			}
+
+			$runningtime		= makeTime( intval( $jobinfo['reported'] ) - intval( $jobinfo['start_timestamp'] ) );
+
+			if( !isset( $this->headerstrlen['runningtime'] ) )
+			{
+				$this->headerstrlen['runningtime']	= strlen( strval( $runningtime) );
+			}
+			else if( strlen( strval( $runningtime) ) > $this->headerstrlen['runningtime'] )
+			{
+				$this->headerstrlen['runningtime']	= strlen( strval( $runningtime) );
+			}
+
+			if( !isset( $this->headerstrlen['name'] ) )
+			{
+				$this->headerstrlen['name']	= strlen( strval( $jobinfo['name'] ) );
+			}
+			else if( strlen( strval( $jobinfo['name'] ) ) > $this->headerstrlen['name'] )
+			{
+				$this->headerstrlen['name']	= strlen( strval( $jobinfo['name'] ) );
 			}
 		}
