2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2016 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 veeam_tapejobs_default_levels
= (1 * 3600 * 24, 2 * 3600 * 24)
30 def parse_veeam_tapejobs(info
):
32 columns
= [s
.lower() for s
in info
[0]]
35 name
= " ".join(line
[:-(len(columns
) - 1)])
36 job_id
, last_result
, last_state
= line
[-(len(columns
) - 1):]
39 "last_result": last_result
,
40 "last_state": last_state
,
46 def inventory_veeam_tapejobs(parsed
):
48 yield job
, "veeam_tapejobs_default_levels"
51 def check_veeam_tapejobs(item
, params
, parsed
):
52 data
= parsed
.get(item
)
56 last_result
= data
["last_result"]
57 last_state
= data
["last_state"]
58 statetext
= ", last state: " + last_state
64 running_since
= get_item_state("running_since")
66 if last_result
== "None" and last_state
== "Working":
69 set_item_state("running_since", now
)
70 running_time
= now
- running_since
72 levelstext
= " (warn/crit at %s/%s)" % tuple(map(get_age_human_readable
, params
))
73 if running_time
>= crit
:
75 elif running_time
>= warn
:
79 infotext
= "Backup in progress since " + get_timestamp_human_readable(running_since
)\
80 + " (" + get_age_human_readable(running_time
) + ")" + levelstext
81 return status
, infotext
83 clear_item_state("running_since")
84 if last_result
== "Success":
85 return 0, "Last backup successful" + statetext
86 elif last_result
== "Warning":
87 return 1, "Last backup result: " + last_result
+ statetext
88 return 2, "Last backup result: " + last_result
+ statetext
91 check_info
["veeam_tapejobs"] = {
92 'parse_function': parse_veeam_tapejobs
,
93 'inventory_function': inventory_veeam_tapejobs
,
94 'check_function': check_veeam_tapejobs
,
95 'service_description': 'VEEAM Tape Job %s',
96 'group': 'veeam_tapejobs',