2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 from agent:
28 # <<<ibm_svc_host:sep(58)>>>
29 # 0:h_esx01:2:4:degraded
30 # 1:host206:2:2:online
31 # 2:host105:2:2:online
32 # 3:host106:2:2:online
35 def inventory_ibm_svc_host(info
):
39 def check_ibm_svc_host(item
, params
, info
):
47 # Old inventory rule until version 1.2.7
48 # params were None instead of empty dictionary
49 params
= {'always_ok': False}
52 if line
[4] == 'degraded':
54 elif line
[4] == 'offline':
56 elif line
[4] == 'active' or line
[4] == 'online':
58 elif line
[4] == 'inactive':
63 if 'always_ok' in params
:
64 # Old configuration rule
65 # This was used with only one parameter always_ok until version 1.2.7
68 ("inactive", inactive
),
69 ("degraded", degraded
),
73 yield 0, "%s active, %s inactive" % (active
, inactive
), perfdata
76 yield (not params
['always_ok'] and 1 or 0), "%s degraded" % degraded
78 yield (not params
['always_ok'] and 2 or 0), "%s offline" % offline
80 yield (not params
['always_ok'] and 1 or 0), "%s in an unidentified state" % other
82 warn
, crit
= params
.get('active_hosts', (None, None))
84 if crit
is not None and active
<= crit
:
85 yield 2, "%s active" % active
86 elif warn
is not None and active
<= warn
:
87 yield 1, "%s active" % active
89 yield 0, "%s active" % active
92 ('inactive', inactive
),
93 ('degraded', degraded
),
97 warn
, crit
= params
.get(ident
+ '_hosts', (None, None))
99 if crit
is not None and value
>= crit
:
101 if warn
is not None and value
>= warn
:
105 yield state
, "%s %s" % (value
, ident
), [(ident
, value
, warn
, crit
)]
108 check_info
["ibm_svc_host"] = {
109 "check_function": check_ibm_svc_host
,
110 "inventory_function": inventory_ibm_svc_host
,
111 "service_description": "Hosts",
112 "has_perfdata": True,
113 "group": "ibm_svc_host",