summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2013-01-09 14:57:36 -0600
committerSol Jerome <sol.jerome@gmail.com>2013-01-09 14:57:36 -0600
commit590a1314bca44f29fc34bd27f0d49599b7eeab10 (patch)
tree7fa1e1af0b536c600f44d0cf3ab8e61283720404 /src
parent09e919aad1ad23e29ff9b88289a546184628e187 (diff)
downloadbcfg2-590a1314bca44f29fc34bd27f0d49599b7eeab10.tar.gz
bcfg2-590a1314bca44f29fc34bd27f0d49599b7eeab10.tar.bz2
bcfg2-590a1314bca44f29fc34bd27f0d49599b7eeab10.zip
NagiosGen: Fix faulty configuration (from Marc GariƩpy)
We previously added all configuration to the generated Nagios configuration resulting in Nagios errors when parts of the configuration were unused. Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/NagiosGen.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
index 023547b7e..c39bd4c42 100644
--- a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
+++ b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
@@ -104,9 +104,17 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin,
for host in host_configs:
host_data.append(open(host, 'r').read())
+ group_list = []
+ for line in "\n".join(host_data).splitlines():
+ # only include those groups which are actually used
+ if "hostgroup" in line:
+ group_list += line.split()[1].split(',')
+
+ group_list = list(set(group_list))
+
for group in group_configs:
group_name = re.sub("(-group.cfg|.*/(?=[^/]+))", "", group)
- if "\n".join(host_data).find(group_name) != -1:
+ if group_name in group_list:
groupfile = open(group, 'r')
group_data.append(groupfile.read())
groupfile.close()