diff --git a/check_borg_backup.py b/check_borg_backup.py index 5c5c4e7..f7f82fa 100755 --- a/check_borg_backup.py +++ b/check_borg_backup.py @@ -19,12 +19,15 @@ with open(BORG_STATUS_FILE) as json_file: last_backup = borg_data[0]['archives'][0]['time'] since_last_backup = datetime.now() - parser.parse(last_backup) +days, seconds = since_last_backup.days, since_last_backup.seconds +hours = days * 24 + seconds // 3600 + if timedelta(hours=48) < since_last_backup: - print('CRITICAL - ' + str(since_last_backup) + ' sice last backup') + print('CRITICAL - ' + str(hours) + ' hours sice last backup |hours=' + str(hours)) sys.exit(CRITICAL) elif timedelta(hours=30) < since_last_backup: - print('WARNING - ' + str(since_last_backup) + ' sice last backup') + print('WARNING - ' + str(hours) + ' hours sice last backup |hours=' + str(hours)) sys.exit(WARNING) else: - print('OK - ' + str(since_last_backup) + ' sice last backup') + print('OK - ' + str(hours) + ' hours sice last backup |hours=' + str(hours)) sys.exit(OK) \ No newline at end of file