/[pdpsoft]/nl.nikhef.pdp.dynsched-pbs-plugin/trunk/pbsServer.py
ViewVC logotype

Diff of /nl.nikhef.pdp.dynsched-pbs-plugin/trunk/pbsServer.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2145 by templon, Fri Oct 8 13:12:27 2010 UTC revision 2146 by templon, Fri Jan 14 16:11:45 2011 UTC
# Line 2  Line 2 
2  # pbsServer.py -- LRMS classes for PBS-based batch systems.  # pbsServer.py -- LRMS classes for PBS-based batch systems.
3  #       $Revision: 1939 $        #       $Revision: 1939 $      
4  #       $URL$    #       $URL$  
 #       $Date: 2010-09-23 16:07:57 +0200 (Thu, 23 Sep 2010) $    
5  #       $Id$      #       $Id$    
6    
7  #--  #--
# Line 33  class LiveServer(Server): Line 32  class LiveServer(Server):
32          else:          else:
33              cmdstr = 'qstat -f'              cmdstr = 'qstat -f'
34          (stat, qstatout) = commands.getstatusoutput(cmdstr)          (stat, qstatout) = commands.getstatusoutput(cmdstr)
35            if stat:
36                print 'problem getting qstat output; cmd used was', cmdstr
37                print 'returned status ', stat, ', text: ', qstatout
38          from torque_utils import pbsnodes          from torque_utils import pbsnodes
39          cpucount = 0          cpucount = 0
40          jobcount = 0          jobcount = 0
# Line 49  class LiveServer(Server): Line 51  class LiveServer(Server):
51                    
52          keyvalpat = re.compile(r'   (\S+) = (.*)')          keyvalpat = re.compile(r'   (\S+) = (.*)')
53                    
54          verbose_job_info=string.split(qstatout,"\n\n")          # guard against empty or nonconforming qstat output
55            if len(qstatout) == 0:
56                verbose_job_info = []  # assume valid output for system with no jobs running!
57            elif qstatout.find('Job Id') != 0:
58                print 'fatal error, qstat output starts with something other than a job id'
59                print 'first few characters are:', qstatout[:min(32,len(qstatout))]
60                sys.exit(4)
61            else:
62                verbose_job_info=string.split(qstatout,"\n\n")
63    
64          for j in verbose_job_info:          for j in verbose_job_info:
65              newj = Job()              newj = Job()
66              lines = string.split(j,'\n ')              lines = string.split(j,'\n ')
# Line 119  class LiveServer(Server): Line 130  class LiveServer(Server):
130                  secs = int(t[2]) + \                  secs = int(t[2]) + \
131                         60.0*(int(t[1]) + 60*int(t[0]))                         60.0*(int(t[1]) + 60*int(t[0]))
132                  newj.set('maxwalltime',secs)                  newj.set('maxwalltime',secs)
133    
134                # do start and wall times.  default is to use qstat "start_time" for start times and
135                # qstat "resources_used.walltime" for walltime.  Code can use walltime for start and
136                # start for walltime in situations where one is missing.
137    
138                if 'start_time' in keysfound:
139                    timestring = qstatDict['start_time']
140                    timetuple = time.strptime(timestring,"%c")
141                    newj.set('start',time.mktime(timetuple))
142                    newj.set('startAnchor', 'start_time')
143                    if 'resources_used.walltime' not in keysfound:   # just after job starts, walltime is not printed
144                        newj.set('walltime', self.__evtime__ - newj.get('start'))
145    
146              if 'resources_used.walltime' in keysfound:              if 'resources_used.walltime' in keysfound:
147                  hms = qstatDict['resources_used.walltime']                  hms = qstatDict['resources_used.walltime']
148                  t = string.split(hms,':')                  t = string.split(hms,':')
149                  secs = int(t[2]) + \                  secs = int(t[2]) + \
150                         60.0*(int(t[1]) + 60*int(t[0]))                         60.0*(int(t[1]) + 60*int(t[0]))
151                  newj.set('walltime', secs)                  newj.set('walltime', secs)
152                    if 'start_time' not in keysfound:  # older torque version
                 # do start time.  if start_time is present use that,  
                 # otherwise, back off to compute it via subtracting elapsed walltime from snapshot time.  
   
                 if 'start_time' in keysfound:  
                     timestring = qstatDict['start_time']  
                     timetuple = time.strptime(timestring,"%c")  
                     newj.set('start',time.mktime(timetuple))  
                     newj.set('startAnchor', 'start_time')  
                 else:  
153                      start = self.__evtime__ - secs                      start = self.__evtime__ - secs
154                      newj.set('start',start)                      newj.set('start',start)
155                      newj.set('startAnchor', 'resources_used.walltime')                      newj.set('startAnchor', 'resources_used.walltime')

Legend:
Removed from v.2145  
changed lines
  Added in v.2146

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28