2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 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.
28 def parse_ddn_s2a_errors(info
):
29 preparsed
= parse_ddn_s2a_api_response(info
)
31 "port_type": preparsed
[u
"port_type"],
32 "link_failure_errs": map(int, preparsed
[u
"link_failure_errs"]),
33 "lost_sync_errs": map(int, preparsed
[u
"lost_sync_errs"]),
34 "loss_of_signal_errs": map(int, preparsed
[u
"loss_of_sig_errs"]),
35 "prim_seq_errs": map(int, preparsed
[u
"prim_seq_errs"]),
36 "crc_errs": map(int, preparsed
[u
"CRC_errs"]),
37 "receive_errs": map(int, preparsed
[u
"receive_errs"]),
38 "ctio_timeouts": map(int, preparsed
[u
"CTIO_timeouts"]),
39 "ctio_xmit_errs": map(int, preparsed
[u
"CTIO_xmit_errs"]),
40 "ctio_other_errs": map(int, preparsed
[u
"CTIO_other_errs"]),
44 def inventory_ddn_s2a_errors(parsed
):
45 def value_to_levels(value
):
46 # As the values in this check are all error counters since last reset,
47 # we calculate default levels according to the current counter state,
48 # so we'll be warned if an error occurs.
49 return (value
+ 1, value
+ 5)
51 for nr
, port_type
in enumerate(parsed
[u
"port_type"]):
53 # Note: The API command returning the port errors that we evaluate
54 # in this check differentiates between FC and IB ports, providing
55 # different values according to port type. As we have no example
56 # for the IB ports at this time, we only implement logic for what
58 if port_type
== u
"FC":
60 yield "%d" % (nr
+ 1), {
61 "link_failure_errs": value_to_levels(parsed
["link_failure_errs"][nr
]),
62 "lost_sync_errs": value_to_levels(parsed
["lost_sync_errs"][nr
]),
63 "loss_of_signal_errs": value_to_levels(parsed
["loss_of_signal_errs"][nr
]),
64 "prim_seq_errs": value_to_levels(parsed
["prim_seq_errs"][nr
]),
65 "crc_errs": value_to_levels(parsed
["crc_errs"][nr
]),
66 "receive_errs": value_to_levels(parsed
["receive_errs"][nr
]),
67 "ctio_timeouts": value_to_levels(parsed
["ctio_timeouts"][nr
]),
68 "ctio_xmit_errs": value_to_levels(parsed
["ctio_xmit_errs"][nr
]),
69 "ctio_other_errs": value_to_levels(parsed
["ctio_other_errs"][nr
]),
73 def check_ddn_s2a_errors(item
, params
, parsed
):
74 def check_errors(value
, levels
, infotext_formatstring
):
75 infotext
= infotext_formatstring
% value
80 levelstext
= " (warn/crit at %d/%d errors)" % (warn
, crit
)
83 infotext
+= levelstext
86 infotext
+= levelstext
89 return status
, infotext
92 link_failure_errs
= parsed
["link_failure_errs"][nr
]
93 lost_sync_errs
= parsed
["lost_sync_errs"][nr
]
94 loss_of_signal_errs
= parsed
["loss_of_signal_errs"][nr
]
95 prim_seq_errs
= parsed
["prim_seq_errs"][nr
]
96 crc_errs
= parsed
["crc_errs"][nr
]
97 receive_errs
= parsed
["receive_errs"][nr
]
98 ctio_timeouts
= parsed
["ctio_timeouts"][nr
]
99 ctio_xmit_errs
= parsed
["ctio_xmit_errs"][nr
]
100 ctio_other_errs
= parsed
["ctio_other_errs"][nr
]
102 yield check_errors(link_failure_errs
, params
["link_failure_errs"], "Link failure errors: %d")
103 yield check_errors(lost_sync_errs
, params
["lost_sync_errs"], "Lost sync errors: %d")
104 yield check_errors(loss_of_signal_errs
, params
["loss_of_signal_errs"],
105 "Loss of signal errors: %d")
106 yield check_errors(prim_seq_errs
, params
["prim_seq_errs"],
107 "PrimSeq errors: %d") # TODO: What is this?
108 yield check_errors(crc_errs
, params
["crc_errs"], "CRC errors: %d")
109 yield check_errors(receive_errs
, params
["receive_errs"], "Receive errors: %d")
110 yield check_errors(ctio_timeouts
, params
["ctio_timeouts"], "CTIO timeouts: %d")
111 yield check_errors(ctio_xmit_errs
, params
["ctio_xmit_errs"], "CTIO transmission errors: %d")
112 yield check_errors(ctio_other_errs
, params
["ctio_other_errs"], "CTIO other errors: %d")
115 check_info
['ddn_s2a_errors'] = {
116 'parse_function': parse_ddn_s2a_errors
,
117 'inventory_function': inventory_ddn_s2a_errors
,
118 'check_function': check_ddn_s2a_errors
,
119 'service_description': 'DDN S2A Port Errors %s',
120 'includes': ["ddn_s2a.include"],
121 'group': "ddn_s2a_port_errors",