Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / netapp_api_vs_traffic
blobf1fbf6de5fc2b976119499c679d02e96636e9271
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_vs_traffic:sep(9)>>>
28 # lif:vserver instance_uuid 4294967295 instance_name sb1 sent_errors 0 recv_errors 0 ...
29 # lif:vserver instance_uuid 16 instance_name vsFS sent_errors 0 recv_errors 0 ..
30 # cifs:vserver session_timed_out 17731 sd_max_ace_size cifs_latency 9403817108427 ..
31 # iscsi_lif:vserver iscsi_read_ops 4071295661 avg_write_latency 3429809602514 ..
34 def inventory_netapp_api_vs_traffic(parsed, what):
35 vservers = {x.split(".", 1)[1] for x in parsed.keys()}
36 for vserver in vservers:
37 yield vserver, {}
40 def check_netapp_api_vs_traffic(item, _no_params, parsed):
41 protocol_map = {
42 "lif:vserver": (
43 "Ethernet",
44 # ( what perfname perftext scale format_func)
45 [("recv_data", "if_in_octets", "received data", 1, get_bytes_human_readable),
46 ("sent_data", "if_out_octets", "sent data", 1, get_bytes_human_readable),
47 ("recv_errors", "if_in_errors", "received errors", 1, int),
48 ("sent_errors", "if_out_errors", "sent errors", 1, int),
49 ("recv_packet", "if_in_pkts", "received packets", 1, int),
50 ("sent_packet", "if_out_pkts", "sent packets", 1, int)]),
51 "fcp_lif:vserver": (
52 "FCP",
53 [("avg_read_latency", "fcp_read_latency", "avg. Read latency", 0.001,
54 lambda x: "%.2f ms" % (x * 1000)),
55 ("avg_write_latency", "fcp_write_latency", "avg. Write latency", 0.001,
56 lambda x: "%.2f ms" % (x * 1000)),
57 ("read_data", "fcp_read_data", "read data", 1, get_bytes_human_readable),
58 ("write_data", "fcp_write_data", "write data", 1, get_bytes_human_readable)],
60 "cifs:vserver": (
61 "CIFS",
62 [("cifs_read_latency", "cifs_read_latency", "read latency", 0.000000001,
63 lambda x: "%.2f ms" % (x * 1000)),
64 ("cifs_write_latency", "cifs_write_latency", "write latency", 0.000000001,
65 lambda x: "%.2f ms" % (x * 1000)),
66 ("cifs_read_ops", "cifs_read_ios", "read OPs", 1, int),
67 ("cifs_write_ops", "cifs_write_ios", "write OPs", 1, int)],
69 "iscsi_lif:vserver": (
70 "iSCSI",
71 [("avg_read_latency", "iscsi_read_latency", "avg. Read latency", 0.001,
72 lambda x: "%.2f ms" % (x * 1000)),
73 ("avg_write_latency", "iscsi_write_latency", "avg. Write latency", 0.001,
74 lambda x: "%.2f ms" % (x * 1000)),
75 ("read_data", "iscsi_read_data", "read data", 1, get_bytes_human_readable),
76 ("write_data", "iscsi_write_data", "write data", 1, get_bytes_human_readable)],
78 "nfsv3": (
79 "NFS",
80 [("nfsv3_read_ops", "nfs_read_ios", "read OPs", 1, int),
81 ("nfsv3_write_ops", "nfs_write_ios", "write OPs", 1, int),
82 ("nfsv3_read_throughput", "nfs_read_throughput", "read throughput", 1,
83 lambda x: get_bytes_human_readable(x) + "/s"),
84 ("nfsv3_write_throughput", "nfs_write_throughput", "write throughput",
85 1, lambda x: get_bytes_human_readable(x) + "/s"),
86 ("nfsv3_ops", "nfs_ios", "OPs", 1, int)],
88 "nfsv4": (
89 "NFSv4",
90 [("nfsv4_read_ops", "nfsv4_read_ios", "read OPs", 1, int),
91 ("nfsv4_write_ops", "nfsv4_write_ios", "write OPs", 1, int),
92 ("nfs4_read_throughput", "nfsv4_read_throughput", "read throughput", 1,
93 lambda x: get_bytes_human_readable(x) + "/s"),
94 ("nfs4_write_throughput", "nfsv4_write_throughput", "write throughput", 1,
95 lambda x: get_bytes_human_readable(x) + "/s"),
96 ("nfsv4_ops", "nfsv4_ios", "OPs", 1, int)],
98 "nfsv4_1": (
99 "NFSv4.1",
100 [("nfsv4_1_ops", "nfsv4_1_ios", "OPs", 1, int),
101 ("nfs41_read_throughput", "nfsv4_1_read_throughput", "read throughput", 1,
102 lambda x: get_bytes_human_readable(x) + "/s"),
103 ("nfs41_write_throughput", "nfsv4_1_write_throughput", "write throughput", 1,
104 lambda x: get_bytes_human_readable(x) + "/s")],
108 now = time.time()
109 for protocol, (protoname, values) in protocol_map.items():
110 data = parsed.get("%s.%s" % (protocol, item))
111 if not data:
112 continue
114 for what, perfname, perftext, scale, format_func in values:
115 if what not in data:
116 continue
118 rate = get_rate('%s.%s' % (protocol, what), now, int(data[what]) * scale)
119 yield 0, "%s %s: %s" % (protoname, perftext, format_func(rate)), [(perfname, rate)]
122 check_info["netapp_api_vs_traffic"] = {
123 'parse_function':
124 lambda info: netapp_api_parse_lines(info, custom_keys=["protocol", "instance_name"]),
125 'inventory_function': lambda parsed: inventory_netapp_api_vs_traffic(parsed, "lif:vserver"),
126 'check_function': check_netapp_api_vs_traffic,
127 'service_description': 'Traffic vServer %s',
128 'has_perfdata': True,
129 'includes': ["netapp_api.include"]