X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-backuppg;h=07843485ab6d4596b74dc0fd67948f7486fb1c1e;hb=0a9fa50e3c10095461a88fa2197bf0791451b5ee;hp=ca6c15962ea5206da4a4807e53520974b36cfcca;hpb=b42329e3953d7f63627445081b2716b8949d2b6a;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-backuppg b/dsa-nagios-checks/checks/dsa-check-backuppg index ca6c159..0784348 100755 --- a/dsa-nagios-checks/checks/dsa-check-backuppg +++ b/dsa-nagios-checks/checks/dsa-check-backuppg @@ -102,10 +102,7 @@ def wal_pre(w, host, db): (w1,w2) = w if w2 == 0: w1 -= 1 - if (host,db) in ( ('moszumanska', 'main'), ): - w2 = 0xFE - else: - w2 = 0xFF + w2 = 0xFF else: w2 -= 1 @@ -120,6 +117,25 @@ def parse_pg_backup_info(fn): f.close() return i +def get_retention(config, host, db): + assert('retention' in config) + + assert('backups' in config) + assert(isinstance(config['backups'], dict)) + + assert(host in config['backups']) + assert(isinstance(config['backups'][host], dict)) + + assert(db in config['backups'][host]) + if isinstance(config['backups'][host][db], dict) and 'retention' in config['backups'][host][db]: + r = config['backups'][host][db]['retention'] + elif '_retention' in config['backups'][host]: + r = config['backups'][host]['_retention'] + else: + r = config['retention'] + + assert(isinstance(r, int)) + return r parser = optparse.OptionParser() parser.set_usage("%prog [-c=] (nagios mode)\n" + @@ -143,7 +159,7 @@ config = load_conf(options.conffile) os.chdir(config['rootdir']) for dir in os.listdir('.'): - if dir.startswith('.') or dir.endswith('.old'): + if dir.startswith('.') or dir.endswith('.old') or dir == 'lost+found': note_info('IGNORED', dir) continue @@ -264,7 +280,7 @@ for dir in os.listdir('.'): backup_state[db]['base_needs_wal_until'] = walbase start = time.mktime(time.strptime(info['start time'], '%Y-%m-%d %H:%M:%S %Z')) - if start + config['retention'] < time.time(): + if start + get_retention(config, dir, db) < time.time(): backup_state[db]['can_expire_for_base_hit'] = True continue @@ -329,6 +345,7 @@ for dir in os.listdir('.'): global_expires.append(f) for db in notyetseen_dbs: + if db.startswith('_'): continue note_warning_db(dir, db, 'NO-BACKUP', 'no backups! (no .backup files found)') #if not db in backup_state: @@ -345,8 +362,9 @@ for dir in os.listdir('.'): for p in problems_seq: print p -for p in notices_seq: - print p +if options.verbose: + for p in notices_seq: + print p if options.expire: for f in global_expires: