Changeset 68


Ignore:
Timestamp:
04/14/05 14:26:47 (19 years ago)
Author:
bastiaans
Message:

plugin/togap.py:

  • Removed global heartbeat
  • Added 'reported' time to each jobinfo
  • Misc. code cleanup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugin/togap.py

    r67 r68  
    1515#
    1616TORQUE_POLL_INTERVAL = 10
     17
     18# Alternate location of gmond.conf
     19#
     20# Default: /etc/gmond.conf
     21#
     22#GMOND_CONF = '/etc/gmond.conf'
    1723
    1824from PBSQuery import PBSQuery
     
    2430
    2531class DataProcessor:
     32        """Class for processing of data"""
    2633
    2734        binary = '/usr/bin/gmetric'
    2835
    2936        def __init__( self, binary=None ):
     37                """Remember alternate binary location if supplied"""
    3038
    3139                if binary:
     
    3442                self.dmax = TORQUE_POLL_INTERVAL
    3543
    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()
    3755                incompatible = 0
    3856
     
    4260
    4361        def checkGmetricVersion( self ):
     62                """
     63                Check version of gmetric is at least 3.0.1
     64                for the syntax we use
     65                """
    4466
    4567                for line in os.popen( self.binary + ' --version' ).readlines():
     
    7294
    7395        def multicastGmetric( self, metricname, metricval, valtype='string', tmax='15' ):
     96                """Call gmetric binary and multicast"""
    7497
    7598                cmd = self.binary
     
    90113
    91114        def __init__( self ):
     115                """Setup appropriate variables"""
    92116
    93117                self.pq = PBSQuery()
     
    96120
    97121        def getAttr( self, attrs, name ):
     122                """Return certain attribute from dictionary, if exists"""
    98123
    99124                if attrs.has_key( name ):
     
    103128
    104129        def jobDataChanged( self, jobs, job_id, attrs ):
     130                """Check if job with attrs and job_id in jobs has changed"""
    105131
    106132                if jobs.has_key( job_id ):
     
    123149
    124150        def getJobData( self, known_jobs ):
     151                """Gather all data on current jobs in Torque"""
    125152
    126153                if len( known_jobs ) > 0:
     
    130157
    131158                joblist = self.pq.getjobs()
     159
     160                cur_time = time.time()
    132161
    133162                jobs_processed = [ ]
     
    172201                        myAttrs['status'] = status
    173202                        myAttrs['start_timestamp'] = start_timestamp
     203                        myAttrs['reported_timestamp'] = str( int( cur_time ) )
    174204                        myAttrs['nodes'] = nodeslist
    175205                        myAttrs['domain'] = string.join( socket.getfqdn().split( '.' )[1:], '.' )
     
    186216        def submitJobData( self, jobs ):
    187217                """Submit job info list"""
    188 
    189                 time_now = time.time()
    190 
    191                 self.dp.multicastGmetric( 'TOGA-HEARTBEAT', str( time_now ), 'float' )
    192218
    193219                # Now let's spread the knowledge
     
    201227
    202228        def makeNodeString( self, nodelist ):
     229                """Make one big string of all hosts"""
    203230
    204231                node_str = None
     
    223250                status_str = 'status=' + jobattrs['status']
    224251                stime_str = 'stime=' + jobattrs['start_timestamp']
     252                reported_str = 'reported=' + jobattrs['reported_timestamp']
    225253                domain_str = 'domain=' + jobattrs['domain']
    226254                node_str = 'nodes=' + self.makeNodeString( jobattrs['nodes'] )
    227255
    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 ]
    229257
    230258                return self.makeAppendLists( appendList )
    231259
    232260        def makeAppendLists( self, append_list ):
     261                """
     262                Divide all values from append_list over strings with a maximum
     263                size of 1400
     264                """
    233265
    234266                app_lists = [ ]
Note: See TracChangeset for help on using the changeset viewer.