Cleanup config.nodes_of
[check_mk.git] / checks / solaris_multipath
blob7bc3da80794f26e749e5b50831ab8be4665c6c1b
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 # Example output:
28 # <<<solaris_multipath>>>
29 # /dev/rdsk/c4t600601608CB02A00DCFD2EEB19A0E111d0s2 4 4
31 # Note: the number of total paths is not correct. After maintainance
32 # they is too high. Also in case of broken paths the number of total
33 # paths sometimes changes. So we just use that for informational
34 # output. The discovery remembers the number of operational paths
35 # and we check agains that later.
38 def inventory_solaris_multipath(info):
39 for device, _total, operational in info:
40 item = device.split('/')[-1]
41 yield item, int(operational)
44 def check_solaris_multipath(item, params, info):
45 for device, total, operational in info:
46 if item == device.split('/')[-1]:
48 operational = int(operational)
49 total = int(total)
51 infotext = "%d paths operational, %d paths total" % (operational, total)
53 if not params:
54 state = 1
55 infotext += ", expected paths unknown, please redo service discovery"
56 else:
57 if isinstance(params, tuple):
58 warn, crit = params
59 warn_num = (warn / 100.0) * total
60 crit_num = (crit / 100.0) * total
61 levels = " (Warning/ Critical at %d/ %d)" % (warn_num, crit_num)
62 info = "paths active: %d" % (operational)
63 if operational <= crit_num:
64 return 2, info + levels
65 elif operational <= warn_num:
66 return 1, info + levels
67 return 0, info
68 else:
69 expected = int(params) # should be int, just for legacy reasons
70 if operational > expected:
71 state = 1
72 elif expected == operational:
73 state = 0
74 elif expected >= operational * 2: # less than half of paths operational
75 state = 2
76 else:
77 state = 1
78 if state:
79 infotext += ", %d paths expected to be operational" % expected
81 return state, infotext
84 check_info["solaris_multipath"] = {
85 "inventory_function": inventory_solaris_multipath,
86 "check_function": check_solaris_multipath,
87 "service_description": "Multipath %s",
88 "group": "multipath"