for key in ( 'initial_state', 'flap_detection_options', 'stalking_options' ):
if key in definition:
- array = re.split( r',+', definition[key][0] )
- for value in array:
- try:
- if key in res:
- logger.warn( "Double entry {0} for host definition in {1}({2}).".format( key, definition[key][1], definition[key][2] ) )
- else:
- args = dict( file = definition[key][1], row = definition[key][2], valid_values = set( [ 'o', 'd', 'u' ] ) )
- res[key] = verifier.verify_property( definition[key][0], 'set', args )
- except NagiosVerifyError as e:
- logger.warn( "Property error for host definition in {0}({1}): {2}".format( definition[key][1], definition[key][2], e ) )
+ try:
+ if key in res:
+ logger.warn( "Double entry {0} for host definition in {1}({2}).".format( key, definition[key][1], definition[key][2] ) )
+ else:
+ args = dict( file = definition[key][1], row = definition[key][2], valid_values = set( [ 'o', 'd', 'u' ] ) )
+ res[key] = verifier.verify_property( definition[key][0], 'set', args )
+ except NagiosVerifyError as e:
+ logger.warn( "Property error for host definition in {0}({1}): {2}".format( definition[key][1], definition[key][2], e ) )
for key in ( 'notification_options' ):
if key in definition:
- array = re.split( r',+', definition[key][0] )
- for value in array:
- try:
- if key in res:
- logger.warn( "Double entry {0} for host definition in {1}({2}).".format( key, definition[key][1], definition[key][2] ) )
- else:
- args = dict( file = definition[key][1], row = definition[key][2], valid_values = set( [ 'r', 'd', 'u', 'f', 's' ] ) )
- res[key] = verifier.verify_property( definition[key][0], 'set', args )
- except NagiosVerifyError as e:
- logger.warn( "Property error for host definition in {0}({1}): {2}".format( definition[key][1], definition[key][2], e ) )
+ try:
+ if key in res:
+ logger.warn( "Double entry {0} for host definition in {1}({2}).".format( key, definition[key][1], definition[key][2] ) )
+ else:
+ args = dict( file = definition[key][1], row = definition[key][2], valid_values = set( [ 'r', 'd', 'u', 'f', 's' ] ) )
+ res[key] = verifier.verify_property( definition[key][0], 'set', args )
+ except NagiosVerifyError as e:
+ logger.warn( "Property error for host definition in {0}({1}): {2}".format( definition[key][1], definition[key][2], e ) )
+
+ for key in ( 'max_check_attempts', 'check_interval', 'retry_interval', 'freshness_threshold', 'low_flap_threshold',
+ 'high_flap_threshold', 'notification_interval', 'first_notification_delay', ):
+ if key in definition:
+ try:
+ if key in res:
+ logger.warn( "Double entry {0} for host definition in {1}({2}).".format( key, definition[key][1], definition[key][2] ) )
+ else:
+ args = dict( file = definition[key][1], row = definition[key][2] )
+ res[key] = verifier.verify_property( definition[key][0], 'int', args )
+ except NagiosVerifyError as e:
+ logger.warn( "Property error for host definition in {0}({1}): {2}".format( definition[key][1], definition[key][2], e ) )
if 'host_name' in res:
identifier = res['host_name']
return self.verify_array_property( definition, args )
elif type == "set":
return self.verify_set_property( definition, args )
+ elif type == "int":
+ return self.verify_int_property( definition, args )
raise NagiosVerifyError( "Unknown property type {0!r} given.".format( type ) )
return res
+ #------------------------------------------------------
+ def verify_int_property( self, definition, args = None ):
+
+ if args is None:
+ args = dict()
+
+ match = re.match( r'^(\d+)$', definition )
+ if match is None:
+ raise NagiosVerifyError( "Not a integer value in {0!r}({1}): {2!r}".format( args['file'], args['row'], definition ) )
+
+ val = int( match.group(1) )
+
+ return val
+
#-----------------------------------------------------------------------
# vim: fileencoding=utf-8 filetype=python ts=4 expandtab