mirror of
https://github.com/netinvent/npbackup.git
synced 2025-02-24 22:44:04 +08:00
Make minimum_backup_size_error unit aware
This commit is contained in:
parent
fa7fc8f69b
commit
8387ebc354
2 changed files with 3 additions and 3 deletions
|
@ -164,7 +164,7 @@ empty_config_dict = {
|
|||
"exclude_files_larger_than": None,
|
||||
"additional_parameters": None,
|
||||
"additional_backup_only_parameters": None,
|
||||
"minimum_backup_size_error": "10", # In megabytes
|
||||
"minimum_backup_size_error": "10MiB", # allows BytesConverter units
|
||||
"pre_exec_commands": [],
|
||||
"pre_exec_per_command_timeout": 3600,
|
||||
"pre_exec_failure_is_fatal": False,
|
||||
|
|
|
@ -168,7 +168,7 @@ def restic_str_output_to_json(
|
|||
|
||||
|
||||
def restic_json_to_prometheus(
|
||||
restic_result: bool, restic_json: dict, labels: dict = None, minimum_backup_size_error: float = None,
|
||||
restic_result: bool, restic_json: dict, labels: dict = None, minimum_backup_size_error: str = None,
|
||||
) -> Tuple[bool, List[str], bool]:
|
||||
"""
|
||||
Transform a restic JSON result into prometheus metrics
|
||||
|
@ -225,7 +225,7 @@ def restic_json_to_prometheus(
|
|||
|
||||
backup_too_small = False
|
||||
if minimum_backup_size_error:
|
||||
if restic_json["data_added"] < minimum_backup_size_error:
|
||||
if restic_json["data_added"] < int(BytesConverter(str(minimum_backup_size_error).replace(" ", ""))):
|
||||
backup_too_small = True
|
||||
good_backup = restic_result and not backup_too_small
|
||||
|
||||
|
|
Loading…
Reference in a new issue