RT#7513 Remove moszumanska
[mirror/dsa-nagios.git] / dsa-nagios-checks / checks / dsa-check-backuppg
index ddef856..13e935e 100755 (executable)
@@ -102,7 +102,7 @@ def wal_pre(w, host, db):
     (w1,w2) = w
     if w2 == 0:
         w1 -= 1
-        if (host,db) in ( ('moszumanska', 'main'), ):
+        if (host,db) in ( ('main'), ):
             w2 = 0xFE
         else:
             w2 = 0xFF
@@ -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=<CONFFILE>]               (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
 
@@ -329,6 +348,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: