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.
27 # https://www.unigma.com/2016/07/11/best-practices-for-monitoring-microsoft-azure/
28 factory_settings
["azure_databases_default_levels"] = {
29 "storage_percent_levels": (85., 95.),
30 "cpu_percent_levels": (85., 95.),
31 "dtu_percent_levels": (85., 95.),
36 def check_azure_databases_storage(_item
, params
, resource
):
38 cmk_key
= 'storage_percent'
39 levels
= params
.get("%s_levels" % cmk_key
)
40 mcheck
= check_azure_metric(
41 resource
, 'average_storage_percent', cmk_key
, 'Storage', levels
=levels
, minv
=0)
43 state
, text
, perf
= mcheck
44 abs_storage_metric
= resource
.get('metrics', {}).get('average_storage')
45 if abs_storage_metric
is not None:
46 text
+= " (%s)" % get_bytes_human_readable(abs_storage_metric
.value
)
47 yield state
, text
, perf
50 check_info
['azure_databases.storage'] = {
51 'inventory_function': discover_azure_by_metrics('average_storage_percent'),
52 'check_function': check_azure_databases_storage
,
54 'service_description': "DB %s Storage",
55 'default_levels_variable': 'azure_databases_default_levels',
56 'group': 'azure_databases',
61 def check_azure_databases_deadlock(_item
, params
, resource
):
64 levels
= params
.get("%s_levels" % cmk_key
)
65 mcheck
= check_azure_metric(
66 resource
, 'average_deadlock', cmk_key
, 'Deadlocks', levels
=levels
, minv
=0)
71 check_info
['azure_databases.deadlock'] = {
72 'inventory_function': discover_azure_by_metrics('average_deadlock'),
73 'check_function': check_azure_databases_deadlock
,
75 'service_description': "DB %s Deadlocks",
76 'default_levels_variable': 'azure_databases_default_levels',
77 'group': 'azure_databases',
82 def check_azure_databases_cpu(_item
, params
, resource
):
84 metrics
= resource
.get('metrics', {})
86 cpu_percent
= metrics
.get('average_cpu_percent')
88 if cpu_percent
is not None:
89 if "cpu_percent_levels" in params
:
90 util_params
["levels"] = params
["cpu_percent_levels"]
91 for y
in check_cpu_util(cpu_percent
.value
, util_params
):
95 check_info
['azure_databases.cpu'] = {
96 'inventory_function': discover_azure_by_metrics('average_cpu_percent'),
97 'check_function': check_azure_databases_cpu
,
99 'service_description': "DB %s CPU",
100 'default_levels_variable': 'azure_databases_default_levels',
101 'group': 'azure_databases',
105 @get_parsed_item_data
106 def check_azure_databases_dtu(_item
, params
, resource
):
108 cmk_key
= 'dtu_percent'
109 levels
= params
.get("%s_levels" % cmk_key
)
110 mcheck
= check_azure_metric(
112 'average_dtu_consumption_percent',
114 'Database throughput units',
121 check_info
['azure_databases.dtu'] = {
122 'inventory_function': discover_azure_by_metrics('average_dtu_consumption_percent'),
123 'check_function': check_azure_databases_dtu
,
124 'has_perfdata': True,
125 'service_description': "DB %s DTU",
126 'default_levels_variable': 'azure_databases_default_levels',
127 'group': 'azure_databases',
130 _AZURE_CONNECTIONS_METRICS
= (
131 # metric key cmk key, display use_rate
132 ("average_connection_successful", "connections", "Successful connections", False),
133 ("average_connection_failed", "connections_failed_rate", "Rate of failed connections", True),
137 @get_parsed_item_data
138 def check_azure_databases_connections(_item
, params
, resource
):
140 for key
, cmk_key
, displ
, use_rate
in _AZURE_CONNECTIONS_METRICS
:
141 levels
= params
.get("%s_levels" % cmk_key
)
142 mcheck
= check_azure_metric(
143 resource
, key
, cmk_key
, displ
, levels
=levels
, minv
=0, use_rate
=use_rate
)
148 check_info
['azure_databases.connections'] = {
149 'inventory_function': discover_azure_by_metrics('average_connection_successful',
150 'average_connection_failed'),
151 'check_function': check_azure_databases_connections
,
152 'has_perfdata': True,
153 'service_description': "DB %s Connections",
154 'default_levels_variable': 'azure_databases_default_levels',
155 'group': 'azure_databases',
159 @get_parsed_item_data
160 def check_azure_databases(_item
, _no_params
, resource
):
161 for k
, v
in azure_iter_informative_attrs(resource
):
162 yield 0, "%s: %s" % (k
, v
)
165 check_info
['azure_databases'] = {
166 'parse_function': parse_azure
,
167 'inventory_function': discover(),
168 'check_function': check_azure_databases
,
169 'service_description': "DB %s",
170 'includes': ['azure.include', 'cpu_util.include'],
171 'default_levels_variable': 'azure_databases_default_levels',
172 'group': 'azure_databases',