Cleanup config.nodes_of
[check_mk.git] / checks / emcvnx_sp_util
blob88f6f6149d36a9c311e6aaaccfcd87885d862d6f
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 # <<<emcvnx_sp_util:sep(58)>>>
28 # Controller busy ticks: 1639432
29 # Controller idle ticks: 1773844
31 # suggested by customer
32 emcvnx_sp_util_default_levels = (50.0, 60.0)
35 def parse_emcvnx_sp_util(info):
36 parsed = {}
37 for line in info:
38 if len(line) == 2 and "busy" in line[0]:
39 parsed.setdefault("busy", float(line[1]))
40 elif len(line) == 2 and "idle" in line[0]:
41 parsed.setdefault("idle", float(line[1]))
42 return parsed
45 def inventory_emcvnx_sp_util(parsed):
46 if "idle" in parsed and "busy" in parsed:
47 return [(None, "emcvnx_sp_util_default_levels")]
50 def check_emcvnx_sp_util(item, params, parsed):
51 if not ("idle" in parsed and "busy" in parsed):
52 return
54 now = time.time()
55 warn, crit = params
56 busy_ticks_rate = get_rate("emcvnx_sp_util.busy_ticks", now, parsed["busy"])
57 idle_ticks_rate = get_rate("emcvnx_sp_util.idle_ticks", now, parsed["idle"])
58 if busy_ticks_rate + idle_ticks_rate == 0:
59 sp_util = 0
60 else:
61 sp_util = 100 * (busy_ticks_rate / (busy_ticks_rate + idle_ticks_rate))
62 infotext = "%.1f%%" % sp_util
63 if sp_util >= crit:
64 state = 2
65 elif sp_util >= warn:
66 state = 1
67 else:
68 state = 0
70 if state > 0:
71 infotext += " (warn/crit at %.1f%%/%.1f%%)" % (warn, crit)
73 return state, infotext, [("storage_processor_util", sp_util, warn, crit, 0, 100.0)]
76 check_info['emcvnx_sp_util'] = {
77 "parse_function": parse_emcvnx_sp_util,
78 "inventory_function": inventory_emcvnx_sp_util,
79 "check_function": check_emcvnx_sp_util,
80 "service_description": "Storage Processor Utilization",
81 "group": "sp_util",
82 "has_perfdata": True,