Changeset 212 for trunk/jobmond


Ignore:
Timestamp:
02/23/06 16:15:20 (15 years ago)
Author:
bastiaans
Message:

jobmond/jobmond.conf:

  • import of jobmond conf

jobmond/jobmond.py:

  • added config file support
Location:
trunk/jobmond
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/jobmond/jobmond.py

    r197 r212  
    11#!/usr/bin/env python
    22
    3 # Specify debugging level here;
    4 #
    5 # 10 = gemtric cmd's
    6 DEBUG_LEVEL = 0
    7 
    8 # Wether or not to run as a daemon in background
    9 #
    10 DAEMONIZE = 1
    11 
    12 # Which Torque server to monitor
    13 #
    14 TORQUE_SERVER = 'localhost'
    15 
    16 # How many seconds interval for polling of jobs
    17 #
    18 # this will effect directly how accurate the
    19 # end time of a job can be determined
    20 #
    21 TORQUE_POLL_INTERVAL = 10
    22 
    23 # Alternate location of gmond.conf
    24 #
    25 # Default: /etc/gmond.conf
    26 #
    27 #GMOND_CONF = '/etc/gmond.conf'
    28 
    29 # Wether or not to detect differences in
    30 # time from Torque server and local time.
    31 #
    32 # Ideally both machines (if not the same)
    33 # should have the same time (via ntp or whatever)
    34 #
    35 DETECT_TIME_DIFFS = 1
     3import sys, getopt, ConfigParser
     4
     5def processArgs( args ):
     6
     7        SHORT_L = 'c:'
     8        LONG_L = 'config='
     9
     10        config_filename = None
     11
     12        try:
     13
     14                opts, args = getopt.getopt( args, SHORT_L, LONG_L )
     15
     16        except getopt.error, detail:
     17
     18                print detail
     19                sys.exit(1)
     20
     21        for opt, value in opts:
     22
     23                if opt in [ '--config', '-c' ]:
     24               
     25                        config_filename = value
     26
     27        if not config_filename:
     28
     29                config_filename = '/etc/jobmond.conf'
     30
     31        return loadConfig( config_filename )
     32
     33def loadConfig( filename ):
     34
     35        cfg = ConfigParser.ConfigParser()
     36
     37        cfg.read( filename )
     38
     39        global DEBUG_LEVEL, DAEMONIZE, TORQUE_SERVER, TORQUE_POLL_INTERVAL, GMOND_CONF, DETECT_TIME_DIFFS
     40
     41
     42        # Specify debugging level here;
     43        #
     44        # 10 = gemtric cmd's
     45        DEBUG_LEVEL = cfg.getint( 'DEFAULT', 'DEBUG_LEVEL' )
     46
     47        # Wether or not to run as a daemon in background
     48        #
     49        DAEMONIZE = cfg.getboolean( 'DEFAULT', 'DAEMONIZE' )
     50
     51        # Which Torque server to monitor
     52        #
     53        TORQUE_SERVER = cfg.get( 'DEFAULT', 'TORQUE_SERVER' )
     54
     55        # How many seconds interval for polling of jobs
     56        #
     57        # this will effect directly how accurate the
     58        # end time of a job can be determined
     59        #
     60        TORQUE_POLL_INTERVAL = cfg.getint( 'DEFAULT', 'TORQUE_POLL_INTERVAL' )
     61
     62        # Alternate location of gmond.conf
     63        #
     64        # Default: /etc/gmond.conf
     65        #
     66        GMOND_CONF = cfg.get( 'DEFAULT', 'GMOND_CONF' )
     67
     68        # Wether or not to detect differences in
     69        # time from Torque server and local time.
     70        #
     71        # Ideally both machines (if not the same)
     72        # should have the same time (via ntp or whatever)
     73        #
     74        DETECT_TIME_DIFFS = cfg.getboolean( 'DEFAULT', 'DETECT_TIME_DIFFS' )
     75
     76        return True
    3677
    3778from PBSQuery import PBSQuery
    38 import sys
    39 import time
    40 import os
    41 import socket
    42 import string
     79
     80import time, os, socket, string
    4381
    4482class DataProcessor:
     
    416454                pid = os.fork()
    417455                if pid > 0:
    418                         sys.exit(0)  # end parrent
     456                        sys.exit(0)  # end parent
    419457
    420458                # creates a session and sets the process group ID
     
    426464                pid = os.fork()
    427465                if pid > 0:
    428                         sys.exit(0)  # end parrent
     466                        sys.exit(0)  # end parent
    429467
    430468                # Go to the root directory and set the umask
     
    466504        """Application start"""
    467505
     506        if not processArgs( sys.argv[1:] ):
     507                sys.exit( 1 )
     508
    468509        gather = DataGatherer()
    469510        if DAEMONIZE:
Note: See TracChangeset for help on using the changeset viewer.