Module: check_mk
Branch: master
Commit: 57bbbdb88fd5a4877b0d7e006c52ab5741ae9702
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=57bbbdb88fd5a4…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Tue Mar 8 13:18:29 2016 +0100
3093 isc_dhcpd: now interprets include statements when parsing the configuration file
---
.werks/3093 | 10 ++++++++++
ChangeLog | 1 +
agents/plugins/isc_dhcpd | 18 +++++++++++++-----
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/.werks/3093 b/.werks/3093
new file mode 100644
index 0000000..5f958b1
--- /dev/null
+++ b/.werks/3093
@@ -0,0 +1,10 @@
+Title: isc_dhcpd: now interprets include statements when parsing the configuration file
+Level: 1
+Component: checks
+Class: feature
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457439448
+
+
diff --git a/ChangeLog b/ChangeLog
index 5881654..59a564f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@
* 3257 dell_idrac_virtdisks: new check which monitors the virtual disks of a Dell
IDrac Device
* 3001 fileinfo: now able to configure the checks status if the file is missing
* 3088 rstcli, rstcli.pdisks: new checks to monitor Intel RST raids
+ * 3093 isc_dhcpd: now interprets include statements when parsing the configuration
file
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/agents/plugins/isc_dhcpd b/agents/plugins/isc_dhcpd
index 87af321..3278460 100755
--- a/agents/plugins/isc_dhcpd
+++ b/agents/plugins/isc_dhcpd
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import os, sys, time, calendar
+import os, sys, time, re, calendar
conf_file = None
for path in [ '/etc/dhcpd.conf', '/etc/dhcp/dhcpd.conf',
'/usr/local/etc/dhcpd.conf' ]:
@@ -27,10 +27,18 @@ pidof_dhcpd = os.popen("pidof dhcpd").read().strip()
sys.stdout.write('<<<isc_dhcpd>>>\n[general]\nPID: %s\n' %
pidof_dhcpd)
sys.stdout.write('[pools]\n')
-for line in file(conf_file):
- line = line.strip().rstrip(";").rstrip()
- if line.startswith("range"):
- sys.stdout.write(line[5:].strip() + "\n")
+
+
+def parse_config(filename):
+ for line in file(filename):
+ if line.startswith("include"):
+ included_file = re.search('include\s+"(.*)"',
line).group(1)
+ parse_config(included_file)
+ elif line.startswith("range"):
+ sys.stdout.write(line[5:].strip() + "\n")
+
+parse_config(conf_file)
+
# lease 10.1.1.81 {
# starts 3 2015/09/09 11:42:20;