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.
29 # 'free_leases' : (warn, crit),
30 # 'used_leases' : (warn, crit),
34 def check_dhcp_pools_levels(free
, used
, pending
, size
, params
):
35 if isinstance(params
, tuple):
36 # In case of win_dhcp_pools old params are percent but of type
37 # integer, thus we have to change them into floats
38 params
= {"free_leases": (float(params
[0]), float(params
[1]))}
40 for what
, value
in [("free", free
), ("used", used
)]:
47 value_perc
= float(value
) / size
* 100.0
49 infotext
= "%s: %d leases (%.1f%%)" % (what
, value
, value_perc
)
50 if params
.get("%s_leases" % what
, ""):
51 warn
, crit
= params
["%s_leases" % what
]
52 if isinstance(warn
, float): # here we have levels in percent
56 warn_abs
= int(size
* (warn
/ 100.0))
57 crit_abs
= int(size
* (crit
/ 100.0))
58 else: # otherwise we use absolute values as integers
60 unit
= " %s pool entries" % what
70 infotext_format
= " (warn/crit below " + text_format
+ "/" + text_format
+ unit
+ ")"
71 infotext
+= infotext_format
% (warn
, crit
)
77 yield state
, infotext
, [("%s_dhcp_leases" % what
, value_abs
, warn_abs
, crit_abs
, 0, size
)]
79 if pending
is not None:
80 yield 0, "%d leases pending" % pending
, [("pending_dhcp_leases", pending
, None, None, 0,