def _configure(self): self._update_config() self.validate_config() helper.configure_log( log_level=helper.log_level_map[self.args['--verbosity']], log_file=self.config['log_file'], log_size=self.config['log_size'])
def configure(args, config): global CONFIG if 'instances_connection_policy' in config: CONFIG['instances_connection_policy'] = config[ 'instances_connection_policy'] if 'system' in config and 'instances_connection_timeout' in config[ 'system']: CONFIG['instances_connection_timeout'] = config['system'][ 'instances_connection_timeout'] if 'stats_poller' not in config: raise Exception("Can't find 'stats_poller' section in %s" % args.config_file) for k, v in config['stats_poller'].iteritems(): CONFIG.update({k: v}) for k, v in vars(args).iteritems(): if v is not None: CONFIG.update({k: v}) log_size = 1024 * 500 if CONFIG['verbosity'] < 2 else 1024 * 10000 helper.configure_log(log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=log_size)
def configure(config, args=None): enabled = config.get('analytics', {}).get('enabled', False) if not enabled: sys.stdout.write('Analytics is disabled\n') sys.exit(0) global CONFIG helper.update_config( config.get('connections', {}).get('mysql', {}), CONFIG['connections']['scalr']) helper.update_config( config.get('analytics', {}).get('connections', {}).get('scalr', {}), CONFIG['connections']['scalr']) helper.update_config( config.get('analytics', {}).get('connections', {}).get('analytics', {}), CONFIG['connections']['analytics']) helper.update_config( config.get('analytics', {}).get('poller', {}), CONFIG) helper.update_config(config_to=CONFIG, args=args) CONFIG['pool_size'] = max(11, CONFIG['pool_size']) helper.validate_config(CONFIG) helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024 * 1000 ) socket.setdefaulttimeout(CONFIG['cloud_connection_timeout']) crypto_key_path = os.path.join(os.path.dirname(os.path.abspath(args.config_file)), '.cryptokey') global CRYPTO_KEY CRYPTO_KEY = cryptotool.read_key(crypto_key_path) global SCALR_DB SCALR_DB = dbmanager.ScalrDB(CONFIG['connections']['scalr']) global ANALYTICS_DB ANALYTICS_DB = dbmanager.ScalrDB(CONFIG['connections']['analytics'])
def configure(config, args=None): global CONFIG if 'connections' in config and 'mysql' in config['connections']: helper.update_config(config['connections']['mysql'], CONFIG['connections']['mysql']) try: CONFIG['rrd']['dir'] = config['stats_poller']['rrd_db_dir'] except: pass try: helper.update_config( config['stats_poller']['connections']['mysql'], CONFIG['connections']['mysql'] ) except: pass try: CONFIG['rrd']['dir'] = config['load_statistics']['rrd']['dir'] except: pass try: helper.update_config( config['load_statistics']['connections']['mysql'], CONFIG['connections']['mysql'] ) except: pass if 'stats_cleaner' in config: helper.update_config(config['stats_cleaner'], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024 * 1000 )
def configure(config, args=None): enabled = config.get("analytics", {}).get("enabled", False) if not enabled: sys.stdout.write("Analytics is disabled\n") sys.exit(0) global CONFIG helper.update_config(config.get("connections", {}).get("mysql", {}), CONFIG["connections"]["mysql"]["scalr"]) helper.update_config( config.get("analytics", {}).get("connections", {}).get("scalr", {}), CONFIG["connections"]["mysql"]["scalr"] ) helper.update_config( config.get("analytics", {}).get("connections", {}).get("analytics", {}), CONFIG["connections"]["mysql"]["analytics"], ) helper.update_config(config.get("analytics", {}).get("processing", {}), CONFIG) helper.update_config(config_to=CONFIG, args=args) CONFIG["pool_size"] = max(21, CONFIG["pool_size"]) helper.validate_config(CONFIG) if CONFIG["recalculate"] and (not CONFIG["platform"] or not CONFIG["date_from"]): sys.stderr.write("Error. You must specify 'platform' and 'date-from' for recalculating\n") sys.exit(1) helper.configure_log(log_level=CONFIG["verbosity"], log_file=CONFIG["log_file"], log_size=1024 * 10000) global POOL POOL = Pool() global SCALR_DB SCALR_DB = dbmanager.ScalrDB(CONFIG["connections"]["mysql"]["scalr"]) global ANALYTICS_DB ANALYTICS_DB = dbmanager.DB(CONFIG["connections"]["mysql"]["analytics"])
def configure(args, cnf): global config for k, v in cnf.iteritems(): config.update({k: v}) for k, v in vars(args).iteritems(): if v is not None: config.update({k: v}) helper.configure_log(__file__, log_level=config["verbosity"], log_file=config["log_file"], log_size=1024 * 500)
def configure(config, args=None): global CONFIG helper.update_config(config['connections']['mysql'], CONFIG['connections']['mysql']) if 'msg_sender_alert' in config: helper.update_config(config['msg_sender_alert'], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log(log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024 * 1000)
def configure(config, args=None): global CONFIG helper.update_config(config['connections']['mysql'], CONFIG['connections']['mysql']) if 'dbqueue_event_alert' in config: helper.update_config(config['dbqueue_event_alert'], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024*1000 )
def configure(args, cnf): global config for k, v in cnf.iteritems(): config.update({k:v}) for k, v in vars(args).iteritems(): if v is not None: config.update({k:v}) helper.configure_log(__file__, log_level=config['verbosity'], log_file=config['log_file'], log_size=1024*100)
def configure(config, args=None): global CONFIG helper.update_config(config["connections"]["mysql"], CONFIG["connections"]["mysql"]) if "email" in config: helper.update_config(config["email"], CONFIG["email"]) if "system" in config and "instances_connection_timeout" in config["system"]: timeout = config["system"]["instances_connection_timeout"] CONFIG["instances_connection_timeout"] = timeout if "dbqueue_event" in config: helper.update_config(config["dbqueue_event"], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log(log_level=CONFIG["verbosity"], log_file=CONFIG["log_file"], log_size=1024 * 1000)
def configure(args=None): global CONFIG, SCALR_CONFIG helper.update_config( SCALR_CONFIG.get('connections', {}).get('mysql', {}), CONFIG['connections']['mysql']) helper.update_config(SCALR_CONFIG.get('msg_sender', {}), CONFIG) inst_conn_timeout = SCALR_CONFIG.get('system', {}).get('instances_connection_timeout', None) if inst_conn_timeout: CONFIG['instances_connection_timeout'] = inst_conn_timeout helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024 * 1000) socket.setdefaulttimeout(CONFIG['instances_connection_timeout'])
def __init__(self, config, args=None): for k, v in config.iteritems(): if k not in self.config: self.config[k] = v self.args = args or argparse.Namespace() self.configure() helper.update_config(config_to=self.config, args=args) helper.validate_config(self.config) helper.configure_log( log_level=self.config['verbosity'], log_file=self.config['log_file'], log_size=self.config['log_size']) super(Application, self).__init__(self.config['pid_file'])
def configure(config, args=None): global CONFIG helper.update_config(config['connections']['mysql'], CONFIG['connections']['mysql']) if 'stats_poller' in config: CONFIG['rrd_db_dir'] = config['stats_poller']['rrd_db_dir'] if 'connections' in config['stats_poller']: helper.update_config( config['stats_poller']['connections']['mysql'], CONFIG['connections']['mysql']) if 'stats_cleaner' in config: helper.update_config(config['stats_cleaner'], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log(log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024 * 1000)
def configure(config, args=None): global CONFIG helper.update_config(config['connections']['mysql'], CONFIG['connections']['mysql']) if 'email' in config: helper.update_config(config['email'], CONFIG['email']) if 'system' in config and 'instances_connection_timeout' in config[ 'system']: timeout = config['system']['instances_connection_timeout'] CONFIG['instances_connection_timeout'] = timeout if 'dbqueue_event' in config: helper.update_config(config['dbqueue_event'], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log(log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024 * 1000)
def configure(config, args=None): global CONFIG helper.update_config(config['connections']['mysql'], CONFIG['connections']['mysql']) if 'system' in config and 'instances_connection_timeout' in config['system']: timeout = config['system']['instances_connection_timeout'] CONFIG['instances_connection_timeout'] = timeout if 'instances_connection_policy' in config: CONFIG['instances_connection_policy'] = config['instances_connection_policy'] if 'msg_sender' in config: helper.update_config(config['msg_sender'], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024*1000 )
def configure(config, args=None): global CONFIG if 'connections' in config and 'mysql' in config['connections']: helper.update_config(config['connections']['mysql'], CONFIG['connections']['mysql']) if 'system' in config and 'instances_connection_timeout' in config['system']: timeout = config['system']['instances_connection_timeout'] CONFIG['instances_connection_timeout'] = timeout if 'dbqueue_event' in config: helper.update_config(config['dbqueue_event'], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024 * 1000 ) socket.setdefaulttimeout(CONFIG['instances_connection_timeout'])
def configure(config, args=None): global CONFIG helper.update_config(config['connections']['mysql'], CONFIG['connections']['mysql']) if 'stats_poller' in config: CONFIG['rrd_db_dir'] = config['stats_poller']['rrd_db_dir'] if 'connections' in config['stats_poller']: helper.update_config( config['stats_poller']['connections']['mysql'], CONFIG['connections']['mysql'] ) if 'stats_cleaner' in config: helper.update_config(config['stats_cleaner'], CONFIG) helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024*1000 )
def configure(args, config): global CONFIG if 'instances_connection_policy' in config: CONFIG['instances_connection_policy'] = config['instances_connection_policy'] if 'system' in config and 'instances_connection_timeout' in config['system']: CONFIG['instances_connection_timeout'] = config['system']['instances_connection_timeout'] if 'stats_poller' not in config: raise Exception("Can't find 'stats_poller' section in %s" % args.config_file) for k, v in config['stats_poller'].iteritems(): CONFIG.update({k:v}) for k, v in vars(args).iteritems(): if v is not None: CONFIG.update({k:v}) log_size = 1024*500 if CONFIG['verbosity'] < 2 else 1024*10000 helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=log_size )
def configure(args=None): global CONFIG, SCALR_CONFIG helper.update_config( SCALR_CONFIG.get('connections', {}).get('mysql', {}), CONFIG['connections']['mysql']) helper.update_config(SCALR_CONFIG.get('load_statistics', {}), CONFIG) inst_conn_timeout = SCALR_CONFIG.get('system', {}).get('instances_connection_timeout', None) if inst_conn_timeout: CONFIG['instances_connection_timeout'] = inst_conn_timeout helper.update_config(config_to=CONFIG, args=args) helper.validate_config(CONFIG) helper.configure_log( log_level=CONFIG['verbosity'], log_file=CONFIG['log_file'], log_size=1024 * 1000) socket.setdefaulttimeout(CONFIG['instances_connection_timeout']) if CONFIG['connections']['plotter']['scheme'] == 'https': try: import OpenSSL except ImportError: msg = "Configure failed, https is not supported, reason: PyOpenSSL is not installed" raise Exception(msg) if not os.path.exists(os.path.dirname(CONFIG['rrd']['rrdcached_sock_path'])): os.makedirs(os.path.dirname(CONFIG['rrd']['rrdcached_sock_path']), 0755) rrd.RRDCACHED_SOCK_FILE = CONFIG['rrd']['rrdcached_sock_path']
def configure_log(self): helper.configure_log( log_level=helper.log_level_map[self.args['--verbosity']], log_file=self.config['log_file'], log_size=self.config['log_size'])