GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / acme_sbc_snmp
blobd800b848dda61b42437ec2631e18bc37375c79ac
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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.
27 # comNET GmbH, Fabian Binder
29 # .1.3.6.1.4.1.9148.3.2.1.1.3 Health Score (apSysHealthScore)
30 # .1.3.6.1.4.1.9148.3.2.1.1.4 Health Status Description (apSysRedundancy)
32 factory_settings["acme_sbc_snmp_default_levels"] = {
33 "levels_lower": (99, 75),
37 def inventory_acme_sbc_snmp(info):
38 yield None, {}
41 def check_acme_sbc_snmp(_no_item, params, info):
42 map_states = {
43 "0": (3, "unknown"),
44 "1": (1, "initial"),
45 "2": (0, "active"),
46 "3": (0, "standby"),
47 "4": (2, "out of service"),
48 "5": (2, "unassigned"),
49 "6": (1, "active (pending)"),
50 "7": (1, "standby (pending)"),
51 "8": (1, "out of service (pending)"),
52 "9": (1, "recovery"),
55 try:
56 score, state = info[0]
57 except (IndexError, ValueError):
58 return
59 health_state, health_state_readable = map_states.get(state, (3, "unknown"))
60 yield health_state, "Health state: %s" % (health_state_readable)
62 try:
63 score = int(score)
64 except ValueError:
65 yield 3, "Unknown score: %s" % score
66 return
67 warn, crit = params.get("levels_lower", (None, None))
68 levels_msg = " (warn/crit at or below %s%%/%s%%)" % (warn, crit)
69 score_msg = "Score: %s%%" % score
70 if crit is not None and score <= crit:
71 yield 2, score_msg + levels_msg
72 elif warn is not None and score <= warn:
73 yield 1, score_msg + levels_msg
74 else:
75 yield 0, score_msg
78 check_info['acme_sbc_snmp'] = {
79 'inventory_function': inventory_acme_sbc_snmp,
80 'check_function': check_acme_sbc_snmp,
81 'service_description': 'ACME SBC health',
82 'snmp_info': (
83 '.1.3.6.1.4.1.9148.3.2.1.1',
85 "3", # APSYSMGMT-MIB::apSysHealthScore
86 "4", # APSYSMGMT-MIB::apSysRedundancy
87 ]),
88 'snmp_scan_function': scan_acme,
89 'includes': ['acme.include'],
90 'group': 'acme_sbc_snmp',
91 'default_levels_variable': 'acme_sbc_snmp_default_levels',