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 isc_dhcpd_default_levels
= (15.0, 5.0)
29 # Example output from agent:
48 def parse_isc_dhcpd(info
):
52 for part
in ip
.split('.')[::-1]:
53 number
+= factor
* int(part
)
65 if line
[0] == '[general]':
67 elif line
[0] == '[pools]':
69 elif line
[0] == '[leases]':
72 elif mode
== "general":
74 parsed
["pids"] = map(int, line
[1:])
77 if 'bootp' in line
[0]:
79 start
, end
= line
[0], line
[1]
80 item
= "%s-%s" % (start
, end
)
81 parsed
["pools"][item
] = (ip_to_number(start
), ip_to_number(end
))
83 elif mode
== "leases":
84 parsed
["leases"].append(ip_to_number(line
[0]))
89 def inventory_isc_dhcpd(parsed
):
90 return [(item
, "isc_dhcpd_default_levels") for item
in parsed
["pools"]]
93 def check_isc_dhcpd(item
, params
, parsed
):
94 if len(parsed
["pids"]) == 0:
95 yield 2, "DHCP Daemon not running"
96 elif len(parsed
["pids"]) > 1:
97 yield 1, "DHCP Daemon running %d times (PIDs: %s)" % (len(parsed
["pids"]), ", ".join(
98 map(str, parsed
["pids"])))
100 if item
not in parsed
["pools"]:
103 range_from
, range_to
= parsed
["pools"][item
]
104 num_leases
= range_to
- range_from
+ 1
106 for lease_dec
in parsed
["leases"]:
107 if lease_dec
>= range_from
and lease_dec
<= range_to
:
110 for check_result
in check_dhcp_pools_levels(num_leases
- num_used
, num_used
, None, num_leases
,
115 check_info
["isc_dhcpd"] = {
116 'parse_function': parse_isc_dhcpd
,
117 'inventory_function': inventory_isc_dhcpd
,
118 'check_function': check_isc_dhcpd
,
119 'service_description': 'DHCP Pool %s',
120 'group': 'win_dhcp_pools',
121 'has_perfdata': True,
122 'includes': ["dhcp_pools.include"],