2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2019 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 factory_settings
['sap_hana_backup'] = {
28 'backup_age': (24 * 60 * 60, 2 * 24 * 60 * 60),
32 def parse_sap_hana_backup(info
):
34 for (sid_instance
, node
), lines
in parse_sap_hana(info
).iteritems():
39 backup_time_readable
= line
[1].rsplit(".", 1)[0]
41 ("%s %s" % (sid_instance
, line
[0]), node
), {
42 "sys_end_time": time
.mktime(
43 time
.strptime(backup_time_readable
, "%Y-%m-%d %H:%M:%S")),
44 "backup_time_readable": backup_time_readable
,
45 "state_name": line
[2],
52 def inventory_sap_hana_backup(parsed
):
53 for (sid_instance_backup_type
, _node
) in parsed
.iterkeys():
54 yield sid_instance_backup_type
, {}
57 def check_sap_hana_backup(item
, params
, parsed
):
58 for (sid_instance_backup_type
, node
), data
in parsed
.iteritems():
59 if item
!= sid_instance_backup_type
:
63 yield 0, 'On node: %s' % node
65 state_name
= data
['state_name']
66 if state_name
== 'failed':
68 elif state_name
in ['cancel pending', 'canceled']:
70 elif state_name
in ['ok', 'successful', 'running']:
74 yield state
, "Status: %s" % state_name
76 yield 0, "Last: %s" % data
['backup_time_readable']
78 time
.time() - data
['sys_end_time'],
81 human_readable_func
=get_age_human_readable
,
84 comment
= data
["comment"]
86 yield 0, "Comment: %s" % comment
88 message
= data
["message"]
90 yield 0, "Message: %s" % message
93 check_info
['sap_hana_backup'] = {
94 'parse_function': parse_sap_hana_backup
,
95 'inventory_function': inventory_sap_hana_backup
,
96 'check_function': check_sap_hana_backup
,
97 'service_description': 'SAP HANA Backup %s',
98 'includes': ['sap_hana.include'],
100 "has_perfdata": True,
101 'group': 'sap_hana_backup',
102 'default_levels_variable': 'sap_hana_backup',