Changeset 466 for trunk/jobarchived
- Timestamp:
- 02/21/08 10:16:36 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jobarchived/jobarchived.py
r455 r466 22 22 # 23 23 24 DEFAULT_SEARCH_PATH = '/usr/share/jobarchived' 25 26 import sys 27 28 if DEFAULT_SEARCH_PATH not in sys.path: 29 30 sys.path.append( DEFAULT_SEARCH_PATH ) 31 32 import getopt, syslog, ConfigParser 33 34 def usage(): 24 import getopt, syslog, ConfigParser, sys 25 26 VERSION='0.3SVN' 27 28 def usage( ver ): 29 30 print 'jobarchived %s' %VERSION 31 32 if ver: 33 return 0 35 34 36 35 print 37 print 'usage: jobarchived [options]' 38 print 'options:' 39 print ' --config, -c configuration file' 40 print ' --pidfile, -p pid file' 41 print ' --help, -h help' 36 print 'Purpose:' 37 print ' The Job Archive Daemon (jobarchived) stores batch job information in a SQL database' 38 print ' and node statistics in a RRD archive' 39 print 40 print 'Usage: jobarchived [OPTIONS]' 41 print 42 print ' -c, --config=FILE The configuration file to use (default: /etc/jobarchived.conf)' 43 print ' -p, --pidfile=FILE Use pid file to store the process id' 44 print ' -h, --help Print help and exit' 45 print ' -v, --version Print version and exit' 42 46 print 43 47 … … 47 51 LONG_L = [ 'help', 'config=', 'pidfile=' ] 48 52 49 config_filename = None53 config_filename = '/etc/jobarchived.conf' 50 54 51 55 global PIDFILE … … 74 78 if opt in [ '--help', '-h' ]: 75 79 76 usage( )80 usage( false ) 77 81 sys.exit( 0 ) 78 82 79 if not config_filename: 80 81 config_filename = '/etc/jobarchived.conf' 83 if opt in [ '--version', '-v' ]: 84 85 usage( true ) 86 sys.exit( 0 ) 82 87 83 88 try: … … 127 132 cfg.read( filename ) 128 133 129 global DEBUG_LEVEL, USE_SYSLOG, SYSLOG_LEVEL, SYSLOG_FACILITY, GMETAD_CONF, ARCHIVE_XMLSOURCE, ARCHIVE_DATASOURCES, ARCHIVE_PATH, ARCHIVE_HOURS_PER_RRD, ARCHIVE_EXCLUDE_METRICS, JOB_SQL_DBASE, DAEMONIZE, RRDTOOL, JOB_TIMEOUT, MODRRDTOOL 134 global DEBUG_LEVEL, USE_SYSLOG, SYSLOG_LEVEL, SYSLOG_FACILITY, GMETAD_CONF, ARCHIVE_XMLSOURCE 135 global ARCHIVE_DATASOURCES, ARCHIVE_PATH, ARCHIVE_HOURS_PER_RRD, ARCHIVE_EXCLUDE_METRICS 136 global JOB_SQL_DBASE, DAEMONIZE, RRDTOOL, JOB_TIMEOUT, MODRRDTOOL 130 137 131 138 ARCHIVE_PATH = cfg.get( 'DEFAULT', 'ARCHIVE_PATH' ) … … 150 157 MODRRDTOOL = False 151 158 152 debug_msg( 0, "ERROR: py-rrdtool import FAILED: failing back to DEPRECATED use of rrdtool binary. This will slow down job mond significantly!" )159 debug_msg( 0, "ERROR: py-rrdtool import FAILED: failing back to DEPRECATED use of rrdtool binary. This will slow down jobarchived significantly!" ) 153 160 154 161 RRDTOOL = cfg.get( 'DEFAULT', 'RRDTOOL' ) … … 199 206 200 207 import xml.sax, xml.sax.handler, socket, string, os, os.path, time, thread, threading, random, re 201 import rrdtool202 208 from pyPgSQL import PgSQL 203 209 … … 545 551 def checkStaleJobs( self ): 546 552 553 # Locate all jobs in the database that are not set to finished 554 # 547 555 q = "SELECT * from jobs WHERE job_status != 'F'" 548 556 … … 566 574 job_start_timestamp = row[8] 567 575 576 # If it was set to queued and we didn't see it started 577 # there's not point in keeping it around 578 # 568 579 if job_status == 'Q' or not job_start_timestamp: 569 580 … … 574 585 start_timestamp = int( job_start_timestamp ) 575 586 587 # If it was set to running longer than JOB_TIMEOUT 588 # close the job: it probably finished while we were not running 589 # 576 590 if ( cur_time - start_timestamp ) > jobtimeout_sec: 577 591 … … 586 600 debug_msg( 1, 'Found ' + str( len( cleanjobs ) ) + ' stale jobs in database: deleting entries' ) 587 601 602 # Purge these from database 603 # 588 604 for j in cleanjobs: 589 605 … … 593 609 debug_msg( 1, 'Found ' + str( len( timeoutjobs ) ) + ' timed out jobs in database: closing entries' ) 594 610 611 # Close these jobs in the database 612 # update the stop_timestamp to: start_timestamp + requested wallclock 613 # and set state: finished 614 # 595 615 for j in timeoutjobs: 596 616 … … 642 662 last_update = 0 643 663 664 # Use the py-rrdtool module if it's available on this system 665 # 644 666 if MODRRDTOOL: 645 667 … … 658 680 return 0 659 681 682 # For backwards compatiblity: use the rrdtool binary if py-rrdtool is unavailable 683 # DEPRECATED (slow!) 684 # 660 685 else: 661 686 debug_msg( 8, self.binary + ' info ' + filename ) … … 752 777 """Setup initial XML connection and handlers""" 753 778 754 #self.myXMLGatherer = XMLGatherer( ARCHIVE_XMLSOURCE.split( ':' )[0], ARCHIVE_XMLSOURCE.split( ':' )[1] )755 #self.myXMLSource = self.myXMLGatherer.getFileObject()756 779 self.myXMLSource = XMLSource 757 780 self.myXMLHandler = TorqueXMLHandler( DataStore )
Note: See TracChangeset
for help on using the changeset viewer.