Changeset 61 for trunk/plugin/togap.py
- Timestamp:
- 04/12/05 16:37:09 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugin/togap.py
r26 r61 5 5 DEBUG_LEVEL = 10 6 6 7 # If set to 1, in addition to multicasting with gmetric, 8 # also transmit jobinfo data to a Toga server for archival 9 # 10 ARCHIVE_MODE = 0 11 12 # Where is the toga server at 13 # 14 #TOGA_SERVER = 'monitor2.irc.sara.nl:9048' 15 7 16 # Wether or not to run as a daemon in background 8 17 # 9 18 DAEMONIZE = 0 19 20 # Allows to specify alternate config 21 # 22 #GMOND_CONF = '/etc/gmondconf' 10 23 11 24 from PBSQuery import PBSQuery … … 13 26 import time 14 27 28 class DataProcessor: 29 30 binary = '/usr/bin/gmetric' 31 32 def __init__( self, binary=None ): 33 34 if binary: 35 self.binary = binary 36 37 def multicastGmetric( self, metricname, metricval, tmax ): 38 39 cmd = binary 40 41 try: 42 cmd = cmd + ' -c' + GMOND_CONF 43 except NameError: 44 debug_msg( 8, 'Assuming /etc/gmond.conf for gmetric cmd (ommitting)' ) 45 46 cmd = cmd + ' -n' + metricname + ' -v' + metricval + ' -t' + tmax 47 48 print cmd 49 #os.system( cmd ) 50 51 def togaSubmitJob( self, jobid, jobattrs ): 52 53 pass 54 15 55 class PBSDataGatherer: 56 57 jobs = { } 16 58 17 59 def __init__( self ): … … 19 61 self.pq = PBSQuery() 20 62 self.jobs = { } 63 self.dp = DataProcessor() 21 64 22 65 def getAttr( self, attrs, name ): … … 49 92 def getJobData( self ): 50 93 51 jobs = self.jobs 94 jobs = self.jobs[:] 52 95 53 96 joblist = self.pq.getjobs() … … 60 103 61 104 jobs_processed.append( job_id ) 62 105 63 106 name = self.getAttr( attrs, 'Job_Name' ) 64 107 queue = self.getAttr( attrs, 'queue' ) … … 88 131 if self.jobDataChanged( jobs, job_id, myAttrs ): 89 132 jobs[ job_id ] = myAttrs 133 134 self.printJob( jobs, job_id ) 135 90 136 debug_msg( 10, printTime() + ' job %s state changed' %(job_id) ) 91 self.printJob( job_id )92 137 93 138 for id, attrs in jobs.items(): … … 98 143 if id not in jobs_processed and attrs['stop_timestamp'] == '': 99 144 100 jobs[ id ]['status'] = ' D'145 jobs[ id ]['status'] = 'F' 101 146 jobs[ id ]['stop_timestamp'] = time.time() 102 147 debug_msg( 10, printTime() + ' job %s finished' %(id) ) 103 self.printJob( id ) 104 148 self.printJob( jobs, id ) 149 150 # Now let's spread the knowledge 151 # 152 for jobid, jobattrs in jobs.items(): 153 154 if ARCHIVE_MODE: 155 156 if self.jobDataChanged( self.jobs, jobid, jobattrs ): 157 158 self.dp.togaSubmitJob( jobid, jobattrs ) 159 160 self.dp.multicastGmetric( jobid, jobattrs ) 161 105 162 self.jobs = jobs 106 163 107 def printJobs( self ):164 def printJobs( self, jobs ): 108 165 109 166 for name, attrs in self.jobs.items(): … … 115 172 print '\t%s = %s' %( name, val ) 116 173 117 def printJob( self, job _id ):174 def printJob( self, jobs, job_id ): 118 175 119 176 print 'job %s' %(job_id)
Note: See TracChangeset
for help on using the changeset viewer.