From: Peter Palfrader Date: Tue, 14 Nov 2017 09:30:20 +0000 (+0100) Subject: dsa-check-backuppg: Support per host and per cluster retention times X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-nagios.git;a=commitdiff_plain;h=7a3a31cd0f0e17e803f2a24d71395dced8b6dbe6 dsa-check-backuppg: Support per host and per cluster retention times --- diff --git a/dsa-nagios-checks/checks/dsa-check-backuppg b/dsa-nagios-checks/checks/dsa-check-backuppg index ddef856..b12479b 100755 --- a/dsa-nagios-checks/checks/dsa-check-backuppg +++ b/dsa-nagios-checks/checks/dsa-check-backuppg @@ -120,6 +120,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" + @@ -264,7 +283,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 diff --git a/dsa-nagios-checks/debian/changelog b/dsa-nagios-checks/debian/changelog index c7c3861..bd22f5f 100644 --- a/dsa-nagios-checks/debian/changelog +++ b/dsa-nagios-checks/debian/changelog @@ -7,6 +7,8 @@ dsa-nagios-checks (111) UNRELEASED; urgency=medium * dsa-update-unowned-file-status: ignore autofs and nfs4 * dsa-check-backuppg: Do not print info level items (IGNORED, etc.) without -v. + * dsa-check-backuppg: Support per host and per cluster retention + times. [ Julien Cristau ] * Set LWP::UserAgent timeout in dsa-check-mirrorsync