Changeset 41 for trunk/daemon


Ignore:
Timestamp:
04/05/05 12:29:35 (19 years ago)
Author:
bastiaans
Message:

daemon/togad.py:

  • Added queue len check in atomic code before pop, len might change before start
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/togad.py

    r40 r41  
    9595                for line in os.popen( self.binary + ' ' + action + ' ' + filename + ' ' + arg_string ).readlines():
    9696
    97                         print line
    98 
    9997                        if line.find( 'ERROR' ) != -1:
    10098
     
    515513
    516514                update_list = [ ]
     515                metric = None
    517516
    518517                while len( self.myMetrics[ host ][ metricname ] ) > 0:
     
    523522                        self.slot.acquire()
    524523
    525                         metric = self.myMetrics[ host ][ metricname ].pop()
     524                        # len might have changed since loop start
     525                        #
     526                        if len( self.myMetrics[ host ][ metricname ] ) > 0:
     527                                metric = self.myMetrics[ host ][ metricname ].pop()
    526528
    527529                        self.slot.release()
    528530                        # </atomic>
    529531
    530                         if self.checkStoreMetric( host, metricname, metric ):
    531                                 update_list.append( '%s:%s' %( metric['time'], metric['val'] ) )
    532                         else:
    533                                 print 'allready wrote metric %s with timestamp %s' %( metric['name'], metric['time'] )
     532                        if metric:
     533                                if self.checkStoreMetric( host, metricname, metric ):
     534                                        update_list.append( '%s:%s' %( metric['time'], metric['val'] ) )
     535                                else:
     536                                        print 'allready wrote metric %s with timestamp %s' %( metric['name'], metric['time'] )
    534537
    535538                return update_list
     
    569572                                else:
    570573                                        debug_msg( 9, 'metric update failed' )
    571                                         return 1
    572 
    573                                 return 1
    574574
    575575        def makeTimeSerial( self ):
     
    707707                update_list = self.makeUpdateList( host, metricname )
    708708
    709                 ret = self.rrdm.update( str(rrd_file), update_list )
    710 
    711                 if ret:
    712                         return 1
     709                if len( update_list ) > 0:
     710                        ret = self.rrdm.update( str(rrd_file), update_list )
     711
     712                        if ret:
     713                                return 1
    713714               
    714                 debug_msg( 9, 'updated rrd %s with %s' %( str(rrd_file), string.join( update_list ) ) )
     715                        debug_msg( 9, 'updated rrd %s with %s' %( str(rrd_file), string.join( update_list ) ) )
    715716
    716717                return 0
Note: See TracChangeset for help on using the changeset viewer.