Index: trunk/cluster_status.php
===================================================================
--- trunk/cluster_status.php	(revision 41)
+++ trunk/cluster_status.php	(revision 1)
@@ -1,27 +1,19 @@
 <?php
 
-$us3bin = exec( "ls -d ~us3/lims/bin" );
-include "$us3bin/listen-config.php";
-
-if ( ! preg_match( "/_local/", $class_dir ) )
-{
-   $xml  = get_data();
-
-   if ( $xml != "" )
-      parse( $xml );
-}
+include "/home/us3/bin/listen-config.php";
+
+$xml  = get_data();
+
+if ( $xml == "" ) exit();  // No status available
 
 $data = array();
-
-local_status();
+parse( $xml );
 
 foreach ( $data as $item )
 {
-   if ( ! preg_match( "/error/", $item[ 'running' ] ) )
-      update( $item[ 'cluster' ], $item[ 'queued' ], $item[ 'status' ], $item[ 'running' ] );
-}
-
-//exit();
-exit(0);
+   update( $item[ 'cluster' ], $item[ 'queued' ], $item[ 'status' ], $item[ 'running' ] );
+}
+
+exit();
 
 // Get the cluster status
@@ -40,5 +32,5 @@
    catch ( HttpException $e )
    {
-//      write_log( "$self: Cluster Status not available" );
+      write_log( "$self: Cluster Status not available" );
       return "";
    }
@@ -114,9 +106,9 @@
    global $gDB;
    global $self;
-//echo  " $cluster $queued, $status, $running\n";
-
-   $gfac_link = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB );
-
-   if ( ! $gfac_link )
+
+   $gfac_link = mysql_connect( $dbhost, $guser, $gpasswd );
+   $result = mysql_select_db( $gDB, $gfac_link );
+
+   if ( ! $result )
    {
       write_log( "$self: Could not connect to DB $gDB" );
@@ -126,14 +118,14 @@
       
    $query = "SELECT * FROM cluster_status WHERE cluster='$cluster'";
-   $result = mysqli_query( $gfac_link, $query );
+   $result = mysql_query( $query, $gfac_link );
 
    if ( ! $result )
    {
-      write_log( "$self: Query failed $query - " .  mysqli_error( $gfac_link ) );
-      echo "$self: Query failed $query - " .  mysqli_error( $gfac_link ) . "\n";
+      write_log( "$self: Query failed $query - " .  mysql_error( $gfac_link ) );
+      echo "$self: Query failed $query - " .  mysql_error( $gfac_link ) . "\n";
       exit();
    }
 
-   $rows = mysqli_num_rows( $result );
+   $rows = mysql_num_rows( $result );
 
    if ( $rows == 0 )  // INSERT
@@ -154,248 +146,10 @@
    }
 
-   $result = mysqli_query( $gfac_link, $query );
+   $result = mysql_query( $query, $gfac_link );
 
    if ( ! $result )
    {
-      write_log( "$self: Query failed $query - " .  mysqli_error( $gfac_link ) );
-      echo "$self: Query failed $query - " .  mysqli_error( $gfac_link ) . "\n";
-   }
-}
-
-// Get local cluster status
-
-function local_status()
-{
-   global $self;
-   global $data;
-   global $dbhost;
-   global $org_domain;
-   global $class_dir;
-
-   if ( preg_match( "/_local/", $class_dir ) )
-   {
-      if ( preg_match( "/attlocal/", $org_domain ) )
-         $clusters = array( "us3iab-devel" );
-      else
-         $clusters = array( "us3iab-node0",  "demeler3-local", "taito-local" );
-   }
-   else
-   {
-      $clusters = array( "lonestar5", "comet",
-                         "stampede2", "jetstream" );
-   }
-
-   foreach ( $clusters as $clname )
-   {
-      $a      = Array();
-//echo "$self:   clname=$clname\n";
-
-      switch( $clname )
-      {
-         case 'us3iab-node0':
-         case 'us3iab-node1':
-         case 'us3iab-devel':
-         {
-            $qstat  = `/usr/bin/qstat -B 2>&1|tail -1`;
-
-            $sparts = preg_split( '/\s+/', $qstat );
-            $que    = $sparts[ 3 ];
-            $run    = $sparts[ 4 ];
-            $sta    = $sparts[ 10 ];
-            if ( $sta == "Active" )
-               $sta    = "up";
-            else
-               $sta    = "down";
-            break;
-         }
-         case 'alamo-local':
-         case 'alamo':
-         {
-            $host   = "us3@alamo.uthscsa.edu";
-            $qstat  = `ssh $host '/usr/bin/qstat -B 2>&1|tail -1'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $que    = $sparts[ 3 ];
-            $run    = $sparts[ 4 ];
-            $sta    = $sparts[ 10 ];
-            if ( $sta == "Active" )
-               $sta    = "up";
-            else
-               $sta    = "down";
-            break;
-         }
-
-        case 'demeler3-local':
-         {
-            $host   = "us3@demeler3.uleth.ca";
-            $qstat  = `ssh $host '/usr/bin/qstat -B 2>&1|tail -1'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $que    = $sparts[ 3 ];
-            $run    = $sparts[ 4 ];
-            $sta    = $sparts[ 10 ];
-            if ( $sta == "Active" )
-               $sta    = "up";
-            else
-               $sta    = "down";
-            break;
-         }
-
-         case 'jacinto':
-         {
-            $host   = "us3@jacinto.uthscsa.edu";
-            $qstat  = `ssh $host '/opt/torque/bin/qstat -B 2>&1|tail -1'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $que    = $sparts[ 3 ];
-            $run    = $sparts[ 4 ];
-            $sta    = $sparts[ 9 ];
-            if ( $sta == "Active" )
-               $sta    = "up";
-            else
-               $sta    = "down";
-            break;
-         }
-         case 'stampede2':
-         {
-            $host   = "us3@stampede2.tacc.utexas.edu";
-            $qstat  = `ssh $host '~us3/scripts/clusstat skx-normal 2>/dev/null'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $tot    = $sparts[ 2 ];
-            $run    = $sparts[ 5 ];
-            $que    = $sparts[ 8 ];
-            $sta    = "up";
-            if ( $tot == ''  ||  $tot == '0' )
-               $sta    = "down";
-            break;
-         }
-         case 'lonestar5':
-         {
-            $host   = "us3@ls5.tacc.utexas.edu";
-            $qstat  = `ssh $host '/opt/apps/tacc/bin/showq 2>/dev/null|grep "Total Jobs"'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $tot    = $sparts[ 2 ];
-            $run    = '0';
-            $que    = '0';
-            $sta    = "up";
-            if ( $tot == ''  ||  $tot == '0' )
-            {
-               $sta    = "down";
-            }
-            else
-            {
-               $run    = $sparts[ 5 ];
-               $que    = $sparts[ 8 ];
-//               $que    = $sparts[ 11 ];
-            }
-            break;
-         }
-         case 'comet':
-         {
-            $host   = "us3@comet.sdsc.edu";
-            //$qstat  = `ssh $host '/usr/bin/sinfo -s -p compute -o "%a %F" |tail -1'`;
-            $qstat  = `ssh $host '/home/us3/scripts/cstat 2>&1'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $tot    = $sparts[ 1 ];
-            $run    = '0';
-            $que    = '0';
-            $sta    = "up";
-            if ( $tot == ''  ||  $tot == '0' )
-            {
-               $sta    = "down";
-            }
-            else
-            {
-               $run    = $sparts[ 3 ];
-               $que    = $sparts[ 5 ];
-               if ( $run == '0'  &&  $que == '0' )
-               {
-                  $sta    = "down";
-               }
-            }
-            break;
-         }
-         case 'jureca':
-         {
-            $host   = "swus1@jureca.fz-juelich.de";
-            $qstat  = `ssh $host '~swus1/scripts/qstat-jureca 2>&1'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $sta    = $sparts[ 0 ];
-            $run    = $sparts[ 1 ];
-            $que    = $sparts[ 2 ];
-            break;
-         }
-         case 'jetstream-local':
-         case 'jetstream':
-         {
-            $host   = "us3@js-169-137.jetstream-cloud.org";
-//            $qstat  = `ssh $host '/usr/bin/sinfo -s -p batch -o "%a %F" |tail -1'`;
-            $qstat  = `ssh $host '/home/us3/bin/clusstat |tail -n 1'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $sta    = $sparts[ 0 ];
-            $knts   = $sparts[ 1 ];
-            $sparts = preg_split( '/\//', $knts );
-            $run    = $sparts[ 0 ];
-            $que    = $sparts[ 2 ];
-            $tot    = $sparts[ 3 ];
-            if ( $sta == "" )
-               $sta    = "down";
-            break;
-         }
-         case 'taito-local':
-         {
-            $host   = "rb_2001068_taito01@taito.csc.fi";
-            $qstat  = `ssh -i /home/us3/.ssh/id_rsa_taito_robot $host '/homeappl/home/rb_2001068_taito01/scripts/cstat 2>&1'`;
-            $sparts = preg_split( '/\s+/', $qstat );
-            $tot    = $sparts[ 1 ];
-            $run    = '0';
-            $que    = '0';
-            $sta    = "up";
-            if ( $tot == ''  ||  $tot == '0' )
-            {
-               $sta    = "down";
-            }
-            else
-            {
-               $run    = $sparts[ 3 ];
-               $que    = $sparts[ 5 ];
-            }
-            break;
-         }
-
-      }
-
-      if ( $sta == "" )
-         $sta    = "down";
-
-      if ( $sta == "down" )
-      {
-         $que    = "0";
-         $run    = "0";
-      }
-
-      // Insure queued,running counts are numeric
-      $que_s          = $que;
-      $run_s          = $run;
-      $que_e          = preg_replace( '/=/', "", $que_s );
-      $run_e          = preg_replace( '/=/', "", $run_s );
-      $que            = intval( $que_e );
-      $run            = intval( $run_e );
-if($que!=$que_s ||  $run!=$run_s)
- echo "$self:   *** que s,e,i $que_s $que_e $que  run s,e,i $run_s $run_e $run\n";
-
-      // Save cluster status values
-      $a[ 'cluster' ] = $clname;
-      $a[ 'queued'  ] = $que;
-      $a[ 'running' ] = $run;
-      $a[ 'status'  ] = $sta;
-echo "$self:  $clname  $que $run $sta\n";
-
-      $data[] = $a;
-
-      if ( $clname == 'alamo'  ||
-           $clname == 'jacinto'  ||
-           $clname == 'jetstream' )
-      {
-         $a[ 'cluster' ] = $clname . "-local";
-         $data[] = $a;
-      }
+      write_log( "$self: Query failed $query - " .  mysql_error( $gfac_link ) );
+      echo "$self: Query failed $query - " .  mysql_error( $gfac_link ) . "\n";
    }
 }
@@ -437,5 +191,5 @@
         if ( $name == "resourceHealth" ) 
         {
-##           $name .= $this->_index;
+           $name .= $this->_index;
            $this->_index++;
         }
