bundles/backup-client: add monitoring for backups
This commit is contained in:
parent
ed325848ab
commit
48fc341137
3 changed files with 45 additions and 0 deletions
33
bundles/backup-client/files/check_backup_last_run
Normal file
33
bundles/backup-client/files/check_backup_last_run
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from os.path import getmtime, isfile
|
||||
from sys import exit
|
||||
from time import time
|
||||
|
||||
statusfile = '/var/tmp/backup.monitoring'
|
||||
if not isfile(statusfile):
|
||||
print('Status file not found')
|
||||
exit(3)
|
||||
|
||||
mtime = getmtime(statusfile)
|
||||
now = time()
|
||||
|
||||
if now-mtime > 60*60*24*2:
|
||||
print('Status file is older than 2 days!')
|
||||
exit(3)
|
||||
|
||||
with open(statusfile, 'r') as f:
|
||||
status = f.read().split()
|
||||
|
||||
if status[0] == 'ok':
|
||||
print('OK')
|
||||
exit(0)
|
||||
elif status[0] == 'rsync_error':
|
||||
print('rsync produced some errors, exit codes were: {}'.format(
|
||||
', '.join(status[1:])
|
||||
))
|
||||
exit(2)
|
||||
else:
|
||||
# garbage in file
|
||||
print(' '.join(status))
|
||||
exit(3)
|
Loading…
Add table
Add a link
Reference in a new issue