2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # ------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2015 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.
28 # [[[db2taddm:CMDBS1]]]
29 # 2015-03-12-04.00.13.000000
31 db2_backup_default_levels
= (86400 * 14, 86400 * 28)
34 def inventory_db2_backup(parsed
):
35 for instance
in parsed
[1]:
36 yield instance
, "db2_backup_default_levels"
39 def check_db2_backup(item
, params
, parsed
):
40 db
= parsed
[1].get(item
)
42 raise MKCounterWrapped("Login into database failed")
45 last_backup
= time
.mktime(time
.strptime(db
[0][0][:19], "%Y-%m-%d-%H.%M.%S"))
48 yield 1, "No backup available"
50 yield 3, "Last backup contains an invalid timestamp: %s" % db
[0][0]
53 age
= time
.time() - last_backup
57 yield 2, "Time since last backup: %s" % get_age_human_readable(age
)
59 yield 1, "Time since last backup: %s" % get_age_human_readable(age
)
61 yield 0, "Time since last backup: %s" % get_age_human_readable(age
)
63 yield 0, "Time since last backup: %s" % get_age_human_readable(age
)
66 check_info
['db2_backup'] = {
67 "parse_function": parse_db2_dbs
,
68 "service_description": "DB2 Backup %s",
69 "check_function": check_db2_backup
,
70 "inventory_function": inventory_db2_backup
,
71 "group": "db2_backup",
72 "includes": ["db2.include"],