projects
/
mirror
/
dsa-nagios.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ftc -> ftcollins
[mirror/dsa-nagios.git]
/
dsa-nagios-checks
/
checks
/
dsa-check-backuppg
diff --git
a/dsa-nagios-checks/checks/dsa-check-backuppg
b/dsa-nagios-checks/checks/dsa-check-backuppg
index
83f54ba
..
ccf9e3d
100755
(executable)
--- a/
dsa-nagios-checks/checks/dsa-check-backuppg
+++ b/
dsa-nagios-checks/checks/dsa-check-backuppg
@@
-65,6
+65,7
@@
def load_conf(cf):
return config
return config
+notices_seq = []
problems_seq = []
problems_per_db = {}
global_expires = []
problems_seq = []
problems_per_db = {}
global_expires = []
@@
-75,6
+76,12
@@
global_expires = []
# global problems_per_db
# if not host in problems_per_db: problems_per_db[host] = {}
# problems_per_db[host][db] = True
# global problems_per_db
# if not host in problems_per_db: problems_per_db[host] = {}
# problems_per_db[host][db] = True
+def note_info(key, value, pre=None):
+ global notices_seq
+ if pre is None:
+ notices_seq.append("%s: %s"%(key, value))
+ else:
+ notices_seq.append("[%s] %s: %s"%(pre, key, value))
def note_warning(key, value, pre=None):
global problems_seq
def note_warning(key, value, pre=None):
global problems_seq
@@
-132,7
+139,10
@@
config = load_conf(options.conffile)
os.chdir(config['rootdir'])
for dir in os.listdir('.'):
if not os.path.isdir(dir):
os.chdir(config['rootdir'])
for dir in os.listdir('.'):
if not os.path.isdir(dir):
- note_warning('NOT-A-DIR', dir)
+ if min(os.path.getmtime(dir), os.path.getctime(dir)) + 3600*4 > time.time():
+ note_info('IGNORED', dir)
+ else:
+ note_warning('NOT-A-DIR', dir)
continue
if not dir in config['backups']:
continue
if not dir in config['backups']:
@@
-266,18
+276,18
@@
for dir in os.listdir('.'):
for db in backup_state:
if not 'newest-base' in backup_state[db]:
for db in backup_state:
if not 'newest-base' in backup_state[db]:
- note_warning(dir, db, 'NO-BASE', 'no base backup found?')
+ note_warning
_db
(dir, db, 'NO-BASE', 'no base backup found?')
else:
age = time.time() - os.stat(backup_state[db]['newest-base']).st_mtime
if age > config['warn-age']['base']:
else:
age = time.time() - os.stat(backup_state[db]['newest-base']).st_mtime
if age > config['warn-age']['base']:
- note_warning(dir, db, 'BASE-IS-OLD', 'latest base backup is too old')
+ note_warning
_db
(dir, db, 'BASE-IS-OLD', 'latest base backup is too old')
if not 'newest-wal-file' in backup_state[db]:
if not 'newest-wal-file' in backup_state[db]:
- note_warning(dir, db, 'NO-BASE', 'no WAL files found?')
+ note_warning
_db
(dir, db, 'NO-BASE', 'no WAL files found?')
else:
age = time.time() - os.stat(backup_state[db]['newest-wal-file']).st_mtime
if age > config['warn-age']['wal']:
else:
age = time.time() - os.stat(backup_state[db]['newest-wal-file']).st_mtime
if age > config['warn-age']['wal']:
- note_warning(dir, db, 'WAL-IS-OLD', 'latest wal file is too old')
+ note_warning
_db
(dir, db, 'WAL-IS-OLD', 'latest wal file is too old')
for db in backup_state:
if len(backup_state[db]['expires']) > 0:
for db in backup_state:
if len(backup_state[db]['expires']) > 0:
@@
-302,6
+312,8
@@
for dir in os.listdir('.'):
for p in problems_seq:
print p
for p in problems_seq:
print p
+for p in notices_seq:
+ print p
if options.expire:
for f in global_expires:
if options.expire:
for f in global_expires:
@@
-311,7
+323,8
@@
if options.expire:
if len(problems_seq) > 0:
sys.exit(1)
if len(problems_seq) > 0:
sys.exit(1)
-print "OK: no problems detected"
+if not options.expire or options.verbose:
+ print "OK: no problems detected"
sys.exit(0)
# vim:set et:
sys.exit(0)
# vim:set et: