Example #1
0
import logging
import os
import sys
import itertools
import importlib

from pmort.parameters import PARAMETERS
from pmort.parameters import CONFIGURATION_DIRECTORY

logger = logging.getLogger(__name__)

PARAMETERS.add_parameter(
        options = [ '--directory', ],
        group = 'collectors',
        default = os.path.join(CONFIGURATION_DIRECTORY, 'collectors.d'),
        help = \
                'Specify another directory to read collectors from.  The ' \
                'default directory is in the pmort configuration directory. ' \
                'Default: %(default)s'
        )

COLLECTORS = {}

# TODO Clean up this module …

def load_collectors(module_basename = __name__, directory = os.path.dirname(__file__), update_path = False):
    '''Load all modules (allowing collectors to register) in directory.

    All python modules in the given directory will be imported.  Collectors
    should be registering themselves by adding themselves to the COLLECTORS
    dict provided by this module.
Example #2
0
import os
import itertools
import subprocess
import re

from pmort.parameters import PARAMETERS
from pmort.parameters import CONFIGURATION_DIRECTORY
from pmort.collectors import COLLECTORS
from pmort.output import write_output

logger = logging.getLogger(__name__)

PARAMETERS.add_parameter(
        options = [ '--directory' ],
        group = 'collector_execute',
        default = os.path.join(CONFIGURATION_DIRECTORY, 'collectors.d'),
        help = \
                'Directory in which to search for non-standard collectors.  ' \
                'Default: %(default)s'
        )

def find_scripts(directory = os.path.dirname(__file__)):
    '''Find executable scripts (with shebang) in specified directory.

    Finds the scripts that can be executed in the specified directory.  Any
    scripts that are missing a shebang or the executable bit will be skipped.

    .. note::
        All python files are excluded as it's assumed that the main collector
        loading function will load those and run them.

    Arguments
Example #3
0
        'LEARNERS',
        ]

import logging
import os
import itertools
import importlib

from pmort.parameters import PARAMETERS

logger = logging.getLogger(__name__)

PARAMETERS.add_parameter(
        options = [ '--active', ],
        group = 'learner',
        default = 'linear', # TODO Switch to predictive.
        help = \
                'The learner algorithm to utilize for determining inter-run ' \
                'timings.  Default %(default)s'
        )

PARAMETERS.add_parameter(
        options = [ '--maximum-interval', ],
        group = 'learner',
        default = 600,
        type = int,
        help = \
                'Set the maximum time between collections by %(prog)s.  This ' \
                'specifies the maximum number of seconds between ' \
                'collections.  Default %(default)s'
        )