key_def = {
'host': {
- 'host_name': ( 'string', None ),
- 'alias': ( 'string', None ),
+ 'host_name': ( 'string', { 'mandantory': True } ),
+ 'alias': ( 'string', { 'mandantory': True } ),
'display_name': ( 'string', None ),
- 'address': ( 'string', None ),
+ 'address': ( 'string', { 'mandantory': True } ),
'parents': ( 'array', None ),
'hostgroups': ( 'array', None ),
'check_command': ( 'string', None ),
'initial_state': ( 'set', { 'valid_values': set( [ 'o', 'd', 'u' ] ) } ),
- 'max_check_attempts': ( 'int', None ),
+ 'max_check_attempts': ( 'int', { 'mandantory': True } ),
'check_interval': ( 'int', None ),
'retry_interval': ( 'int', None ),
'normal_check_interval': ( 'int', { 'deprecated': True, } ),
'retry_check_interval': ( 'int', { 'deprecated': True, } ),
'active_checks_enabled': ( 'bool', None ),
'passive_checks_enabled': ( 'bool', None ),
- 'check_period': ( 'string', None ),
+ 'check_period': ( 'string', { 'mandantory': True } ),
'failure_prediction_enabled': ( 'bool', None ),
'obsess_over_host': ( 'bool', None ),
'check_freshness': ( 'bool', None ),
'process_perf_data': ( 'bool', None ),
'retain_status_information': ( 'bool', None ),
'retain_nonstatus_information': ( 'bool', None ),
- 'contacts': ( 'array', None ),
- 'contact_groups': ( 'array', None ),
- 'notification_interval': ( 'int', None ),
+ 'contacts': ( 'array', { 'mandantory': True } ),
+ 'contact_groups': ( 'array', { 'mandantory': True } ),
+ 'notification_interval': ( 'int', { 'mandantory': True } ),
'first_notification_delay': ( 'int', None ),
- 'notification_period': ( 'string', None ),
+ 'notification_period': ( 'string', { 'mandantory': True } ),
'notification_options': ( 'set', { 'valid_values': set( [ 'd', 'u', 'r', 'f', 's' ] ) } ),
'notifications_enabled': ( 'bool', None ),
'stalking_options': ( 'set', { 'valid_values': set( [ 'o', 'd', 'u' ] ) } ),
if key not in key_def[object_type]:
return None
- return key_def[object_type][key]
+ test_type = key_def[object_type][key][0]
+ test_args = key_def[object_type][key][1]
+
+ if test_args is None:
+ test_args = {}
+
+ if not 'deprecated' in test_args:
+ test_args['deprecated'] = False
+
+ if not 'mandantory' in test_args:
+ test_args['mandantory'] = False
+
+ return ( test_type, test_args )
#------------------------------------------------------
def check_timeperiod_line_syntax( self, line ):
re_timeranges = r'(' + re_timerange + r')(?:,(' + re_timerange + r'))*'
re_weekdays = r'(monday|tuesday|wednesday|thursday|friday|saturday|sunday)'
re_isodate = r'(\d\d\d\d)-(0[1-9]|1[0-2])-([0-2][1-9]|3[01])'
+ re_monthname = r'(january|ferbruary|march|april|may|june|july|august|september|october|november|december)'
pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 )
# first search for a simple weekday
regex = r'^' + re_weekdays + r'\s+' + re_timeranges + r'$'
- #self.logger.debug( "Timeperiod Regex {0!r}.\n\t{1!r}".format( regex, line ) )
+ if self.verbose >= 4:
+ self.logger.debug( "Timeperiod Regex {0!r}.\n\t{1!r}".format( regex, line ) )
match = re.search( regex, line )
if match is not None:
return ( key, value )
# Now search single ISO formatted date or a range of two ISO formatted dates
- regex = r'^' + re_isodate + r'(?:\s*-\s*' + re_isodate + r')?\s+' + re_timeranges + r'$'
- self.logger.debug( "Timeperiod Regex {0!r}.\n\t{1!r}".format( regex, line ) )
+ regex = r'^' + re_isodate + r'(?:\s*-\s*' + re_isodate + r')?(?:\s*/\s*(\d+))\s+' + re_timeranges + r'$'
+ if self.verbose >= 3:
+ self.logger.debug( "Timeperiod Regex {0!r}.\n\t{1!r}".format( regex, line ) )
match = re.search( regex, line )
if match is not None:
key = key + ' - ' + date_end.isoformat()
+ if match.group(7) is not None:
+ key = key + ' / ' + match.group(7)
+
# Formatting the value ...
value = []
- for v in match.groups()[6:-1]:
+ for v in match.groups()[7:-1]:
value.append(v)
return ( key, value )