Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / scaleio.include
blob3ac5df9789914561f49c242d2c403b7d592c82d1
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_scaleio(info, section):
29 parsed = {}
30 sys_id = ""
31 for line in info:
32 if line[0].startswith(section):
33 sys_id = line[1].replace(":", "")
34 parsed[sys_id] = {}
35 elif sys_id in parsed:
36 parsed[sys_id][line[0]] = line[1:]
37 return parsed
40 # This converts data into MB for our df.include
41 def convert_scaleio_space(unit, value):
42 if unit == "Bytes":
43 return value / 1024 / 1024
44 elif unit == "KB":
45 return value / 1024
46 elif unit == "MB":
47 return value
48 elif unit == "GB":
49 return value * 1024
50 elif unit == "TB":
51 return value * 1024 * 1024
54 # Values can be in every unit. We need Bytes for
55 # diskstat.include
56 def convert_to_bytes(tp, unit):
57 if unit == "Bytes":
58 return tp
59 elif unit == "KB":
60 return tp * 1024
61 elif unit == "MB":
62 return tp * 1024 * 1024
63 elif unit == "GB":
64 return tp * 1024 * 1024 * 1024
65 elif unit == "TB":
66 return tp * 1024 * 1024 * 1024 * 1024
69 def get_disks(item, read_data, write_data):
70 read_tp = convert_to_bytes(int(read_data[-3].strip("(")), \
71 read_data[-2].strip(")"))
72 write_tp = convert_to_bytes(int(write_data[-3].strip("(")), \
73 write_data[-2].strip(")"))
75 disks = {
76 item: {
77 'node': None,
78 'read_ios': int(read_data[0]),
79 'read_throughput': read_tp,
80 'write_ios': int(write_data[0]),
81 'write_throughput': write_tp,
84 return disks
87 def get_scaleio_data(item, parsed):
88 return parsed.get(item)