Changeset 61 for trunk


Ignore:
Timestamp:
04/12/05 16:37:09 (19 years ago)
Author:
bastiaans
Message:

plugin/togap.py:

  • Added initial setup for transmission of jobinfo
  • Not sure wether a extra direct connection to data server is needed or not. Will mean transmitting the same data twice by different means -> not logical.


Will contemplate on this..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugin/togap.py

    r26 r61  
    55DEBUG_LEVEL = 10
    66
     7# If set to 1, in addition to multicasting with gmetric,
     8# also transmit jobinfo data to a Toga server for archival
     9#
     10ARCHIVE_MODE = 0
     11
     12# Where is the toga server at
     13#
     14#TOGA_SERVER = 'monitor2.irc.sara.nl:9048'
     15
    716# Wether or not to run as a daemon in background
    817#
    918DAEMONIZE = 0
     19
     20# Allows to specify alternate config
     21#
     22#GMOND_CONF = '/etc/gmondconf'
    1023
    1124from PBSQuery import PBSQuery
     
    1326import time
    1427
     28class 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
    1555class PBSDataGatherer:
     56
     57        jobs = { }
    1658
    1759        def __init__( self ):
     
    1961                self.pq = PBSQuery()
    2062                self.jobs = { }
     63                self.dp = DataProcessor()
    2164
    2265        def getAttr( self, attrs, name ):
     
    4992        def getJobData( self ):
    5093
    51                 jobs = self.jobs
     94                jobs = self.jobs[:]
    5295
    5396                joblist = self.pq.getjobs()
     
    60103
    61104                        jobs_processed.append( job_id )
    62                        
     105
    63106                        name = self.getAttr( attrs, 'Job_Name' )
    64107                        queue = self.getAttr( attrs, 'queue' )
     
    88131                        if self.jobDataChanged( jobs, job_id, myAttrs ):
    89132                                jobs[ job_id ] = myAttrs
     133
     134                                self.printJob( jobs, job_id )
     135
    90136                                debug_msg( 10, printTime() + ' job %s state changed' %(job_id) )
    91                                 self.printJob( job_id )
    92137
    93138                for id, attrs in jobs.items():
     
    98143                        if id not in jobs_processed and attrs['stop_timestamp'] == '':
    99144
    100                                 jobs[ id ]['status'] = 'D'
     145                                jobs[ id ]['status'] = 'F'
    101146                                jobs[ id ]['stop_timestamp'] = time.time()
    102147                                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                                       
    105162                self.jobs = jobs
    106163
    107         def printJobs( self ):
     164        def printJobs( self, jobs ):
    108165       
    109166                for name, attrs in self.jobs.items():
     
    115172                                print '\t%s = %s' %( name, val )
    116173
    117         def printJob( self, job_id ):
     174        def printJob( self, jobs, job_id ):
    118175
    119176                print 'job %s' %(job_id)
Note: See TracChangeset for help on using the changeset viewer.