Example #1
0
def set_log_state_to_end_of_file():
    """Useful to reset the state of a logfile to the end, to pick up only new errors"""
    set_config()
    logpath = _config['GEOSERVER_LOG']
    logfile_model = get_logfile_model(logpath)
    with open(logpath) as fileobj:
        fileobj.seek(0, 2)
        end = fileobj.tell()
    new_checksum = checksum('', end, end)
    logfile_model.checksum = new_checksum
    logfile_model.offset_start = end
    logfile_model.offset_end = end
    logfile_model.save()
Example #2
0
def set_log_state_to_end_of_file():
    """Useful to reset the state of a logfile to the end, to pick up only new errors"""
    set_config()
    logpath = _config['GEOSERVER_LOG']
    logfile_model = get_logfile_model(logpath)
    with open(logpath) as fileobj:
        fileobj.seek(0, 2)
        end = fileobj.tell()
    new_checksum = checksum('', end, end)
    logfile_model.checksum = new_checksum
    logfile_model.offset_start = end
    logfile_model.offset_end = end
    logfile_model.save()
Example #3
0
    def handle(self, *args, **opts):
        if not args:
            print ('need one or more suites to run, or "mark_log_ok", '
                   '"list", or "clean_runs <days>"')
            sys.exit(1)

        set_config()
        for k in _config:
            envkey = 'WATCHDOG_%s' % k
            if envkey in os.environ:
                _config[k] = os.environ[envkey]

        if args[0] == 'mark_log_ok':
            set_log_state_to_end_of_file()
        elif args[0] == 'list':
            list_suites()
        elif args[0] == 'clean_runs':
            ndays = 14
            if len(args) > 1:
                try:
                    ndays = int(args[1])
                except ValueError:
                    pass
            clean_runs(ndays)
        elif args[0] == 'summarize':
            usage = "must specify 'day' or 'week' to summarize"
            if len(args) == 1:
                print usage
                return
            else:
                period = args[1]
                if period not in ('day', 'week'):
                    print usage
                    return
                days = 1
                if period == 'day':
                    days = 1
                elif period == 'week':
                    days = 7
                now = datetime.now()
                delta = timedelta(days=days)
                plain_day = datetime(now.year, now.month, now.day)
                start_time = plain_day - delta
                end_time = plain_day
                summarize(start_time, end_time)
        elif args[0] == 'log_scan':
            log_scan()
        else:
            _run_watchdog_suites(*args)