Changeset 68 for trunk/plugin
- Timestamp:
- 04/14/05 14:26:47 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugin/togap.py
r67 r68 15 15 # 16 16 TORQUE_POLL_INTERVAL = 10 17 18 # Alternate location of gmond.conf 19 # 20 # Default: /etc/gmond.conf 21 # 22 #GMOND_CONF = '/etc/gmond.conf' 17 23 18 24 from PBSQuery import PBSQuery … … 24 30 25 31 class DataProcessor: 32 """Class for processing of data""" 26 33 27 34 binary = '/usr/bin/gmetric' 28 35 29 36 def __init__( self, binary=None ): 37 """Remember alternate binary location if supplied""" 30 38 31 39 if binary: … … 34 42 self.dmax = TORQUE_POLL_INTERVAL 35 43 36 #incompatible = self.checkGmetricVersion 44 try: 45 gmond_file = GMOND_CONF 46 47 except NameError: 48 gmond_file = '/etc/gmond.conf' 49 50 if not os.path.exists( gmond_file ): 51 debug_msg( 0, gmond_file + ' does not exist' ) 52 sys.exit( 1 ) 53 54 #incompatible = self.checkGmetricVersion() 37 55 incompatible = 0 38 56 … … 42 60 43 61 def checkGmetricVersion( self ): 62 """ 63 Check version of gmetric is at least 3.0.1 64 for the syntax we use 65 """ 44 66 45 67 for line in os.popen( self.binary + ' --version' ).readlines(): … … 72 94 73 95 def multicastGmetric( self, metricname, metricval, valtype='string', tmax='15' ): 96 """Call gmetric binary and multicast""" 74 97 75 98 cmd = self.binary … … 90 113 91 114 def __init__( self ): 115 """Setup appropriate variables""" 92 116 93 117 self.pq = PBSQuery() … … 96 120 97 121 def getAttr( self, attrs, name ): 122 """Return certain attribute from dictionary, if exists""" 98 123 99 124 if attrs.has_key( name ): … … 103 128 104 129 def jobDataChanged( self, jobs, job_id, attrs ): 130 """Check if job with attrs and job_id in jobs has changed""" 105 131 106 132 if jobs.has_key( job_id ): … … 123 149 124 150 def getJobData( self, known_jobs ): 151 """Gather all data on current jobs in Torque""" 125 152 126 153 if len( known_jobs ) > 0: … … 130 157 131 158 joblist = self.pq.getjobs() 159 160 cur_time = time.time() 132 161 133 162 jobs_processed = [ ] … … 172 201 myAttrs['status'] = status 173 202 myAttrs['start_timestamp'] = start_timestamp 203 myAttrs['reported_timestamp'] = str( int( cur_time ) ) 174 204 myAttrs['nodes'] = nodeslist 175 205 myAttrs['domain'] = string.join( socket.getfqdn().split( '.' )[1:], '.' ) … … 186 216 def submitJobData( self, jobs ): 187 217 """Submit job info list""" 188 189 time_now = time.time()190 191 self.dp.multicastGmetric( 'TOGA-HEARTBEAT', str( time_now ), 'float' )192 218 193 219 # Now let's spread the knowledge … … 201 227 202 228 def makeNodeString( self, nodelist ): 229 """Make one big string of all hosts""" 203 230 204 231 node_str = None … … 223 250 status_str = 'status=' + jobattrs['status'] 224 251 stime_str = 'stime=' + jobattrs['start_timestamp'] 252 reported_str = 'reported=' + jobattrs['reported_timestamp'] 225 253 domain_str = 'domain=' + jobattrs['domain'] 226 254 node_str = 'nodes=' + self.makeNodeString( jobattrs['nodes'] ) 227 255 228 appendList = [ name_str, queue_str, owner_str, rtime_str, rmem_str, ppn_str, status_str, stime_str, domain_str, node_str ]256 appendList = [ name_str, queue_str, owner_str, rtime_str, rmem_str, ppn_str, status_str, stime_str, reported_str, domain_str, node_str ] 229 257 230 258 return self.makeAppendLists( appendList ) 231 259 232 260 def makeAppendLists( self, append_list ): 261 """ 262 Divide all values from append_list over strings with a maximum 263 size of 1400 264 """ 233 265 234 266 app_lists = [ ]
Note: See TracChangeset
for help on using the changeset viewer.