Cleanup config.nodes_of
[check_mk.git] / checks / hp_msa_if
blobda8a4afb872df98d105edd9db1a2640e6cd2ed72
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 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 # <<<hp_msa_if>>>
28 # port 3 durable-id hostport_A1
29 # port 3 controller A
30 # port 3 controller-numeric 1
31 # port 3 port A1
32 # port 3 port-type FC
33 # port 3 port-type-numeric 6
34 # port 3 media FC(P)
35 # port 3 target-id 207000c0ff1e82bb
36 # port 3 status Up
37 # port 3 status-numeric 0
38 # port 3 actual-speed 8Gb
39 # port 3 actual-speed-numeric 7
40 # port 3 configured-speed Auto
41 # port 3 configured-speed-numeric 3
42 # port 3 health OK
43 # port 3 health-numeric 0
44 # port 3 health-reason
45 # port 3 health-recommendation
46 # fc-port 4 configured-topology PTP
47 # fc-port 4 primary-loop-id N/A
48 # fc-port 4 sfp-status OK
49 # fc-port 4 sfp-present Present
50 # fc-port 4 sfp-present-numeric 1
51 # fc-port 4 sfp-vendor DHS
52 # fc-port 4 sfp-part-number FTLF8529P3BCV-1H
53 # fc-port 4 sfp-revision A
54 # fc-port 4 sfp-supported-speeds 4G,8G,16G
55 # port 5 durable-id hostport_A2
56 # port 5 controller A
57 # port 5 controller-numeric 1
58 # port 5 port A2
59 # port 5 port-type FC
60 # port 5 port-type-numeric 6
61 # port 5 media FC(P)
62 # port 5 target-id 217000c0ff1e82bb
63 # port 5 status Up
64 # port 5 status-numeric 0
65 # port 5 actual-speed 8Gb
66 # port 5 actual-speed-numeric 7
67 # port 5 configured-speed Auto
68 # port 5 configured-speed-numeric 3
69 # port 5 health OK
70 # port 5 health-numeric 0
71 # port 5 health-reason
72 # port 5 health-recommendation
73 # fc-port 6 configured-topology PTP
74 # fc-port 6 primary-loop-id N/A
75 # fc-port 6 sfp-status OK
76 # fc-port 6 sfp-present Present
77 # fc-port 6 sfp-present-numeric 1
78 # fc-port 6 sfp-vendor DHS
79 # fc-port 6 sfp-part-number FTLF8529P3BCV-1H
80 # fc-port 6 sfp-revision A
81 # fc-port 6 sfp-supported-speeds 4G,8G,16G
82 # host-port-statistics 1 durable-id hostport_A1
83 # host-port-statistics 1 bytes-per-second 8881.6KB
84 # host-port-statistics 1 bytes-per-second-numeric 8881664
85 # host-port-statistics 1 iops 106
86 # host-port-statistics 1 number-of-reads 23978726
87 # host-port-statistics 1 number-of-writes 157185192
88 # host-port-statistics 1 data-read 2583.7GB
89 # host-port-statistics 1 data-read-numeric 2583779790336
90 # host-port-statistics 1 data-written 12.7TB
91 # host-port-statistics 1 data-written-numeric 12760541957120
92 # host-port-statistics 1 queue-depth 0
93 # host-port-statistics 1 avg-rsp-time 1355
94 # host-port-statistics 1 avg-read-rsp-time 7872
95 # host-port-statistics 1 avg-write-rsp-time 497
96 # host-port-statistics 1 reset-time 2015-05-22 13:54:37
97 # host-port-statistics 1 reset-time-numeric 1432302877
98 # host-port-statistics 1 start-sample-time 2015-08-21 11:51:43
99 # host-port-statistics 1 start-sample-time-numeric 1440157903
100 # host-port-statistics 1 stop-sample-time 2015-08-21 11:52:00
101 # host-port-statistics 1 stop-sample-time-numeric 1440157920
102 # host-port-statistics 2 durable-id hostport_A2
103 # host-port-statistics 2 bytes-per-second 5161.9KB
104 # host-port-statistics 2 bytes-per-second-numeric 5161984
105 # host-port-statistics 2 iops 220
106 # host-port-statistics 2 number-of-reads 43445061
107 # host-port-statistics 2 number-of-writes 343467343
108 # host-port-statistics 2 data-read 5127.7GB
109 # host-port-statistics 2 data-read-numeric 5127720481792
110 # host-port-statistics 2 data-written 28.0TB
111 # host-port-statistics 2 data-written-numeric 28069848090624
112 # host-port-statistics 2 queue-depth 0
113 # host-port-statistics 2 avg-rsp-time 1492
114 # host-port-statistics 2 avg-read-rsp-time 5309
115 # host-port-statistics 2 avg-write-rsp-time 1129
116 # host-port-statistics 2 reset-time 2015-05-22 13:54:37
117 # host-port-statistics 2 reset-time-numeric 1432302877
118 # host-port-statistics 2 start-sample-time 2015-08-21 11:51:43
119 # host-port-statistics 2 start-sample-time-numeric 1440157903
120 # host-port-statistics 2 stop-sample-time 2015-08-21 11:52:00
121 # host-port-statistics 2 stop-sample-time-numeric 1440157920
124 def parse_hp_msa_if(info):
125 parsed = []
126 for idx, (_key, values) in enumerate(sorted(parse_hp_msa(info).iteritems())):
127 try:
128 speed = int(values['actual-speed'].replace('Gb', '')) * 10**9
129 except ValueError:
130 speed = 0
132 if values['status'] == 'Up':
133 status = '1'
134 else:
135 status = '2'
137 nic = ['0'] * 20
138 nic[0] = str(idx + 1) # Index
139 nic[1] = values['port'] # Description
140 nic[2] = "6" # Fake ethernet # Type
141 nic[3] = speed # Speed
142 nic[4] = status # Status
143 # IN
144 nic[5] = int(values['data-read-numeric']) # inoctets
145 nic[6] = 0 # inucast
146 nic[7] = 0 # inmcast
147 nic[8] = 0 # ibcast
148 nic[9] = 0 # indiscards
149 nic[10] = 0 # inerrors
150 # OUT
151 nic[11] = int(values['data-written-numeric']) # outoctets
152 nic[12] = 0 # outucast
153 nic[13] = 0 # outmcast
154 nic[14] = 0 # outbcast
155 nic[15] = 0 # outdiscards
156 nic[16] = 0 # outspeed
157 nic[17] = int(values['queue-depth']) # outqlen
158 nic[18] = "" # Alias
159 nic[19] = "" # MAC
161 parsed.append(nic)
163 return parsed
166 def inventory_hp_msa_if(parsed):
167 return inventory_if_common(parsed)
170 def check_hp_msa_if(item, params, parsed):
171 yield check_if_common(item, params, parsed)
174 check_info['hp_msa_if'] = {
175 'parse_function': parse_hp_msa_if,
176 'inventory_function': inventory_hp_msa_if,
177 'check_function': check_hp_msa_if,
178 'service_description': 'Interface %s',
179 'has_perfdata': True,
180 'default_levels_variable': 'if_default_levels',
181 'includes': ["hp_msa.include", "if.include"],