def main(): parser = argparse.ArgumentParser(description=DESCRIPTION, usage=USAGE) parser.add_argument("command", help="the command to run") parser.add_argument("-c", "--config-path", default=DEFAULT_CONFIG_PATH, help="configuration path, checks also folder 'default' on given path [{}]" .format(DEFAULT_CONFIG_PATH)) args = parser.parse_args() conf = find_and_parse_config(args.config_path) if 'postgres' not in conf: raise Exception("failed parsing configuration from: " + args.config_path) log_level = conf.get('log', {}).get('log_level', 'debug') if args.command == 'all': init_logging_stderr(log_level) db_connections = get_db_connections_with_conf(conf) get_all_metrics_now(db_connections, conf) print "# sleep 5 s to get diffs on derivative metrics" time.sleep(5.0) for metric in get_all_metrics_now(db_connections, conf): print metric elif args.command == 'long-running-ffwd': if conf['log']['log_to_stderr'] is True: init_logging_stderr(log_level) if conf['log']['log_to_file'] is True: init_logging_file(conf['log']['filename'], log_level, conf['log']['rotate_file_log'], conf['log']['file_rotate_max_size']) run_long_running_ffwd(conf) elif args.command == 'prepare-db': init_logging_stderr(log_level) prepare_databases_for_metrics(conf)
def main(): parser = argparse.ArgumentParser(description=DESCRIPTION, usage=USAGE) parser.add_argument("command", help="the command to run") parser.add_argument( "-c", "--config-path", default=DEFAULT_CONFIG_PATH, help= "configuration path, checks also folder 'default' on given path [{}]". format(DEFAULT_CONFIG_PATH)) args = parser.parse_args() conf = find_and_parse_config(args.config_path) if 'postgres' not in conf: raise Exception("failed parsing configuration from: " + args.config_path) log_level = conf.get('log', {}).get('log_level', 'debug') if args.command == 'all': init_logging_stderr(log_level) db_connections = get_db_connections_with_conf(conf) get_all_metrics_now(db_connections, conf) print("# sleep 5 s to get diffs on derivative metrics") time.sleep(5.0) for metric in get_all_metrics_now(db_connections, conf): print(metric) elif args.command == 'long-running-ffwd': if conf['log']['log_to_stderr'] is True: init_logging_stderr(log_level) if conf['log']['log_to_file'] is True: init_logging_file(conf['log']['filename'], log_level, conf['log']['rotate_file_log'], conf['log']['file_rotate_max_size']) if conf['log']['log_to_syslog'] is True: init_logging_syslog(log_level, facility=conf['log']['syslog_facility']) run_long_running_ffwd(conf) elif args.command == 'prepare-db': init_logging_stderr(log_level) prepare_databases_for_metrics(conf)