From 13588d10fdc823621a86f6e322794dce956f3a2a Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Sat, 27 Nov 2010 07:56:59 +0000 Subject: [PATCH] Bugfixing git-svn-id: http://svn.brehm-online.com/svn/my-stuff/nagios/trunk@134 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- bin/nagios/object/host.py | 15 +++++++++++++-- bin/nagios/object/hostgroup.py | 13 ++++++++++++- bin/nagios/object/service.py | 11 +++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/bin/nagios/object/host.py b/bin/nagios/object/host.py index 6bdeded..519c964 100644 --- a/bin/nagios/object/host.py +++ b/bin/nagios/object/host.py @@ -11,7 +11,7 @@ from nagios.object.verify import NagiosVerifyError, NagiosObjectVerifier #----------------------------------------------------------------------- def verify( definition, logger ): - "Verifiziert einen übergebenen Definitionsblock als Nagios-Host." + "Verifying a given definition block as a Nagios host" res = {} identifier = None @@ -84,9 +84,17 @@ define host{ for key in definition: if key == '__object_definition__': + res['__object_definition__'] = definition['__object_definition__'] + continue + if re.match( r'^_', key ): + key_upper = key.upper() + if key_upper in res: + logger.warn( "Double entry {0} for host definition in {1}({2}).".format( key_upper, definition[key][1], definition[key][2] ) ) + else: + res[key_upper] = definition[key][0] continue if not key in valid_keys: - logger.warn( "Ungültige Eigenschaft {0!r} für Hostdefinition in {1}({2}).".format( + logger.warn( "Invalid property {0!r} for host definition in {1}({2}).".format( key, definition[key][1], definition[key][2] ) ) verifier = NagiosObjectVerifier( logger = logger ) @@ -173,6 +181,9 @@ define host{ except NagiosVerifyError as e: logger.warn( "Property error for host definition in {0}({1}): {2}".format( definition[key][1], definition[key][2], e ) ) + if 'register' not in res: + res['register'] = True + if 'host_name' in res: identifier = res['host_name'] elif 'name' in res: diff --git a/bin/nagios/object/hostgroup.py b/bin/nagios/object/hostgroup.py index 39a52ad..029c2cf 100644 --- a/bin/nagios/object/hostgroup.py +++ b/bin/nagios/object/hostgroup.py @@ -11,7 +11,7 @@ from nagios.object.verify import NagiosVerifyError, NagiosObjectVerifier #----------------------------------------------------------------------- def verify( definition, logger ): - "Verifying e given definition block as a Nagios host group" + "Verifying a given definition block as a Nagios host group" res = {} identifier = None @@ -41,6 +41,14 @@ define hostgroup{ for key in definition: if key == '__object_definition__': + res['__object_definition__'] = definition['__object_definition__'] + continue + if re.match( r'^_', key ): + key_upper = key.upper() + if key_upper in res: + logger.warn( "Double entry {0} for hostgroup definition in {1}({2}).".format( key_upper, definition[key][1], definition[key][2] ) ) + else: + res[key_upper] = definition[key][0] continue if not key in valid_keys: logger.warn( "Invalid property {0!r} for hostgroup definition in {1}({2}).".format( @@ -83,6 +91,9 @@ define hostgroup{ except NagiosVerifyError as e: logger.warn( "Property error for host definition in {0}({1}): {2}".format( definition[key][1], definition[key][2], e ) ) + if 'register' not in res: + res['register'] = True + if 'hostgroup_name' in res: identifier = res['hostgroup_name'] elif 'name' in res: diff --git a/bin/nagios/object/service.py b/bin/nagios/object/service.py index 4ccf0e6..c7545f0 100755 --- a/bin/nagios/object/service.py +++ b/bin/nagios/object/service.py @@ -81,6 +81,14 @@ define service{ for key in definition: if key == '__object_definition__': + res['__object_definition__'] = definition['__object_definition__'] + continue + if re.match( r'^_', key ): + key_upper = key.upper() + if key_upper in res: + logger.warn( "Double entry {0} for host definition in {1}({2}).".format( key_upper, definition[key][1], definition[key][2] ) ) + else: + res[key_upper] = definition[key][0] continue if not key in valid_keys: logger.warn( "Invalid Property {0!r} for service definition in {1}({2}).".format( @@ -160,6 +168,9 @@ define service{ except NagiosVerifyError as e: logger.warn( "Property error for service definition in {0}({1}): {2}".format( definition[key][1], definition[key][2], e ) ) + if 'register' not in res: + res['register'] = True + if 'service_description' in res: identifier = res['service_description'] elif 'name' in res: -- 2.39.5