Module: check_mk
Branch: master
Commit: 6944cc99bc3b34c76c91a1270ef30d6236238f1b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6944cc99bc3b34…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Wed Dec 28 15:05:35 2016 +0100
veeam_tapejobs: Now allows checking for maximum backup job runtime
Change-Id: I8d0dcbf25bc44ec60f18367fcea512e92d1db23b
---
checks/veeam_tapejobs | 39 ++++++++++++++++++++++++++++++------
web/plugins/wato/check_parameters.py | 17 ++++++++++++++++
2 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/checks/veeam_tapejobs b/checks/veeam_tapejobs
index 0e45e71..51a2dec 100644
--- a/checks/veeam_tapejobs
+++ b/checks/veeam_tapejobs
@@ -24,6 +24,8 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+veeam_tapejobs_default_levels = (1*3600*24, 2*3600*24)
+
def parse_veeam_tapejobs(info):
parsed = {}
columns = map(lambda s: s.lower(), info[0])
@@ -42,19 +44,43 @@ def parse_veeam_tapejobs(info):
def inventory_veeam_tapejobs(parsed):
for job in parsed:
- yield job, None
+ yield job, "veeam_tapejobs_default_levels"
-def check_veeam_tapejobs(item, _no_params, parsed):
+def check_veeam_tapejobs(item, params, parsed):
last_result = parsed[item]["last_result"]
last_state = parsed[item]["last_state"]
+ statetext = ", last state: " + last_state
+
+ warn, crit = params
+
+ now = time.time()
+
+ running_since = get_item_state("running_since")
- if last_result == "Success":
- yield 0, "Last backup successful"
+ if last_result == "None" and last_state == "Working":
+ if not running_since:
+ running_since = now
+ set_item_state("running_since", now)
+ running_time = now - running_since
+ status = 0
+ levelstext = " (warn/crit at %s/%s)" %
tuple(map(get_age_human_readable, params))
+ if running_time >= crit:
+ status = 2
+ elif running_time >= warn:
+ status = 1
+ else:
+ levelstext = ""
+ infotext = "Backup in progress since " +
get_timestamp_human_readable(running_since)\
+ + " (" + get_age_human_readable(running_time) +
")" + levelstext
+ return status, infotext
else:
- yield 2, "Last backup result: " + last_result
+ clear_item_state("running_since")
+ if last_result == "Success":
+ return 0, "Last backup successful" + statetext
+ else:
+ return 2, "Last backup result: " + last_result + statetext
- yield 0, "Last state: " + last_state
check_info["veeam_tapejobs"] = {
@@ -62,4 +88,5 @@ check_info["veeam_tapejobs"] = {
'inventory_function' : inventory_veeam_tapejobs,
'check_function' : check_veeam_tapejobs,
'service_description' : 'VEEAM Tape Job %s',
+ 'group' : 'veeam_tapejobs',
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 0df53e0..2f30d2b 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4073,6 +4073,23 @@ register_check_parameters(
"dict"
)
+register_check_parameters(
+ subgroup_storage,
+ "veeam_tapejobs",
+ _("VEEAM tape backup jobs"),
+ Tuple(
+ title = _("Levels for duration of backup job"),
+ elements = [
+ Age(title = "Warning at"),
+ Age(title = "Critical at"),
+ ],
+ ),
+ TextAscii(
+ title = _("Name of the tape job"),
+ ),
+ "first",
+)
+
#.
# .--Printing------------------------------------------------------------.
# | ____ _ _ _ |