]> Frank Brehm's Git Trees - my-stuff/nagios.git/commitdiff
Bugfixing
authorFrank Brehm <frank@brehm-online.com>
Wed, 15 Dec 2010 22:50:48 +0000 (22:50 +0000)
committerFrank Brehm <frank@brehm-online.com>
Wed, 15 Dec 2010 22:50:48 +0000 (22:50 +0000)
git-svn-id: http://svn.brehm-online.com/svn/my-stuff/nagios/trunk@159 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa

bin/nagios/config.py

index 008462064c7bc6549ee0f532e77b978c79eac72c..805b601c8b4cb0cedb10b466c4ed082050ee2737 100644 (file)
@@ -349,37 +349,65 @@ class NagiosConfig(LoggingObject):
         @rtype: list
         '''
 
+        pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 )
+
+        if self.verbose >= 5:
+            self.logger.debug( "Analyze object:\n\t{0}".format( pp.pformat( object ) ) )
+
+        object_file = object['__object_definition__'][0]
+        object_rownum = object['__object_definition__'][1]
+
+        if object_type == 'contact' and self.verbose >= 4:
+            name = 'anonymous'
+            if 'contact_name' in object:
+                name = "'contact_name': " + object['contact_name'][0]
+            elif 'name' in object:
+                name = "'name': " + object['name'][0]
+            self.logger.debug( "Analyze Contact {0!r} from {1!r}({2}) ...".format( name, object_file, object_rownum ) )
+
         if not 'use' in object:
+            if self.verbose >= 4:
+                self.logger.debug( "No 'use' in object." )
             return []
 
         file    = object['use'][1]
         row_num = object['use'][2]
 
-        pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 )
         if 'templates' in object:
-            self.logger.debug( "Templates allready found, returning:\n\t{0}".format( pp.pformat( object['templates'] ) ) )
+            if self.verbose >= 4:
+                self.logger.debug( "Templates allready found, returning:\n\t{0}".format( pp.pformat( object['templates'] ) ) )
             return object['templates']
 
+        if self.verbose >= 4:
+            self.logger.debug( "No templates found, go on ..." )
+
         object['templates'] = []
         object['templates_applied'] = set([])
 
         for template_name in object['use'][0]:
+            if self.verbose >= 4:
+                self.logger.debug( "Looking for template {0!r} ...".format( template_name ) )
             if not template_name in self.templates[object_type]:
                 raise NagiosConfigError( "Template {0!r} for {1!r} in {2!r}({3}) not found.".format( template_name, object_type, file, row_num ) )
             template_id = self.templates[object_type][template_name]
+            if self.verbose >= 4:
+                self.logger.debug( "Found ID {0} for template {1!r}.".format( template_id, template_name ) )
             template_object = self.objects_read[object_type][template_id]
             names = [ template_name ]
-            for name in self._retrieve_templates( object_type, template_name ):
+            for name in self._retrieve_templates( object_type, template_object ):
                 names.append( name )
             for name in names:
-                self.logger.debug( "Assigning template {0!r}.".format( name ) )
+                if self.verbose >= 4:
+                    self.logger.debug( "Assigning template {0!r}.".format( name ) )
                 if name in object['templates_applied']:
-                    self.logger.debug( "Template {0!r} for {1!r} allready applied.".format( name, object_type ) )
+                    if self.verbose >= 3:
+                        self.logger.debug( "Template {0!r} for {1!r} allready applied.".format( name, object_type ) )
                 else:
                     object['templates'].append( name )
                     object['templates_applied'].add( name )
 
-        self.logger.debug( "Templates returning:\n\t{0}".format( pp.pformat( object['templates'] ) ) )
+        if self.verbose >= 4:
+            self.logger.debug( "Templates returning:\n\t{0}".format( pp.pformat( object['templates'] ) ) )
         return object['templates']
 
     #------------------------------------------------------