2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 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 # TODO WATO group 'memory_simple' for items
30 def parse_sap_hana_mem(info
):
35 if line
[0] in ["[[[resident]]]", "[[[database]]]"]:
36 section
= line
[0][3:-3]
39 if line
[0].startswith("[[[") and line
[0].endswith("]]]"):
40 instance
= line
[0][3:-3]
46 line
= [x
.replace('"', '').strip() for x
in line
]
47 inst_data
= pparsed
.setdefault("%s %s" % (instance
, line
[0]), {})
48 # all memory values in bytes
49 if section
== 'resident':
52 elif section
== 'database':
53 # used, max, resident_max
54 data
= map(int, line
[1:])
57 inst_data
.setdefault(section
, data
)
60 for instance
, attrs
in pparsed
.iteritems():
61 inst_data
= parsed
.setdefault(instance
, {})
62 resident_used
= attrs
['resident']
63 db_used
, db_max
, resident_max
= attrs
['database']
64 inst_data
.setdefault('database', [db_used
, db_max
])
65 inst_data
.setdefault('resident', [resident_used
, resident_max
])
69 def inventory_sap_hana_mem(parsed
, _type
):
70 return [(instance
, {}) for instance
, attrs
in parsed
.iteritems() if _type
in attrs
]
73 def check_sap_hana_mem(item
, params
, parsed
, _type
):
76 used
, total
= data
[_type
]
77 return check_memory_simple(used
, total
, params
)
80 # .--resident------------------------------------------------------------.
82 # | _ __ ___ ___(_) __| | ___ _ __ | |_ |
83 # | | '__/ _ \/ __| |/ _` |/ _ \ '_ \| __| |
84 # | | | | __/\__ \ | (_| | __/ | | | |_ |
85 # | |_| \___||___/_|\__,_|\___|_| |_|\__| |
87 # '----------------------------------------------------------------------'
89 factory_settings
["sap_hana_mem_resident_default_levels"] = {"levels": ("perc_used", (80.0, 90.0))}
92 def inventory_sap_hana_mem_resident(parsed
):
93 return inventory_sap_hana_mem(parsed
, 'resident')
96 def check_sap_hana_mem_resident(item
, params
, parsed
):
97 return check_sap_hana_mem(item
, params
, parsed
, 'resident')
100 check_info
['sap_hana_mem'] = {
101 'parse_function': parse_sap_hana_mem
,
102 'inventory_function': inventory_sap_hana_mem_resident
,
103 'check_function': check_sap_hana_mem_resident
,
104 'service_description': 'SAP HANA Resident Memory %s',
105 'includes': ['memory.include'],
106 #'group' : 'memory_simple',
107 'has_perfdata': True,
108 'default_levels_variable': 'sap_hana_mem_resident_default_levels',
112 # .--database------------------------------------------------------------.
114 # | __| | __ _| |_ __ _| |__ __ _ ___ ___ |
115 # | / _` |/ _` | __/ _` | '_ \ / _` / __|/ _ \ |
116 # | | (_| | (_| | || (_| | |_) | (_| \__ \ __/ |
117 # | \__,_|\__,_|\__\__,_|_.__/ \__,_|___/\___| |
119 # '----------------------------------------------------------------------'
121 factory_settings
["sap_hana_mem_database_default_levels"] = {"levels": ("perc_used", (80.0, 90.0))}
124 def inventory_sap_hana_mem_db(parsed
):
125 return inventory_sap_hana_mem(parsed
, 'database')
128 def check_sap_hana_mem_db(item
, params
, parsed
):
129 return check_sap_hana_mem(item
, params
, parsed
, 'database')
132 check_info
['sap_hana_mem.database'] = {
133 'inventory_function': inventory_sap_hana_mem_db
,
134 'check_function': check_sap_hana_mem_db
,
135 'service_description': 'SAP HANA Used Memory %s',
136 'includes': ['memory.include'],
137 #'group' : 'memory_simple',
138 'has_perfdata': True,
139 'default_levels_variable': 'sap_hana_mem_database_default_levels',