summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-07-23 01:36:44 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-07-23 01:36:44 +0000
commitdf71d563a9b82e08807e1e3603ae15fbd4ae1bae (patch)
tree59e41bebece819d9428cc4b33b3ff162c2e31e34 /src/lib
parent92406467032682c8b0bdbb67576bbe177c4e868f (diff)
downloadbcfg2-df71d563a9b82e08807e1e3603ae15fbd4ae1bae.tar.gz
bcfg2-df71d563a9b82e08807e1e3603ae15fbd4ae1bae.tar.bz2
bcfg2-df71d563a9b82e08807e1e3603ae15fbd4ae1bae.zip
NagiosGen: Add support for properties driven monitoring configurations (Patch from Nico Halpern)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5379 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Plugins/NagiosGen.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/Server/Plugins/NagiosGen.py b/src/lib/Server/Plugins/NagiosGen.py
index 7dfaef125..3eba10da8 100644
--- a/src/lib/Server/Plugins/NagiosGen.py
+++ b/src/lib/Server/Plugins/NagiosGen.py
@@ -8,10 +8,9 @@ LOGGER = logging.getLogger('Bcfg2.Plugins.NagiosGen')
host_config_fmt = \
'''
define host{
-use default
-host_name %s
-alias %s
-address %s
+ host_name %s
+ alias %s
+ address %s
'''
class NagiosGen(Bcfg2.Server.Plugin.Plugin,
@@ -41,9 +40,20 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin,
os.path.isfile('%s/%s-group.cfg' % (self.data, grp))]
host_config = host_config_fmt % \
(metadata.hostname, metadata.hostname, host_address )
+
if host_groups:
- host_config += ' hostgroups %s\n' % (",".join(host_groups))
- host_config += ' }\n'
+ host_config += ' hostgroups %s\n' % (",".join(host_groups))
+
+ if 'NagiosGen.xml' in metadata.Properties and \
+ metadata.Properties['NagiosGen.xml'].data.find(metadata.hostname) is not None:
+ directives = list (metadata.Properties['NagiosGen.xml'].data.find(metadata.hostname))
+ for item in directives:
+ host_config += ' %-32s %s\n' % ( item.tag, item.text )
+
+ else:
+ host_config += ' use default\n'
+
+ host_config += '}\n'
entry.text = host_config
[entry.attrib.__setitem__(key, value) for \
(key, value) in self.client_attrib.iteritems()]