Changeset 34 for trunk


Ignore:
Timestamp:
04/04/05 11:53:39 (19 years ago)
Author:
bastiaans
Message:

daemon/togad.py:

  • Numerous bugfixes Data is still not written, storeMetrics doesn't run
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/togad.py

    r33 r34  
    2020# <=7  = daemon threading - NOTE: Daemon will 'halt on all errors' from this level
    2121#
    22 DEBUG_LEVEL = 9
     22DEBUG_LEVEL = 10
    2323
    2424# Where is the gmetad.conf located
     
    8989                        if not self.clusters.has_key( self.clusterName ):
    9090
    91                                 self.clusters[ self.clusterName ] = RRDHandler( self.clusterName )
     91                                self.clusters[ self.clusterName ] = RRDHandler( self.config, self.clusterName )
    9292
    9393                        debug_msg( 10, ' |-Cluster found: %s' %( self.clusterName ) )
     
    112112                                myMetric['time'] = self.hostReported
    113113
    114                                 self.clusters[ self.clusterName ].memMetric( self.hostname, myMetric )
    115 
    116                         debug_msg( 11, ' | | |-metric: %s:%s' %( myMetric['name'], myMetric['val'] ) )
    117 
    118         def storeMetrics( self, hostname, timeserial ):
    119 
    120                 for cluster in self.clusters:
    121 
    122                         cluster.storeMetrics()
     114                                self.clusters[ self.clusterName ].memMetric( self.hostName, myMetric )
     115
     116                                debug_msg( 11, ' | | |-metric: %s:%s' %( myMetric['name'], myMetric['val'] ) )
     117
     118        def storeMetrics( self ):
     119
     120                for clustername, rrdh in self.clusters.items():
     121
     122                        print 'storing metrics of cluster ' + clustername
     123                        rrdh.storeMetrics()
    123124
    124125class GangliaXMLGatherer:
     
    264265                        # Make sure XML is processed on time and at regular intervals
    265266
    266                         debug_msg( 7, self.printTime() + ' - mainthread() - Sleep '+ str( self.config.getInterval() ) +'s: zzzzz..' )
    267                         time.sleep( self.config.getInterval() )
     267                        debug_msg( 7, self.printTime() + ' - mainthread() - Sleep '+ str( self.config.getLowestInterval() ) +'s: zzzzz..' )
     268                        time.sleep( float( self.config.getLowestInterval() ) )
    268269                        debug_msg( 7, self.printTime() + ' - mainthread() - Awoken: waiting for XML thread..' )
    269270
     
    309310class GangliaConfigParser:
    310311
    311         sources = { }
     312        sources = [ ]
    312313
    313314        def __init__( self, config ):
     
    363364                return None
    364365
     366        def getLowestInterval( self ):
     367
     368                lowest_interval = 0
     369
     370                for source in self.sources:
     371
     372                        if not lowest_interval or source['interval'] <= lowest_interval:
     373
     374                                lowest_interval = source['interval']
     375
     376                # Return 15 when nothing is found, so that the daemon won't go insane with 0 sec delays
     377                if lowest_interval:
     378                        return lowest_interval
     379                else:
     380                        return 15
     381
    365382class RRDHandler:
    366383
     
    376393        def memMetric( self, host, metric ):
    377394
    378                 for m in self.myMetrics[ host ]:
    379 
    380                         if m['time'] == metric['time']:
    381 
    382                                 # Allready have this metric, abort
    383                                 return 1
    384 
    385                 if not self.myMetrics.has_key( host ):
    386 
     395                if self.myMetrics.has_key( host ):
     396
     397                        if self.myMetrics[ host ].has_key( metric['name'] ):
     398
     399                                for mymetric in self.myMetrics[ host ][ metric['name'] ]:
     400
     401                                        if mymetric['time'] == metric['time']:
     402
     403                                                # Allready have this metric, abort
     404                                                return 1
     405                        else:
     406                                self.myMetrics[ host ][ metric['name'] ] = [ ]
     407                else:
    387408                        self.myMetrics[ host ] = { }
    388 
    389                 if not self.myMetrics[ host ].has_key( metric['name'] ):
    390 
    391409                        self.myMetrics[ host ][ metric['name'] ] = [ ]
     410
    392411
    393412                self.myMetrics[ host ][ metric['name'] ].append( metric )
Note: See TracChangeset for help on using the changeset viewer.