Changeset 353 for trunk


Ignore:
Timestamp:
05/03/07 12:13:52 (17 years ago)
Author:
bastiaans
Message:

jobmond/jobmond.conf:

  • added GMETRIC_TARGET

jobmond/gmetric.py:

  • checkin of native python gmetric support, thanks to Nick Galbreath

jobmond/jobmond.py:

  • added handling of GMETRIC_TARGET
  • GMOND_CONF is now deprecated (GMETRIC_TARGET should be used) but we are still backwards compatible
Location:
trunk/jobmond
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/jobmond/jobmond.conf

    r317 r353  
    3636# Default: /etc/gmond.conf
    3737#
    38 GMOND_CONF              : /etc/gmond.conf
     38# DEPRECATED!:          use GMETRIC_TARGET!
     39#
     40#GMOND_CONF             : /etc/gmond.conf
     41
     42# Target of Gmetric's: where should we report to
     43# (usually: your udp_send_channel from gmond)
     44#
     45GMETRIC_TARGET          : 239.2.11.71:8649
    3946
    4047# Wether or not to detect differences in
  • trunk/jobmond/jobmond.py

    r352 r353  
    114114        cfg.read( filename )
    115115
    116         global DEBUG_LEVEL, DAEMONIZE, BATCH_SERVER, BATCH_POLL_INTERVAL, GMOND_CONF, DETECT_TIME_DIFFS, BATCH_HOST_TRANSLATE, BATCH_API, QUEUE
     116        global DEBUG_LEVEL, DAEMONIZE, BATCH_SERVER, BATCH_POLL_INTERVAL, GMOND_CONF, DETECT_TIME_DIFFS, BATCH_HOST_TRANSLATE, BATCH_API, QUEUE, GMETRIC_TARGET
    117117
    118118        DEBUG_LEVEL = cfg.getint( 'DEFAULT', 'DEBUG_LEVEL' )
     
    143143                BATCH_POLL_INTERVAL = cfg.getint( 'DEFAULT', 'TORQUE_POLL_INTERVAL' )
    144144                api_guess = 'pbs'
    145                
    146         GMOND_CONF = cfg.get( 'DEFAULT', 'GMOND_CONF' )
     145       
     146        try:
     147
     148                GMOND_CONF = cfg.get( 'DEFAULT', 'GMOND_CONF' )
     149
     150        except ConfigParser.NoOptionError:
     151
     152                GMOND_CONF = None
    147153
    148154        DETECT_TIME_DIFFS = cfg.getboolean( 'DEFAULT', 'DETECT_TIME_DIFFS' )
     
    169175
    170176                QUEUE = None
    171        
     177
     178        try:
     179
     180                GMETRIC_TARGET = cfg.get( 'DEFAULT', 'GMETRIC_TARGET' )
     181
     182        except ConfigParser.NoOptionError:
     183
     184                GMETRIC_TARGET = None
     185
     186                if not GMOND_CONF:
     187
     188                        debug_msg( 0, "fatal error: GMETRIC_TARGET or GMOND_CONF both not set!" )
     189                        sys.exit( 1 )
     190                else:
     191
     192                        debug_msg( 0, "error: GMETRIC_TARGET not set: internel Gmetric handling aborted. Failing back to DEPRECATED use of gmond.conf/gmetric binary. This will slow down jobmond significantly!" )
     193
    172194        return True
    173195
     
    197219                self.dmax = str( int( int( BATCH_POLL_INTERVAL ) * 2 ) )
    198220
    199                 try:
    200                         gmond_file = GMOND_CONF
    201 
    202                 except NameError:
    203                         gmond_file = '/etc/gmond.conf'
    204 
    205                 if not os.path.exists( gmond_file ):
    206                         debug_msg( 0, gmond_file + ' does not exist' )
    207                         sys.exit( 1 )
    208 
    209                 incompatible = self.checkGmetricVersion()
    210 
    211                 if incompatible:
    212                         debug_msg( 0, 'Gmetric version not compatible, pls upgrade to at least 3.0.1' )
    213                         sys.exit( 1 )
     221                if GMOND_CONF:
     222                        try:
     223                                gmond_file = GMOND_CONF
     224
     225                        except NameError:
     226                                gmond_file = '/etc/gmond.conf'
     227
     228                        if not os.path.exists( gmond_file ):
     229                                debug_msg( 0, 'fatal error: ' + gmond_file + ' does not exist' )
     230                                sys.exit( 1 )
     231
     232                        incompatible = self.checkGmetricVersion()
     233
     234                        if incompatible:
     235                                debug_msg( 0, 'Gmetric version not compatible, pls upgrade to at least 3.0.1' )
     236                                sys.exit( 1 )
    214237
    215238        def checkGmetricVersion( self ):
     
    264287                cmd = self.binary
    265288
    266                 try:
    267                         cmd = cmd + ' -c' + GMOND_CONF
    268                 except NameError:
    269                         debug_msg( 10, 'Assuming /etc/gmond.conf for gmetric cmd (ommitting)' )
    270 
    271                 cmd = cmd + ' -n' + str( metricname )+ ' -v"' + str( metricval )+ '" -t' + str( valtype ) + ' -d' + str( self.dmax )
    272 
    273                 debug_msg( 10, printTime() + ' ' + cmd )
    274                 os.system( cmd )
     289                if GMETRIC_TARGET:
     290
     291                        from gmetric import Gmetric
     292
     293                if GMETRIC_TARGET:
     294
     295                        GMETRIC_TARGET_HOST     = GMETRIC_TARGET.split( ':' )[0]
     296                        GMETRIC_TARGET_PORT     = GMETRIC_TARGET.split( ':' )[1]
     297
     298                        metric_debug            = "[gmetric] name: %s - val: %s - dmax: %s" %( str( metricname ), str( metricval ), str( self.dmax ) )
     299
     300                        debug_msg( 10, printTime() + ' ' + metric_debug)
     301
     302                        gm = Gmetric( GMETRIC_TARGET_HOST, GMETRIC_TARGET_PORT )
     303
     304                        gm.send( str( metricname ), str( metricval ), str( self.dmax ) )
     305
     306                else:
     307                        try:
     308                                cmd = cmd + ' -c' + GMOND_CONF
     309
     310                        except NameError:
     311
     312                                debug_msg( 10, 'Assuming /etc/gmond.conf for gmetric cmd (ommitting)' )
     313
     314                        cmd = cmd + ' -n' + str( metricname )+ ' -v"' + str( metricval )+ '" -t' + str( valtype ) + ' -d' + str( self.dmax )
     315
     316                        debug_msg( 10, printTime() + ' ' + cmd )
     317
     318                        os.system( cmd )
    275319
    276320class DataGatherer:
Note: See TracChangeset for help on using the changeset viewer.