Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / storeonce.include
blob54176d127546b099d081cec5e7d7285d12cad2a2
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.
28 def parse_storeonce_clusterinfo(info):
29 parsed = {}
30 for line in info:
31 parsed[line[0]] = line[1]
32 return parsed
35 def parse_storeonce_servicesets(info):
36 parsed = {}
37 for line in info:
38 if line[0].startswith('['):
39 item = line[0]
40 parsed[item] = {}
41 else:
42 parsed[item][line[0]] = line[1]
43 return parsed
46 def translate_storeonce_status(status):
47 translate_state = {
48 '0': 3, # Unknown
49 '1': 0, # OK
50 '2': 0, # Information
51 '3': 1, # Warning
52 '4': 2, # Critical
54 return translate_state[status]
57 def _get_storeonce_space_values(values, type_):
58 key = "%s Space in bytes" % type_
59 if key in values:
60 return float(values[key]), 0, 0
62 # combined(total) = local + cloud
63 combined_key = "combined%sBytes" % type_
64 cloud_key = "cloud%sBytes" % type_
65 local_key = "local%sBytes" % type_
66 return float(values.get(combined_key, 0)),\
67 float(values.get(cloud_key, 0)),\
68 float(values.get(local_key, 0))
71 def check_storeonce_space(item, params, values):
72 total_bytes, cloud_bytes, local_bytes = _get_storeonce_space_values(values, "Capacity")
73 free_bytes, free_cloud_bytes, free_local_bytes = _get_storeonce_space_values(values, "Free")
74 factor = 1024 * 2
75 yield df_check_filesystem_list(item, params,
76 [(item, total_bytes / factor, free_bytes / factor, 0)])
78 if cloud_bytes and local_bytes:
79 yield 0, "Total cloud: %s, Total local: %s" % (get_bytes_human_readable(cloud_bytes),
80 get_bytes_human_readable(local_bytes))
82 if free_cloud_bytes and free_local_bytes:
83 yield 0, "Free cloud: %s, Free local: %s" % (get_bytes_human_readable(free_cloud_bytes),
84 get_bytes_human_readable(free_local_bytes))
86 yield 0, "Dedup ratio: %.2f" % float(values['Deduplication Ratio'])