From df71d563a9b82e08807e1e3603ae15fbd4ae1bae Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 23 Jul 2009 01:36:44 +0000 Subject: 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 --- src/lib/Server/Plugins/NagiosGen.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/lib/Server') 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()] -- cgit v1.2.3-1-g7c22