Ejemplo n.º 1
0
def setup_logging(options):
    # Set log levels if the user has asked for it

    logging_level = LOGGING_LEVELS.get(options.logging_level)

    if logging_level is None:
        logging_level = 20 # 20 -> 'info' logging level

    logging.basicConfig(level=logging_level,
        format='%(asctime)s %(levelname)s: %(message)s',
        datefmt='%Y-%m-%d %H:%M:%S')

    Utils.set_logging(logging_level)
    LoadAnalysisLib.set_logging(logging_level)
Ejemplo n.º 2
0
def main():

    # Setup parser options & parse them
    parser = setup_parser_options()
    (options, args) = parser.parse_args()

    # Setup logging if requested
    setup_logging(options)

    # Check for arguments, in this case, directories containing file data
    if len(args) < 1:
        parser.error("no arguments given.")

    # Setup the output file to write the results to, if requested
    if options.output_to_file:
        LoadAnalysisLib.output_to_file = True
        Utils.filepath = 'results/' + options.output_to_file

    # Parse out all of the file data provided
    all_file_data = LoadAnalysisLib.parse_data_files(args)

    # Print debug info about all of the original file data, if requested
    if options.logging_level == 'debug':
        LoadAnalysisLib.log_debug_file_data("original", all_file_data)

    # Analyze all of the original file data and log it
    title, log = "original", True
    LoadAnalysisLib.analyze(all_file_data, title, log)
    
    # Clean up outliers if requested & reset the file data to be the clean data
    if options.cleanup_level:
        cleanup_level = int(options.cleanup_level)

        # Clean the original file data
        all_file_data_cleaned = \
                LoadAnalysisLib.cleanup_file_data(all_file_data, \
                cleanup_level)

        # Reset the original file data to now be the clean file data
        all_file_data = all_file_data_cleaned

        # Analyze all of the clean file data and log it
        title, log = "clean", True
        LoadAnalysisLib.analyze(all_file_data, title, log)

    # Trim the file data (original or clean) based off of a shared timestamp
    # threshold
    all_file_data_trimmed = \
        LoadAnalysisLib.trim_lists_by_common_threshold(all_file_data)

    # Print debug info about the trimmed file data (original or clean),
    # if requested
    if options.logging_level == 'debug':
        LoadAnalysisLib.log_debug_file_data("trimmed", all_file_data_trimmed)

    # Find the mean of all delta standard deviations found (from the trimmed
    # file data)
    LoadAnalysisLib.compute_mean_of_file_data_stds(\
            all_file_data_trimmed)
    
    # Plot the trimmed file data (original or clean)
    if options.plot_filename:
        filepath = '/'.join(['graphs', options.plot_filename])

        # Collect all of the timestamps and deltas
        all_timestamps = \
            LoadAnalysisLib.collect_all_timestamps(all_file_data_trimmed)
        all_deltas = \
            LoadAnalysisLib.collect_all_deltas(all_file_data_trimmed)

        # Plot the data
        plot_title = "Load Analysis"
        Utils.plot_data(all_timestamps, all_deltas, plot_title, filepath)