예제 #1
0
    def ajax_index(self):
        c = sqlite3.connect(self.db_path).cursor()

        hubs_list = get_tunnel_connections(self.config['tunnel_info'])
        oldest_cache = arrow.utcnow()

        hubs = []
        for hub_id in sorted(hubs_list):
            c.execute('SELECT * FROM Cache WHERE hub_id=?', [hub_id])
            for hub_id, hub_health, summary, cache_time in c.fetchall():
                cache_time = arrow.get(cache_time, 'YYYY-MM-DD HH:mm:ss')
                oldest_cache = min(cache_time, oldest_cache)

                hub_health = {
                    'RED': nexus.RED,
                    'YELLOW': nexus.YELLOW,
                    'GREEN': nexus.GREEN,
                    'FAIL': nexus.RED
                }[hub_health]

                hubs.append((hub_id, hub_health, summary))

        return render_template('ajax_index.html',
                               hubs=hubs,
                               oldest_cache=oldest_cache,
                               nexus=nexus)
예제 #2
0
    def ajax_index(self):
        c = sqlite3.connect(self.db_path).cursor()

        hubs_list = get_tunnel_connections(self.config["tunnel_info"])
        oldest_cache = arrow.utcnow()

        hubs = []
        for hub_id in sorted(hubs_list):
            c.execute("SELECT * FROM Cache WHERE hub_id=?", [hub_id])
            for hub_id, hub_health, summary, cache_time in c.fetchall():
                cache_time = arrow.get(cache_time, "YYYY-MM-DD HH:mm:ss")
                oldest_cache = min(cache_time, oldest_cache)

                hub_health = {"RED": nexus.RED, "YELLOW": nexus.YELLOW, "GREEN": nexus.GREEN, "FAIL": nexus.RED}[
                    hub_health
                ]

                hubs.append((hub_id, hub_health, summary))

        return render_template("ajax_index.html", hubs=hubs, oldest_cache=oldest_cache, nexus=nexus)
예제 #3
0
    def ajax_all(self):
        self.nexus_init()

        hubs_list = get_tunnel_connections(self.config["tunnel_info"])

        results = []
        for hub_id in hubs_list:
            app.logger.info(hub_id)

            data = fetch_data(hub_id, self.config)
            res = assess_data(data, self.config)

            if res.error:
                color = nexus.RED
            elif res.hub_health != nexus.GREEN:
                color = nexus.YELLOW
            else:
                color = nexus.GREEN

            results.append((res.hub_id, color, res.error or res.summary))

        return render_template("ajax_search.html", results=results, nexus=nexus)
예제 #4
0
    def ajax_all(self):
        self.nexus_init()

        hubs_list = get_tunnel_connections(self.config['tunnel_info'])

        results = []
        for hub_id in hubs_list:
            app.logger.info(hub_id)

            data = fetch_data(hub_id, self.config)
            res = assess_data(data, self.config)

            if res.error:
                color = nexus.RED
            elif res.hub_health != nexus.GREEN:
                color = nexus.YELLOW
            else:
                color = nexus.GREEN

            results.append((res.hub_id, color, res.error or res.summary))

        return render_template('ajax_search.html',
                               results=results,
                               nexus=nexus)
예제 #5
0
DIR = os.path.dirname(os.path.realpath(__file__))

with open(os.path.join(DIR, 'config.json')) as f:
    config = json.load(f)

for _ in range(5):
    try:
        init(config)
    except paramiko.SSHException:
        continue
    break
else:
    exit(1)

hubs_list = get_tunnel_connections(config['tunnel_info'])

results = []
for hub_id in hubs_list:
    data = fetch_data(hub_id, config)
    res = assess_data(data, config)

    if res.error:
        color = 'RED'
    elif res.hub_health != GREEN:
        color = 'YELLOW'
    else:
        color = 'GREEN'

    print('[{}] {}... {}'.format(color, res.hub_id, res.error or res.summary))