Cleanup config.nodes_of
[check_mk.git] / checks / netapp_api_vf_stats
blobe02c281e23450d532e9949212d892dab5fae20bf
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 netapp_api_vf_stats_cpu_util_default_levels = (90.0, 95.0)
29 # <<<netapp_api_vf_stats:sep(9)>>>
30 # vfiler vfiler0 instance_uuid node_uuid vfiler_cpu_busy 663312444303217 vfiler_net_data_sent 8204762 vfiler_read_ops 14334581 ...
33 def inventory_netapp_api_vf_stats(parsed):
34 stats, _cpu = parsed
35 for key in stats.keys():
36 yield key, 'netapp_api_vf_stats_cpu_util_default_levels'
39 def check_netapp_api_vf_stats(item, params, parsed):
40 stats, cpu = parsed
42 vf = stats.get(item)
43 if not vf:
44 return
46 now = time.time()
48 cpu_busy = int(vf["vfiler_cpu_busy"])
49 ticks_per_sec = get_rate("netapp_api_vf_stats.cpu_busy", now, cpu_busy, onwrap=RAISE)
51 cpu_busy_base = int(vf["vfiler_cpu_busy_base"])
52 ticks_per_sec_base = get_rate(
53 "netapp_api_vf_stats.cpu_busy_base", now, cpu_busy_base, onwrap=RAISE)
55 if ticks_per_sec == 0:
56 raise MKCounterWrapped("Counter wrapped")
58 # vFilers are 7mode only and cannot appear in clustermoder
59 num_processors = float(cpu.get('7mode', {}).get("num_processors", 1))
61 used_perc = ticks_per_sec / num_processors / ticks_per_sec_base * 100
63 # Due to timeing invariancies the measured level can become > 100%.
64 # This makes users unhappy, so cut it off.
65 if used_perc < 0:
66 used_perc = 0
67 elif used_perc > 100:
68 used_perc = 100
70 state, infotext, perfdata = check_cpu_util(used_perc, params, now).next()
71 perfdata[0] = perfdata[0][:5]
72 infotext += ", Num Processors: %d" % num_processors
73 return state, infotext, perfdata
76 check_info["netapp_api_vf_stats"] = {
77 'parse_function': netapp_api_parse_lines,
78 'check_function': check_netapp_api_vf_stats,
79 'inventory_function': inventory_netapp_api_vf_stats,
80 'has_perfdata': True,
81 'group': 'cpu_utilization_multiitem',
82 'service_description': 'CPU utilization %s',
83 'includes': ["cpu_util.include", "netapp_api.include"],
84 'extra_sections': ['netapp_api_cpu'],
88 def inventory_netapp_api_vf_stats_traffic(parsed):
89 stats, _ = parsed
90 for key in stats.keys():
91 yield key, None
94 def check_netapp_api_vf_stats_traffic(item, params, parsed):
95 stats, _ = parsed
97 vf = stats.get(item)
98 if not vf:
99 return
100 else:
101 now = time.time()
102 for entry, name, base, factor, unit in [
103 ("read_ops", "Read", 1000.0, 1, "OP/s"),
104 ("write_ops", "Write", 1000.0, 1, "OP/s"),
105 ("net_data_recv", "Net Data Recv", 1024.0, 1024, "B/s"),
106 ("net_data_sent", "Net Data Sent", 1024.0, 1024, "B/s"),
107 ("read_bytes", "Read", 1024.0, 1024, "B/s"),
108 ("write_bytes", "Write", 1024.0, 1024, "B/s"),
110 traffic = int(vf["vfiler_" + entry]) * factor
111 ticks_per_sec = get_rate("netapp_api_vf_stats.traffic.%s.%s" % (item, entry), now,
112 traffic)
113 yield 0, "%s: %s" % (name, get_bytes_human_readable(
114 ticks_per_sec, base=base, unit=unit)), [(entry, ticks_per_sec)]
117 check_info["netapp_api_vf_stats.traffic"] = {
118 'check_function': check_netapp_api_vf_stats_traffic,
119 'inventory_function': inventory_netapp_api_vf_stats_traffic,
120 'has_perfdata': True,
121 'service_description': 'Traffic vFiler %s',