X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-backuppg;h=78b3380890b3544d7a36c5dc19545748f34fcd51;hb=4dd94be5ec29b8e4eab807fd6de7552a764cfbf7;hp=b7b05c89aa6a8c56b9eae7274fe631cc6bfeec3e;hpb=e99ccb7e98436663093e52075ef69506b5853606;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-backuppg b/dsa-nagios-checks/checks/dsa-check-backuppg index b7b05c8..78b3380 100755 --- a/dsa-nagios-checks/checks/dsa-check-backuppg +++ b/dsa-nagios-checks/checks/dsa-check-backuppg @@ -47,6 +47,7 @@ import copy import time import re import os +import errno import sys import yaml import optparse @@ -138,12 +139,20 @@ config = load_conf(options.conffile) os.chdir(config['rootdir']) for dir in os.listdir('.'): - if dir.startswith('.'): + if dir.startswith('.') or dir.endswith('.old'): note_info('IGNORED', dir) continue if not os.path.isdir(dir): - if min(os.path.getmtime(dir), os.path.getctime(dir)) + 3600*4 > time.time(): + try: + mtime = os.path.getmtime(dir) + ctime = os.path.getctime(dir) + except OSError as e: + if e.errno == errno.ENOENT: + continue + else: + raise e + if min(mtime, ctime) + 3600*4 > time.time(): note_info('IGNORED', dir) else: note_warning('NOT-A-DIR', dir) @@ -219,8 +228,11 @@ for dir in os.listdir('.'): basefn = '%s.BASE.%s-%s.tar.gz'%(db, info['label'], info['start wal location'].split(' ',2)[0].replace('/', '_')) baseffn = os.path.join(dir, basefn) if not basefn in files: - note_warning_db(dir, db, 'MISSING-BASE', basefn) - continue + basefn = '%s.BASE.%s.tar.gz'%(db, info['label']) + baseffn = os.path.join(dir, basefn) + if not basefn in files: + note_warning_db(dir, db, 'MISSING-BASE', basefn) + continue files.remove(basefn) if backup_state[db]['can_expire_next']: backup_state[db]['expires'].append(baseffn)