Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / checks / scaleio_sds
blobfc0e54b1e967283de4668049e4d4298cbdf87680
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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 # example output
28 #<<<scaleio_sds>>>
29 #SDS 3c7af8db00000000:
30 # ID 3c7af8db00000000
31 # NAME sds03
32 # PROTECTION_DOMAIN_ID 91ebcf4500000000
33 # STATE REMOVE_STATE_NORMAL
34 # MEMBERSHIP_STATE JOINED
35 # MDM_CONNECTION_STATE MDM_CONNECTED
36 # MAINTENANCE_MODE_STATE NO_MAINTENANCE
37 # MAX_CAPACITY_IN_KB 21.8 TB (22353 GB)
38 # UNUSED_CAPACITY_IN_KB 13.2 TB (13471 GB)
40 #SDS 3c7ad1cc00000001:
41 # ID 3c7ad1cc00000001
42 # NAME sds01
43 # PROTECTION_DOMAIN_ID 91ebcf4500000000
44 # STATE REMOVE_STATE_NORMAL
45 # MEMBERSHIP_STATE JOINED
46 # MDM_CONNECTION_STATE MDM_CONNECTED
47 # MAINTENANCE_MODE_STATE NO_MAINTENANCE
48 # MAX_CAPACITY_IN_KB 21.8 TB (22353 GB)
49 # UNUSED_CAPACITY_IN_KB 13.2 TB (13477 GB)
51 #SDS 3c7af8dc00000002:
52 # ID 3c7af8dc00000002
53 # NAME sds02
54 # PROTECTION_DOMAIN_ID 91ebcf4500000000
55 # STATE REMOVE_STATE_NORMAL
56 # MEMBERSHIP_STATE JOINED
57 # MDM_CONNECTION_STATE MDM_CONNECTED
58 # MAINTENANCE_MODE_STATE NO_MAINTENANCE
59 # MAX_CAPACITY_IN_KB 21.8 TB (22353 GB)
60 # UNUSED_CAPACITY_IN_KB 13.2 TB (13477 GB)
64 def inventory_scaleio_sds(parsed):
65 for entry in parsed:
66 yield entry, {}
69 def check_scaleio_sds(item, params, parsed):
70 data = get_scaleio_data(item, parsed)
71 if not data:
72 return
74 # How will the data be represented? It's magic and the only
75 # indication is the unit. We need to handle this!
76 unit = data["MAX_CAPACITY_IN_KB"][3].strip(")")
77 total = convert_scaleio_space(unit, int(data["MAX_CAPACITY_IN_KB"][2].strip("(")))
78 free = convert_scaleio_space(unit, int(data["UNUSED_CAPACITY_IN_KB"][2].strip("(")))
80 yield df_check_filesystem_list(item, params, [(item, total, free, 0)])
83 check_info['scaleio_sds'] = {
84 'parse_function': lambda info: parse_scaleio(info, "SDS"),
85 'inventory_function': inventory_scaleio_sds,
86 'check_function': check_scaleio_sds,
87 'service_description': 'ScaleIO SDS capacity %s',
88 'group': "filesystem",
89 'has_perfdata': True,
90 'includes': ['scaleio.include', 'size_trend.include', 'df.include'],
94 def inventory_scaleio_sds_status(parsed):
95 for entry in parsed:
96 yield entry, {}
99 def check_scaleio_sds_status(item, params, parsed):
100 data = get_scaleio_data(item, parsed)
101 if not data:
102 return
104 name, pd_id = data["NAME"][0], data["PROTECTION_DOMAIN_ID"][0]
105 yield 0, "Name: %s, PD: %s" % (name, pd_id)
107 status = data["STATE"][0]
108 if "normal" not in status.lower():
109 yield 2, "State: %s" % status
111 status_maint = data["MAINTENANCE_MODE_STATE"][0]
112 if "no_maintenance" not in status_maint.lower():
113 yield 1, "Maintenance: %s" % status_maint
115 status_conn = data["MDM_CONNECTION_STATE"][0]
116 if "connected" not in status_conn.lower():
117 yield 2, "Connection state: %s" % status_conn
119 status_member = data["MEMBERSHIP_STATE"][0]
120 if "joined" not in status_member.lower():
121 yield 2, "Membership state: %s" % status_member
124 check_info['scaleio_sds.status'] = {
125 'parse_function': lambda info: parse_scaleio(info, "SDS"),
126 'inventory_function': inventory_scaleio_sds_status,
127 'check_function': check_scaleio_sds_status,
128 'service_description': 'ScaleIO SDS status %s',