Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / azure_storageaccounts
blob1429b8de953dc7aea44a15c97bc3527ae83fef64
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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 factory_settings['levels_azure_storageaccounts'] = {}
28 # metrics description:
29 # https://docs.microsoft.com/en-US/azure/monitoring-and-diagnostics/monitoring-supported-metrics#microsoftstoragestorageaccounts
30 # 'ingress_levels': tuple [B]
31 # 'egress_levels': tuple [B]
32 # 'used_capacity_levels': tuple [B]
33 # 'server_latency_levels': tuple [ms]
34 # 'e2e_latency_levels': tuple [ms]
35 # 'transactions_levels': tuple int
36 # 'availablility_levels': tuple float
37 # The percentage of availability for the storage service or the specified API operation.
38 # Availability is calculated by taking the TotalBillableRequests value and dividing it
39 # by the number of applicable requests, including those that produced unexpected errors.
40 # All unexpected errors result in reduced availability for the storage service or the
41 # specified API operation.
44 @get_parsed_item_data
45 def check_azure_storageaccounts(_item, params, resource):
46 iter_attrs = azure_iter_informative_attrs(resource, include_keys=('kind', 'location'))
47 # kind first
48 yield 0, "%s: %s" % next(iter_attrs)
50 levels = params.get("used_capacity_levels", (None, None))
51 mcheck = check_azure_metric(
52 resource, 'total_UsedCapacity', 'used_space', 'Used capacity', levels=levels, minv=0)
53 if mcheck:
54 yield mcheck
56 for kv_pair in iter_attrs:
57 yield 0, "%s: %s" % kv_pair
60 check_info['azure_storageaccounts'] = {
61 'parse_function': parse_azure,
62 'inventory_function': discover(),
63 'check_function': check_azure_storageaccounts,
64 'service_description': "Storage %s account",
65 'includes': ['azure.include'],
66 'has_perfdata': True,
67 'default_levels_variable': 'levels_azure_storageaccount',
68 'group': 'azure_storageaccount',
72 @get_parsed_item_data
73 def check_azure_storageaccounts_flow(_item, params, resource):
74 for metric_key in ('total_Ingress', 'total_Egress', 'total_Transactions'):
75 cmk_key = metric_key[6:].lower()
76 displ = cmk_key.title()
77 levels = params.get("%s_levels" % cmk_key, (None, None))
78 mcheck = check_azure_metric(resource, metric_key, cmk_key, displ, levels=levels, minv=0)
79 if mcheck:
80 yield mcheck
83 check_info['azure_storageaccounts.flow'] = {
84 'inventory_function': discover_azure_by_metrics('total_Ingress', 'total_Egress',
85 'total_Transactions'),
86 'check_function': check_azure_storageaccounts_flow,
87 'service_description': "Storage %s flow",
88 'has_perfdata': True,
89 'includes': ['azure.include'],
90 'default_levels_variable': 'levels_azure_storageaccount',
91 'group': 'azure_storageaccount',
95 @get_parsed_item_data
96 def check_azure_storageaccounts_performance(_item, params, resource):
98 for key, cmk_key, displ in (
99 ('total_SuccessServerLatency', 'server_latency', 'Success server latency'),
100 ('total_SuccessE2ELatency', 'e2e_latency', 'End-to-end server latency'),
101 ('total_Availability', 'availability', 'Availability'),
103 levels = params.get("%s_levels" % cmk_key, (None, None))
104 mcheck = check_azure_metric(resource, key, cmk_key, displ, levels=levels, minv=0)
105 if mcheck:
106 yield mcheck
109 check_info['azure_storageaccounts.performance'] = {
110 'inventory_function': discover_azure_by_metrics(
111 'total_SuccessServerLatency', 'total_SuccessE2ELatency', 'total_Availability'),
112 'check_function': check_azure_storageaccounts_performance,
113 'service_description': "Storage %s performance",
114 'has_perfdata': True,
115 'includes': ['azure.include'],
116 'default_levels_variable': 'levels_azure_storageaccount',
117 'group': 'azure_storageaccount',