Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / checkpoint_ha_status
blob6c8b5f6a5ea78ac22f0552a45e6ecbf90fb1c1e7
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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.2620.1.5.2.0 1
28 # .1.3.6.1.4.1.2620.1.5.3.0 6
29 # .1.3.6.1.4.1.2620.1.5.4.0 0
30 # .1.3.6.1.4.1.2620.1.5.5.0 yes
31 # .1.3.6.1.4.1.2620.1.5.6.0 active
32 # .1.3.6.1.4.1.2620.1.5.7.0 OK
33 # .1.3.6.1.4.1.2620.1.5.101.0 0
34 # .1.3.6.1.4.1.2620.1.5.103.0
37 def inventory_checkpoint_ha_status(info):
38 installed, _major, _minor, _started, _state, _block_state, _stat_code, _stat_long = info[0]
39 if installed != "0":
40 return [(None, None)]
43 def check_checkpoint_ha_status(_no_item, _no_params, info):
44 installed, major, minor, started, state, block_state, stat_code, stat_long = info[0]
46 # Some devices have a trailing "\n" in the state field. Drop it.
47 state = state.rstrip()
49 if installed == "0":
50 yield 2, "Not installed"
51 else:
52 yield 0, "Installed: v%s.%s" % (major, minor)
54 for val, infotext, ok_vals, warn_vals in [(started, "Started", ["yes"], None),
55 (state, "Status", ["active", "standby"], None),
56 (block_state, "Blocking", ["ok"],
57 ["initializing"])]:
58 if ok_vals is None or val.lower() in ok_vals:
59 status = 0
60 elif warn_vals is not None and val.lower() in warn_vals:
61 status = 1
62 else:
63 status = 2
65 yield status, "%s: %s" % (infotext, val)
67 if stat_code != "0":
68 yield 2, "Problem: %s" % stat_long
71 check_info['checkpoint_ha_status'] = {
72 'check_function': check_checkpoint_ha_status,
73 'inventory_function': inventory_checkpoint_ha_status,
74 'service_description': "HA Status",
75 'snmp_scan_function': scan_checkpoint,
76 'snmp_info': (
77 '.1.3.6.1.4.1.2620.1.5',
79 2, # haInstalled
80 3, # haVerMajor
81 4, # haVerMinor
82 5, # haStarted
83 6, # haState
84 7, # haBlockState
85 101, # haStatCode
86 103, # haStatLong
87 ]),
88 'includes': ['checkpoint.include'],