Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / brocade_tm
blob0d6afbf8d1e67ab2d91b8ce4b5a92c9a651bf217
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 # FIXME:
28 # - no camel case in check parameters
29 # - use friendly output of values. Output
30 # "Ingress Dequeue Packets" instead of "brcdTMStatsIngressDequeuePkts"
32 factory_settings["brocade_tm_default_levels"] = {
33 'brcdTMStatsTotalIngressPktsCnt': (1000, 10000),
34 'brcdTMStatsIngressEnqueuePkts': (1000, 10000),
35 'brcdTMStatsEgressEnqueuePkts': (1000, 10000),
36 'brcdTMStatsIngressDequeuePkts': (1000, 10000),
37 'brcdTMStatsIngressTotalQDiscardPkts': (1000, 10000),
38 'brcdTMStatsIngressOldestDiscardPkts': (1000, 10000),
39 'brcdTMStatsEgressDiscardPkts': (1000, 10000),
43 def inventory_brocade_tm(info):
44 inventory = []
45 for line in info:
46 inventory.append((line[0], None))
47 return inventory
50 def check_brocade_tm(item, params, info):
51 for line in info:
52 if line[0] == item:
53 tm = {}
55 tm['TotalIngressPktsCnt'] = line[1]
56 tm['IngressEnqueuePkts'] = line[2]
57 tm['EgressEnqueuePkts'] = line[3]
58 tm['IngressDequeuePkts'] = line[4]
59 tm['IngressTotalQDiscardPkts'] = line[5]
60 tm['IngressOldestDiscardPkts'] = line[6]
61 tm['EgressDiscardPkts'] = line[7]
63 now = time.time()
64 infotext = ""
65 perfdata = []
66 overall_state = 0
68 for name, counter in tm.items():
69 rate = get_rate("%s.%s" % (name, item), now, int(counter))
71 warn, crit = params["brcdTMStats" + name]
72 if re.search("Discard", name):
73 if rate > crit:
74 state = 2
75 sym = "(!!)"
76 elif rate > warn:
77 state = 1
78 sym = "(!)"
79 else:
80 state = 0
81 sym = ""
82 else:
83 state = 0
84 sym = ""
85 infotext += "%s: %.1f%s, " % (name, rate, sym)
86 perfdata.append((name, rate, warn, crit))
87 overall_state = max(overall_state, state)
89 return (overall_state, infotext, perfdata)
91 return (3, "Interface not found")
94 check_info["brocade_tm"] = {
95 'check_function': check_brocade_tm,
96 'inventory_function': inventory_brocade_tm,
97 'service_description': 'TM %s',
98 'has_perfdata': True,
99 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1991.1."),
100 'group': 'brocade_tm',
101 'default_levels_variable': 'brocade_tm_default_levels',
102 'snmp_info': (
103 ".1.3.6.1.4.1.1991.1.14.2.1.2.2.1",
105 3, # 'brcdTMStatsDescription',
106 4, # 'brcdTMStatsTotalIngressPktsCnt',
107 5, # 'brcdTMStatsIngressEnqueuePkts',
108 6, # 'brcdTMStatsEgressEnqueuePkts',
109 9, # 'brcdTMStatsIngressDequeuePkts',
110 11, # 'brcdTMStatsIngressTotalQDiscardPkts',
111 13, # 'brcdTMStatsIngressOldestDiscardPkts',
112 15, # 'brcdTMStatsEgressDiscardPkts',