Module: check_mk
Branch: master
Commit: 7943989ce12bfcf85736ede9cb1fb22a1d13d18e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7943989ce12bfc…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Mon Jun 26 15:28:42 2017 +0200
4825 FIX mkbackup: Fixed crash if size of backup is not reported because of a failure
Previously the check crashed if the size has not been reported. This can
happen if the backup fails directly from the beginning. This bug has always
been in this plugin until now.
Change-Id: I8e425d12aa99aa0e7edff9b299f15c7c07a033ff
---
.werks/4825 | 12 ++++++++++++
checks/mkbackup | 5 +++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/.werks/4825 b/.werks/4825
new file mode 100644
index 0000000..1166ad6
--- /dev/null
+++ b/.werks/4825
@@ -0,0 +1,12 @@
+Title: mkbackup: Fixed crash if size of backup is not reported because of a failure
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1498483587
+Class: fix
+
+Previously the check crashed if the size has not been reported. This can
+happen if the backup fails directly from the beginning. This bug has always
+been in this plugin until now.
diff --git a/checks/mkbackup b/checks/mkbackup
index 8eed86a..2ff4449 100644
--- a/checks/mkbackup
+++ b/checks/mkbackup
@@ -106,8 +106,9 @@ def check_mkbackup(job_state):
[ ("backup_duration", duration),
("backup_avgspeed", job_state["bytes_per_second"]) ]
- yield 0, "Size: %s" %
get_bytes_human_readable(job_state["size"]), \
- [ ("backup_size", job_state["size"]) ]
+ if "size" in job_state:
+ yield 0, "Size: %s" %
get_bytes_human_readable(job_state["size"]), \
+ [ ("backup_size", job_state["size"]) ]
next_run = job_state["next_schedule"]
if next_run == "disabled":