Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / windows_multipath
blobf8373934a9691283fb96e45e0ccafa6d7c9b4d27
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 # Agent output:
28 #<<<windows_multipath>>>
30 # (yes, thats all)
33 def inventory_windows_multipath(info):
34 try:
35 num_active = int(info[0][0])
36 except (ValueError, IndexError):
37 return []
39 if num_active > 0:
40 return [(None, num_active)]
41 return []
44 def check_windows_multipath(item, params, info):
45 num_active = int(info[0][0])
47 yield 0, "Paths active: %s" % (num_active)
49 if isinstance(params, tuple):
50 num_paths, warn, crit = params
51 warn_num = (warn / 100.0) * num_paths
52 crit_num = (crit / 100.0) * num_paths
53 if num_active < crit_num:
54 state = 2
55 elif num_active < warn_num:
56 state = 1
57 else:
58 state = 0
60 if state > 0:
61 yield state, "(warn/crit below %d/%d)" % (warn_num, crit_num)
62 else:
63 if isinstance(params, int):
64 num_paths = params
65 else:
66 num_paths = 4
68 yield 0, "Expected paths: %s" % num_paths
69 if num_active < num_paths:
70 yield 2, "(crit below %d)" % num_paths
71 elif num_active > num_paths:
72 yield 1, "(warn at %d)" % num_paths
75 check_info["windows_multipath"] = {
76 "inventory_function": inventory_windows_multipath,
77 "check_function": check_windows_multipath,
78 "service_description": "Multipath",
79 "group": "windows_multipath",