From 9ab3a1823a011c4ad0a94c6f58d84a86b97f6a84 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Sun, 21 Nov 2010 18:25:12 +0000 Subject: [PATCH] Bugfixing, Debug-Ausgabe mit pprint git-svn-id: http://svn.brehm-online.com/svn/my-stuff/nagios/trunk@128 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- bin/check_nagios_config.py | 3 ++- bin/nagios/config.py | 11 +++++++---- bin/nagios/config.pyc | Bin 11525 -> 0 bytes bin/nagios/object/host.py | 16 ++++++++-------- 4 files changed, 17 insertions(+), 13 deletions(-) delete mode 100644 bin/nagios/config.pyc diff --git a/bin/check_nagios_config.py b/bin/check_nagios_config.py index dc73f39..070da81 100755 --- a/bin/check_nagios_config.py +++ b/bin/check_nagios_config.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import sys +import pprint from nagios.config import NagiosConfig, NagiosConfigError #print "Modul-Suchpfade:" @@ -23,7 +24,7 @@ except NagiosConfigError as e: #print "Nagios-Objekt: " + repr( nagios_conf ) -print nagios_conf.dump_config() +#print nagios_conf.dump_config() nagios_conf.read_objects() # vim: fileencoding=utf-8 filetype=python ts=4 expandtab diff --git a/bin/nagios/config.py b/bin/nagios/config.py index 0583a48..4130d12 100644 --- a/bin/nagios/config.py +++ b/bin/nagios/config.py @@ -9,6 +9,7 @@ import re import sys import warnings import logging +import pprint import nagios.object.host class NagiosConfigError(Exception): @@ -247,7 +248,9 @@ class NagiosConfig(object): for file_name in files: self.read_objectfile(file_name) - self.logger.debug( "Gelesene Objekte: {0!r}".format( self.objects ) ) + #self.logger.debug( "Gelesene Objekte: {0!r}".format( self.objects ) ) + pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 ) + self.logger.debug( "Gelesene Objekte: {0}".format( pp.pformat( self.objects ) ) ) return @@ -298,9 +301,9 @@ class NagiosConfig(object): self.logger.debug( "Gefunden: key: {0!r}, value: {1!r}".format( key, value ) ) if key in cur_object: self.logger.warn( "Doppelter Eintrag für Eigenschaft {0!r} von {1!r} in {2}({3}).".format( - key, object_type, file_name, row_num ) + key, object_type, file_name, row_num ) ) else: - cur_object[key] = ( value, file, row_num ) + cur_object[key] = ( value, file_name, row_num ) else: @@ -309,7 +312,7 @@ class NagiosConfig(object): in_block = True cur_object = {} object_type = match.group(1).lower() - cur_object['__object_definition__'] = ( file, row_num ) + cur_object['__object_definition__'] = ( file_name, row_num ) self.logger.debug( "Zeile {0} in {1}: Beginne Block vom Type {2!r}".format( row_num, file_name, object_type ) ) continue diff --git a/bin/nagios/config.pyc b/bin/nagios/config.pyc deleted file mode 100644 index ba01b13da679b2d16fadcae4af7cc5c7e4e72df4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11525 zcmb_iO>Z1mc70V%HrW&@l9DKzGqP2ZC5x2Bmd5rVi7b!5D9egu+9}$mOyNk^d zn^nzv)e^71n{`bs=F)RJNXI8vky>C|h zUcO{jO1=DmSsCc%2hB>^G<_2dnKg7Qncp+!sWD%#44dYFi7Kic?AMNP!ll_VCXfFY z|1IW|$S&4facVzIleM^YGt1Jfzg!PbKfuo(M-pM7S{#-YF3s|ponwQ#jevj049p_~xl^rdNh|=s4~EGu%Wp%x5bVvyKxR zQF=`2C@%#!v@*u4Y2sdR-^Wd}tjclI98zY&G*6o5u%4b!zM?!TN7UeyX&zH%$}~rn zIc=I_%1oQ)ab;dI&2eRBO!OnuoX`kAHqA*@o>AoqRldyIJcS+G>qzeKBBS6@Hw*66 zJ2q-}lU7h~x1%grh?79n6es%AUbVS|k)l#-##v6~T#MULZ50x|SE8uq6b&|%h^DLeqegC}M@{(mUxlI6GI* zzdG~3K&F4%JVxlF$6H{=?`2B8%z(*zLSHl zGrPDzJRUVqO6tdzV5l+HavZ4B(k$0&siu%Hn`hmPJk6@oTPI8otL*z|adDRSGiQVO z;Nt9BH)$-YID2unjf+mwx#pZ6wTTz|nr=qc)?4VfI7@KL$B;DYNt(ouq8g<@*SU9# zIa@hYsTKDxS!k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