better printout, performace data

This commit is contained in:
Matěj Divecký 2020-04-19 17:19:03 +02:00
parent ee9a010178
commit 55171cdda4

View file

@ -19,12 +19,15 @@ with open(BORG_STATUS_FILE) as json_file:
last_backup = borg_data[0]['archives'][0]['time'] last_backup = borg_data[0]['archives'][0]['time']
since_last_backup = datetime.now() - parser.parse(last_backup) 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: 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) sys.exit(CRITICAL)
elif timedelta(hours=30) < since_last_backup: 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) sys.exit(WARNING)
else: else:
print('OK - ' + str(since_last_backup) + ' sice last backup') print('OK - ' + str(hours) + ' hours sice last backup |hours=' + str(hours))
sys.exit(OK) sys.exit(OK)