def aconf(app): configs = glob.glob("%s-*" % app.config_dir_prefix) # # Test crap # configs.append("%s-87-envoy.json" % app.config_dir_prefix) if configs: keyfunc = lambda x: x.split("-")[-1] key_match = lambda x: re.match('^\d+$', keyfunc(x)) key_as_int = lambda x: int(keyfunc(x)) configs = sorted(filter(key_match, configs), key=key_as_int) latest = configs[-1] else: latest = app.config_dir_prefix aconf = Config(latest) uptime = datetime.datetime.now() - boot_time hr_uptime = td_format(uptime) result = Config.scout_report(mode="diagd", runtime=Config.runtime, uptime=int(uptime.total_seconds()), hr_uptime=hr_uptime) app.logger.info("Scout reports %s" % json.dumps(result)) return aconf
def aconf(app): configs = glob.glob("%s-*" % app.config_dir_prefix) if configs: configs.sort(key=lambda x: int(x.split("-")[-1])) latest = configs[-1] else: latest = app.config_dir_prefix aconf = Config(latest) # How long since the last Scout update? If it's been more than an hour, # check Scout again. now = datetime.datetime.now() if (now - last_scout_update) > datetime.timedelta(hours=1): uptime = now - boot_time hr_uptime = td_format(uptime) result = Config.scout_report(mode="diagd", runtime=Config.runtime, uptime=int(uptime.total_seconds()), hr_uptime=hr_uptime) app.logger.debug("Scout reports %s" % json.dumps(result)) return aconf
def aconf(app): configs = glob.glob("%s-*" % app.config_dir_prefix) # # Test crap # configs.append("%s-87-envoy.json" % app.config_dir_prefix) if configs: keyfunc = lambda x: x.split("-")[-1] key_match = lambda x: re.match('^\d+$', keyfunc(x)) key_as_int = lambda x: int(keyfunc(x)) configs = sorted(filter(key_match, configs), key=key_as_int) latest = configs[-1] else: latest = app.config_dir_prefix aconf = Config(latest) uptime = datetime.datetime.now() - boot_time hr_uptime = td_format(uptime) result = Config.scout_report(mode="diagd", runtime=Config.runtime, uptime=int(uptime.total_seconds()), hr_uptime=hr_uptime) app.logger.info("Scout reports %s" % json.dumps(result)) return aconf
def aconf(app): configs = glob.glob("%s-*" % app.config_dir_prefix) if configs: configs.sort(key=lambda x: int(x.split("-")[-1])) latest = configs[-1] else: latest = app.config_dir_prefix aconf = Config(latest) uptime = datetime.datetime.now() - boot_time hr_uptime = td_format(uptime) result = Config.scout_report(mode="diagd", runtime=Config.runtime, uptime=int(uptime.total_seconds()), hr_uptime=hr_uptime) app.logger.info("Scout reports %s" % json.dumps(result)) return aconf