Changeset 6 for trunk/cluster_status.php


Ignore:
Timestamp:
Apr 22, 2015, 10:27:05 PM (9 years ago)
Author:
gegorbet
Message:

changes since 2013, mostly for airvata/thrift

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cluster_status.php

    r1 r6  
    11<?php
    22
    3 include "/home/us3/bin/listen-config.php";
     3$us3bin = exec( "ls -d ~us3/bin" );
     4include "$us3bin/listen-config.php";
    45
    56$xml  = get_data();
    67
    7 if ( $xml == "" ) exit();  // No status available
     8if ( $xml != "" )
     9   parse( $xml );
    810
    911$data = array();
    10 parse( $xml );
     12
     13local_status();
    1114
    1215foreach ( $data as $item )
     
    3235   catch ( HttpException $e )
    3336   {
    34       write_log( "$self: Cluster Status not available" );
     37//      write_log( "$self: Cluster Status not available" );
    3538      return "";
    3639   }
     
    152155      write_log( "$self: Query failed $query - " .  mysql_error( $gfac_link ) );
    153156      echo "$self: Query failed $query - " .  mysql_error( $gfac_link ) . "\n";
     157   }
     158}
     159
     160// Get local cluster status
     161
     162function local_status()
     163{
     164   global $self;
     165   global $data;
     166
     167//   $clusters = array( "alamo", "jacinto", "bcf" );
     168   $clusters = array( "alamo", "jacinto" );
     169//   $clusters = array( "alamo" );
     170   foreach ( $clusters as $clname )
     171   {
     172      $a      = Array();
     173      if ( $clname == "alamo" )
     174      {
     175         $qstat  = `ssh $clname '/usr/bin/qstat -B 2>&1|tail -1'`;
     176
     177         $sparts = preg_split( '/\s+/', $qstat );
     178         $que    = $sparts[ 3 ];
     179         $run    = $sparts[ 4 ];
     180         $sta    = $sparts[ 10 ];
     181      }
     182      else 
     183      {
     184         $qstat  = `ssh $clname '/opt/torque/bin/qstat -B 2>&1|tail -1'`;
     185
     186         $sparts = preg_split( '/\s+/', $qstat );
     187         $que    = $sparts[ 3 ];
     188         $run    = $sparts[ 4 ];
     189         $sta    = $sparts[ 9 ];
     190      }
     191
     192//echo "$self: cln que run sta   $clname $que $run $sta \n";
     193
     194      if ( $sta == "Active" )
     195      {
     196         $sta    = "up";
     197      }
     198      else
     199      {
     200         $sta    = "down";
     201         $que    = "0";
     202         $run    = "0";
     203      }
     204
     205      $a[ 'cluster' ] = $clname;
     206      $a[ 'queued'  ] = $que;
     207      $a[ 'running' ] = $run;
     208      $a[ 'status'  ] = $sta;
     209
     210      $data[] = $a;
     211      $a[ 'cluster' ] = $clname . "-local";
     212      $data[] = $a;
    154213   }
    155214}
     
    191250        if ( $name == "resourceHealth" )
    192251        {
    193            $name .= $this->_index;
     252##           $name .= $this->_index;
    194253           $this->_index++;
    195254        }
Note: See TracChangeset for help on using the changeset viewer.