Example #1
0
def reset_db_daily():
    # Clean the whole database and regenerate it (like this we do not
    # keep data of the old rankings)
    report = ReportsGenerator()
    report.flush_temp_db()
    report.build_reports_lasts_days(days_history_cache)

    # date used to generate a ranking with the data in the database at
    # this point
    date = (datetime.date.today() - datetime.timedelta(1)).isoformat()
    return date
Example #2
0
    def __init__(self):
        self.config = ConfigParser.RawConfigParser()
        config_file = "/path/to/bgp-ranking.conf"
        self.config.read(config_file)
        root_dir =  self.config.get('directories','root')
        sys.path.append(os.path.join(root_dir,self.config.get('directories','libraries')))
        from ranking.reports import Reports
        from ranking.reports_generator import ReportsGenerator

        # Ensure there is something to display
        report_generator = ReportsGenerator()
        report_generator.flush_temp_db()
        report_generator.build_reports_lasts_days(int(self.config.get('ranking','days')))
        report_generator.build_last_reports()

        self.report = Reports()
        self.days_graph = 30
Example #3
0
            while routing_db.dbsize() > 0:
                time.sleep(sleep_timer)
            if not os.path.exists(filename) or history_db.exists(key_to_rank):
                # wait for a new file
                time.sleep(bview_check_interval)
                continue

            prepare_bview_file()
            amount_asns = routing_db.scard('asns')

            if compute_yesterday_ranking():
                date = reset_db_daily()
            else:
                date = datetime.date.today().isoformat()

            prepare_keys_for_ranking()

            service_start_multiple(ranking_process_service, rank_procs)

            while history_db.scard(key_to_rank) > 0:
                # wait for a new file
                time.sleep(sleep_timer)
            rmpid(ranking_process_service)
            # Save the number of asns known by the RIPE
            history_db_static.set('{date}|amount_asns'.format(date=date),
                                  amount_asns)
            routing_db.flushdb()
            publisher.info('Updating the reports...')
            ReportsGenerator().build_reports(date)
            publisher.info('...done.')