Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / ibm_svc_license
blobe5f3a2a0178e7d95950ca5d13c5fe5f9d8b68cde
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 from agent:
28 # <<<ibm_svc_license:sep(58)>>>
29 # used_flash:0.00
30 # used_remote:0.00
31 # used_virtualization:192.94
32 # license_flash:0
33 # license_remote:0
34 # license_virtualization:412
35 # license_physical_disks:0
36 # license_physical_flash:off
37 # license_physical_remote:off
38 # used_compression_capacity:0.00
39 # license_compression_capacity:0
40 # license_compression_enclosures:0
43 def parse_ibm_svc_license(info):
44 licenses = {}
45 for line in info:
46 if line[0].startswith("license_"):
47 license_ = line[0].replace("license_", "")
48 if not license_ in licenses.keys():
49 licenses[license_] = [0.0, 0.0]
50 if line[1] == "off":
51 licenses[license_][0] = 0.0
52 else:
53 licenses[license_][0] = float(line[1])
54 if line[0].startswith("used_"):
55 license_ = line[0].replace("used_", "")
56 if not license_ in licenses.keys():
57 licenses[license_] = [0.0, 0.0]
58 licenses[license_][1] = float(line[1])
59 return licenses
62 def inventory_ibm_svc_license(parsed):
63 for item, data in parsed.items():
64 if data != [0.0, 0.0]:
65 # Omit unused svc features
66 yield item, None
69 def check_ibm_svc_license(item, params, parsed):
70 licensed, used = parsed[item]
71 return license_check_levels(licensed, used, params)
74 check_info["ibm_svc_license"] = {
75 "check_function": check_ibm_svc_license,
76 "inventory_function": inventory_ibm_svc_license,
77 "parse_function": parse_ibm_svc_license,
78 "service_description": "License %s",
79 "group": "ibmsvc_licenses",
80 "has_perfdata": True,
81 "includes": ["license.include"]