X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-backuppg;h=e8a859237f019a61126920b8b8371ca30b0df4d4;hb=0d733525c14624e0057514af37421552e244d0a1;hp=78b3380890b3544d7a36c5dc19545748f34fcd51;hpb=f42ae38244c1cc817c893b1138cf35f540b19265;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-backuppg b/dsa-nagios-checks/checks/dsa-check-backuppg index 78b3380..e8a8592 100755 --- a/dsa-nagios-checks/checks/dsa-check-backuppg +++ b/dsa-nagios-checks/checks/dsa-check-backuppg @@ -51,6 +51,7 @@ import errno import sys import yaml import optparse +import socket def load_conf(cf): if cf is not None: @@ -97,11 +98,14 @@ def note_warning_db(host, db, key, value): problems_per_db[host][db] = True -def wal_pre(w): +def wal_pre(w, host, db): (w1,w2) = w if w2 == 0: w1 -= 1 - w2 = 0xFE + if (host,db) in ( ('moszumanska', 'main'), ): + w2 = 0xFE + else: + w2 = 0xFF else: w2 -= 1 @@ -191,7 +195,7 @@ for dir in os.listdir('.'): continue (db, type) = r.groups(1) - if not isinstance(config['backups'][dir], list) or not db in config['backups'][dir]: + if not isinstance(config['backups'][dir], dict) or not db in config['backups'][dir]: if not db in ignored_dbs: note_warning_db(dir, db, 'NOT-CONFIGURED', '%s/%s'%(dir, db)) ignored_dbs[db] = True @@ -207,6 +211,10 @@ for dir in os.listdir('.'): # can_expire_next: Can expire all files that we handle from now on backup_state[db]['can_expire_next'] = False backup_state[db]['expires'] = [] + if isinstance(config['backups'][dir][db], dict) and 'timeline' in config['backups'][dir][db]: + backup_state[db]['timeline'] = config['backups'][dir][db]['timeline'] + else: + backup_state[db]['timeline'] = 1 # Apparently we already have seen a base backup and all its wal files # which we want to keep, so everything what we see now is older than @@ -231,8 +239,13 @@ for dir in os.listdir('.'): 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 + m = re.match('([a-z0-9.]+)-\d{8}-\d{6}', info['label']) + if m and (m.group(1) != socket.getfqdn()): + note_info(dir, 'IGNORED-OTHER-BASE: '+basefn) + continue + else: + 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) @@ -264,8 +277,8 @@ for dir in os.listdir('.'): backup_state[db]['can_expire_next'] = True (timeline, wal1, wal2) = map(lambda x: int(x,16), r.groups()) - if not timeline == 1: - note_warning_db(dir, db, 'CANNOT-HANDLE-TIMELINES_NOT_1', ffn) + if not timeline == backup_state[db]['timeline']: + note_warning_db(dir, db, 'UNEXPECTED-TIMELINE', ffn) continue thissegment = (wal1, wal2) @@ -273,7 +286,7 @@ for dir in os.listdir('.'): backup_state[db]['newest-wal'] = thissegment backup_state[db]['newest-wal-file'] = ffn else: - if not wal_pre(backup_state[db]['oldest-wal']) == thissegment: + if not wal_pre(backup_state[db]['oldest-wal'], dir, db) == thissegment: note_warning_db(dir, db, 'WAL-MISSING-AFTER', ffn) ignored_dbs[db] = True continue