2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2015 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.
28 # old params = (crit_low , warn_low, warn, crit)
29 def check_humidity(humidity
, params
):
32 "levels_lower": (-1, -1),
35 elif isinstance(params
, (list, tuple)):
37 "levels_lower": (params
[1], params
[0]),
38 "levels": (params
[2], params
[3]),
41 warn_lower
, crit_lower
= params
.get("levels_lower", (None, None))
42 warn_upper
, crit_upper
= params
.get("levels", (None, None))
43 perfdata
= [("humidity", humidity
, warn_upper
, crit_upper
, 0, 100)]
44 infotext
= get_percent_human_readable(humidity
)
46 if warn_lower
is not None and crit_lower
is not None:
47 levelstext_lower
= " (warn/crit below %s/%s)" % (get_percent_human_readable(warn_lower
),
48 get_percent_human_readable(crit_lower
))
49 if warn_upper
is not None and crit_upper
is not None:
50 levelstext_upper
= " (warn/crit at %s/%s)" % (get_percent_human_readable(warn_upper
),
51 get_percent_human_readable(crit_upper
))
55 if crit_lower
is not None and humidity
< crit_lower
:
57 levelstext
= levelstext_lower
59 elif crit_upper
is not None and humidity
>= crit_upper
:
61 levelstext
= levelstext_upper
63 elif warn_lower
is not None and humidity
< warn_lower
:
65 levelstext
= levelstext_lower
67 elif warn_upper
is not None and humidity
>= warn_upper
:
69 levelstext
= levelstext_upper
72 infotext
+= levelstext
74 return status
, infotext
, perfdata