Changeset 102 for trunk/daemon/togad.py


Ignore:
Timestamp:
05/12/05 10:21:25 (19 years ago)
Author:
bastiaans
Message:

daemon/togad.py:

Some naming changes

web:

Initial checkin of web frontend

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/togad.py

    r100 r102  
    2323# 1  = daemon threading
    2424#
    25 DEBUG_LEVEL = 7
     25DEBUG_LEVEL = 1
    2626
    2727# Where is the gmetad.conf located
     
    388388                """Main XML processing"""
    389389
    390                 debug_msg( 5, printTime() + ' - torquexmlthread(): started.' )
     390                debug_msg( 1, printTime() + ' - torque_xml_thread(): started.' )
    391391
    392392                while( 1 ):
    393393
    394394                        self.myXMLSource = self.myXMLGatherer.getFileObject()
    395                         debug_msg( 1, printTime() + ' - torquexmlthread(): Parsing..' )
     395                        debug_msg( 1, printTime() + ' - torque_xml_thread(): Parsing..' )
    396396                        xml.sax.parse( self.myXMLSource, self.myXMLHandler, self.myXMLError )
    397                         debug_msg( 1, printTime() + ' - torquexmlthread(): Done parsing.' )
    398                         debug_msg( 1, printTime() + ' - torquexmlthread(): Sleeping.. (%ss)' %(str( self.config.getLowestInterval() ) ) )
     397                        debug_msg( 1, printTime() + ' - torque_xml_thread(): Done parsing.' )
     398                        debug_msg( 1, printTime() + ' - torque_xml_thread(): Sleeping.. (%ss)' %(str( self.config.getLowestInterval() ) ) )
    399399                        time.sleep( self.config.getLowestInterval() )
    400400
     
    462462                                                        self.jobs_to_store.append( job_id )
    463463
    464                                                 debug_msg( 0, 'jobinfo for job %s has changed' %job_id )
     464                                                debug_msg( 6, 'jobinfo for job %s has changed' %job_id )
    465465                                else:
    466466                                        self.jobAttrs[ job_id ] = jobinfo
     
    469469                                                self.jobs_to_store.append( job_id )
    470470
    471                                         debug_msg( 0, 'jobinfo for job %s has changed' %job_id )
     471                                        debug_msg( 6, 'jobinfo for job %s has changed' %job_id )
    472472                                       
    473473        def endDocument( self ):
     
    480480                        #
    481481                        mytime = int( jobinfo['reported'] ) + int( jobinfo['poll_interval'] )
     482
    482483                        if mytime < self.heartbeat and jobid not in self.jobs_processed and jobinfo['status'] == 'R':
    483484
     
    491492                                        self.jobs_to_store.append( jobid )
    492493
    493                 debug_msg( 1, printTime() + ' - torquexmlthread(): Storing..' )
     494                debug_msg( 1, printTime() + ' - torque_xml_thread(): Storing..' )
    494495
    495496                for jobid in self.jobs_to_store:
    496497                        self.ds.storeJobInfo( jobid, self.jobAttrs[ jobid ] )   
    497498
    498                 debug_msg( 1, printTime() + ' - torquexmlthread(): Done storing.' )
     499                debug_msg( 1, printTime() + ' - torque_xml_thread(): Done storing.' )
    499500
    500501                self.jobs_processed = [ ]
     
    759760                """Main XML processing; start a xml and storethread"""
    760761
    761                 xmlthread = threading.Thread( None, self.processXML, 'xmlthread' )
    762                 storethread = threading.Thread( None, self.storeMetrics, 'storethread' )
     762                xml_thread = threading.Thread( None, self.processXML, 'xmlthread' )
     763                store_thread = threading.Thread( None, self.storeMetrics, 'storethread' )
    763764
    764765                while( 1 ):
    765766
    766                         if not xmlthread.isAlive():
     767                        if not xml_thread.isAlive():
    767768                                # Gather XML at the same interval as gmetad
    768769
    769770                                # threaded call to: self.processXML()
    770771                                #
    771                                 xmlthread = threading.Thread( None, self.processXML, 'xmlthread' )
    772                                 xmlthread.start()
    773 
    774                         if not storethread.isAlive():
     772                                xml_thread = threading.Thread( None, self.processXML, 'xml_thread' )
     773                                xml_thread.start()
     774
     775                        if not store_thread.isAlive():
    775776                                # Store metrics every .. sec
    776777
    777778                                # threaded call to: self.storeMetrics()
    778779                                #
    779                                 storethread = threading.Thread( None, self.storeMetrics, 'storethread' )
    780                                 storethread.start()
     780                                store_thread = threading.Thread( None, self.storeMetrics, 'store_thread' )
     781                                store_thread.start()
    781782               
    782783                        # Just sleep a sec here, to prevent daemon from going mad. We're all threads here anyway
     
    786787                """Store metrics retained in memory to disk"""
    787788
    788                 debug_msg( 7, printTime() + ' - storethread(): started.' )
     789                debug_msg( 1, printTime() + ' - ganglia_store_thread(): started.' )
    789790
    790791                # Store metrics somewhere between every 360 and 640 seconds
     
    792793                STORE_INTERVAL = random.randint( 360, 640 )
    793794
    794                 storethread = threading.Thread( None, self.storeThread, 'storemetricthread' )
    795                 storethread.start()
    796 
    797                 debug_msg( 7, printTime() + ' - storethread(): Sleeping.. (%ss)' %STORE_INTERVAL )
     795                store_metric_thread = threading.Thread( None, self.storeThread, 'store_metric_thread' )
     796                store_metric_thread.start()
     797
     798                debug_msg( 1, printTime() + ' - ganglia_store_thread(): Sleeping.. (%ss)' %STORE_INTERVAL )
    798799                time.sleep( STORE_INTERVAL )
    799                 debug_msg( 7, printTime() + ' - storethread(): Done sleeping.' )
    800 
    801                 if storethread.isAlive():
    802 
    803                         debug_msg( 7, printTime() + ' - storethread(): storemetricthread() still running, waiting to finish..' )
     800                debug_msg( 1, printTime() + ' - ganglia_store_thread(): Done sleeping.' )
     801
     802                if store_metric_thread.isAlive():
     803
     804                        debug_msg( 1, printTime() + ' - ganglia_store_thread(): storemetricthread() still running, waiting to finish..' )
    804805                        storethread.join( STORE_TIMEOUT ) # Maximum time is for storing thread to finish
    805                         debug_msg( 7, printTime() + ' - storethread(): Done waiting.' )
    806 
    807                 debug_msg( 7, printTime() + ' - storethread(): finished.' )
     806                        debug_msg( 1, printTime() + ' - ganglia_store_thread(): Done waiting.' )
     807
     808                debug_msg( 1, printTime() + ' - ganglia_store_thread(): finished.' )
    808809
    809810                return 0
     
    812813                """Actual metric storing thread"""
    813814
    814                 debug_msg( 1, printTime() + ' - storemetricthread(): started.' )
    815                 debug_msg( 1, printTime() + ' - storemetricthread(): Storing data..' )
     815                debug_msg( 1, printTime() + ' - ganglia_store_metric_thread(): started.' )
     816                debug_msg( 1, printTime() + ' - ganglia_store_metric_thread(): Storing data..' )
    816817                ret = self.myXMLHandler.storeMetrics()
    817                 debug_msg( 1, printTime() + ' - storemetricthread(): Done storing.' )
    818                 debug_msg( 1, printTime() + ' - storemetricthread(): finished.' )
     818                debug_msg( 1, printTime() + ' - ganglia_store_metric_thread(): Done storing.' )
     819                debug_msg( 1, printTime() + ' - ganglia_store_metric_thread(): finished.' )
    819820               
    820821                return ret
     
    828829                parsethread.start()
    829830
    830                 debug_msg( 1, printTime() + ' - xmlthread(): Sleeping.. (%ss)' %self.config.getLowestInterval() )
     831                debug_msg( 1, printTime() + ' - ganglia_xml_thread(): Sleeping.. (%ss)' %self.config.getLowestInterval() )
    831832                time.sleep( float( self.config.getLowestInterval() ) ) 
    832                 debug_msg( 1, printTime() + ' - xmlthread(): Done sleeping.' )
     833                debug_msg( 1, printTime() + ' - ganglia_xml_thread(): Done sleeping.' )
    833834
    834835                if parsethread.isAlive():
    835836
    836                         debug_msg( 1, printTime() + ' - xmlthread(): parsethread() still running, waiting to finish..' )
     837                        debug_msg( 1, printTime() + ' - ganglia_xml_thread(): parsethread() still running, waiting to finish..' )
    837838                        parsethread.join( PARSE_TIMEOUT ) # Maximum time for XML thread to finish
    838                         debug_msg( 7, printTime() + ' - xmlthread(): Done waiting.' )
    839 
    840                 debug_msg( 1, printTime() + ' - xmlthread(): finished.' )
     839                        debug_msg( 1, printTime() + ' - ganglia_xml_thread(): Done waiting.' )
     840
     841                debug_msg( 1, printTime() + ' - ganglia_xml_thread(): finished.' )
    841842
    842843                return 0
     
    845846                """Actual parsing thread"""
    846847
    847                 debug_msg( 1, printTime() + ' - parsethread(): started.' )
    848                 debug_msg( 1, printTime() + ' - parsethread(): Parsing XML..' )
     848                debug_msg( 1, printTime() + ' - ganglia_parse_thread(): started.' )
     849                debug_msg( 1, printTime() + ' - ganglia_parse_thread(): Parsing XML..' )
    849850                self.myXMLSource = self.myXMLGatherer.getFileObject()
    850851                ret = xml.sax.parse( self.myXMLSource, self.myXMLHandler, self.myXMLError )
    851                 debug_msg( 1, printTime() + ' - parsethread(): Done parsing.' )
    852                 debug_msg( 1, printTime() + ' - parsethread(): finished.' )
     852                debug_msg( 1, printTime() + ' - ganglia_parse_thread(): Done parsing.' )
     853                debug_msg( 1, printTime() + ' - ganglia_parse_thread(): finished.' )
    853854
    854855                return ret
     
    12991300        """Program startup"""
    13001301
    1301         myTProcessor = TorqueXMLProcessor()
    1302         myGProcessor = GangliaXMLProcessor()
     1302        myTorqueProcessor = TorqueXMLProcessor()
     1303        myGangliaProcessor = GangliaXMLProcessor()
    13031304
    13041305        if DAEMONIZE:
    1305                 torquexmlthread = threading.Thread( None, myTProcessor.daemon, 'tprocxmlthread' )
    1306                 gangliaxmlthread = threading.Thread( None, myGProcessor.daemon, 'gprocxmlthread' )
     1306                torque_xml_thread = threading.Thread( None, myTorqueProcessor.daemon, 'torque_proc_thread' )
     1307                ganglia_xml_thread = threading.Thread( None, myGangliaProcessor.daemon, 'ganglia_proc_thread' )
    13071308        else:
    1308                 torquexmlthread = threading.Thread( None, myTProcessor.run, 'tprocxmlthread' )
    1309                 gangliaxmlthread = threading.Thread( None, myGProcessor.run, 'gprocxmlthread' )
    1310 
    1311         torquexmlthread.start()
    1312         gangliaxmlthread.start()
     1309                torque_xml_thread = threading.Thread( None, myTorqueProcessor.run, 'torque_proc_thread' )
     1310                ganglia_xml_thread = threading.Thread( None, myGangliaProcessor.run, 'ganglia_proc_thread' )
     1311
     1312        torque_xml_thread.start()
     1313        ganglia_xml_thread.start()
    13131314
    13141315# Global functions
Note: See TracChangeset for help on using the changeset viewer.