Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / kemp_loadmaster_services
blob8a23c1d63e403c5c09bda9e8d6c1adb05bf769fa
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 # .1.3.6.1.4.1.12196.13.1.1.13.1 Exchange HTTPS
28 # .1.3.6.1.4.1.12196.13.1.1.13.3 Exchange MAPI
29 # .1.3.6.1.4.1.12196.13.1.1.13.4 Exchange SMTP
30 # .1.3.6.1.4.1.12196.13.1.1.13.5 Lync Internal WebSvc HTTP
31 # .1.3.6.1.4.1.12196.13.1.1.13.6 Lync Internal WebSvc HTTPS
32 # .1.3.6.1.4.1.12196.13.1.1.14.1 1
33 # .1.3.6.1.4.1.12196.13.1.1.14.3 1
34 # .1.3.6.1.4.1.12196.13.1.1.14.4 1
35 # .1.3.6.1.4.1.12196.13.1.1.14.5 1
36 # .1.3.6.1.4.1.12196.13.1.1.14.6 1
37 # .1.3.6.1.4.1.12196.13.1.1.21.1 882
38 # .1.3.6.1.4.1.12196.13.1.1.21.3 6386
39 # .1.3.6.1.4.1.12196.13.1.1.21.4 3
40 # .1.3.6.1.4.1.12196.13.1.1.21.5 1
41 # .1.3.6.1.4.1.12196.13.1.1.21.6 1
43 # Some devices provide strange, wrong or incomplete data
44 # and it's not possible to exclude them via std. OIDs
45 # .1.3.6.1.4.1.12196.13.1.1.13.1 lbwebinterface --> B100-MIB::vSname.1
46 # .1.3.6.1.4.1.12196.13.1.1.13.2 --> B100-MIB::vSname.2
47 # .1.3.6.1.4.1.12196.13.1.1.13.3 --> B100-MIB::vSname.3
48 # .1.3.6.1.4.1.12196.13.1.1.14.1 LB_WI --> B100-MIB::vSstate.1
49 # .1.3.6.1.4.1.12196.13.1.1.14.2 --> B100-MIB::vSstate.2
50 # .1.3.6.1.4.1.12196.13.1.1.14.3 CAG_LB --> B100-MIB::vSstate.3
52 kemp_loadmaster_service_default_levels = (1500, 2000)
55 def parse_kemp_loadmaster_services(info):
56 parsed = {}
57 for name, status, conns in info:
58 if name == "" or len(status) > 1:
59 continue
61 inst = parsed.setdefault(name, {"device_state": status})
62 try:
63 inst.update({"conns": int(conns)})
64 except ValueError:
65 pass
66 return parsed
69 def inventory_kemp_loadmaster_services(parsed):
70 for item, iteminfo in parsed.items():
71 if iteminfo["device_state"] not in ["4", ""]:
72 yield item, kemp_loadmaster_service_default_levels
75 def check_kemp_loadmaster_services(item, _no_params, parsed):
76 map_states = {
77 "1": (0, 'in service'),
78 "2": (2, 'out of service'),
79 "3": (2, 'failed'),
80 "4": (3, 'disabled'),
81 "5": (1, 'sorry'),
82 "6": (0, 'redirect'),
83 "7": (2, 'error message'),
86 if item in parsed:
87 data = parsed[item]
88 state, state_readable = map_states[data["device_state"]]
89 yield state, "Status: %s" % state_readable
90 conns = data.get("conns")
91 if conns is not None:
92 yield 0, "Active connections: %s" % conns, [('conns', conns)]
95 check_info["kemp_loadmaster_services"] = {
96 "parse_function" : parse_kemp_loadmaster_services,
97 "inventory_function" : inventory_kemp_loadmaster_services,
98 "check_function" : check_kemp_loadmaster_services,
99 "service_description" : "Service %s",
100 "has_perfdata" : True,
101 "snmp_info" : ( ".1.3.6.1.4.1.12196.13.1.1", [
102 "13", # B100-MIB::vSname
103 "14", # B100-MIB::vSstate
104 "21", # B100-MIB::conns
106 "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.12196.250.10" or \
107 oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.2021.250.10",