def method_last_72_hours(): global guhHost global guhPort params = logs.create_last_time_logfilter(72 * 60) print "\nThe filter:\n" guh.print_json_format(params) guh.debug_stop() if params: logs.log_window(guhHost, guhPort, params)
def method_rule_logs(): global guhHost global guhPort params = logs.create_rule_logfilter() print "\nThe filter:\n" guh.print_json_format(params) guh.debug_stop() if params: logs.log_window(guhHost, guhPort, params)
def create_logfilter(): params = {} boolTypes = ["yes","no"] # Devices selection = guh.get_selection("Do you want to filter for \"Devices\"? ", boolTypes) if boolTypes[selection] == "yes": deviceIds = [] deviceId = devices.select_configured_device() deviceIds.append(deviceId) finished = False while not finished: selection = guh.get_selection("Do you want to add an other \"Device\"? ", boolTypes) if boolTypes[selection] == "no": finished = True break deviceId = devices.select_configured_device() if not deviceId: params['deviceIds'] = deviceIds return params deviceIds.append(deviceId) params['deviceIds'] = deviceIds # LoggingSources selection = guh.get_selection("Do you want to filter for \"LoggingSource\"? ", boolTypes) if boolTypes[selection] == "yes": sources = [] finished = False loggingSources = ["LoggingSourceSystem", "LoggingSourceEvents", "LoggingSourceActions", "LoggingSourceStates", "LoggingSourceRules"] selection = guh.get_selection("Please select a \"LoggingSource\": ", loggingSources) if selection: sources.append(loggingSources[selection]) else: finished = True while not finished: selection = guh.get_selection("Do you want to add an other \"LoggingSource\"? ", boolTypes) if boolTypes[selection] == "no": finished = True break selection = get_selection("Please select a \"LoggingSource\": ", loggingSources) if selection: sources.append(loggingSources[selection]) else: finished = True break params['loggingSources'] = sources # LoggingLevel selection = guh.get_selection("Do you want to filter for \"LoggingLevel\"? ", boolTypes) if boolTypes[selection] == "yes": levels = [] loggingLevels = ["LoggingLevelInfo", "LoggingLevelAlert"] selection = guh.get_selection("Please select a \"LoggingLevel\": ", loggingLevels) if selection: levels.append(loggingLevels[selection]) params['loggingLevels'] = levels # LoggingEventType selection = guh.get_selection("Do you want to filter for \"LoggingEventType\"? ", boolTypes) if boolTypes[selection] == "yes": types = [] loggingEventTypes = ["LoggingEventTypeTrigger", "LoggingEventTypeActiveChange", "LoggingEventTypeEnabledChange", "LoggingEventTypeActionsExecuted", "LoggingEventTypeExitActionsExecuted"] selection = guh.get_selection("Please select a \"LoggingEventType\": ", loggingEventTypes) if selection: types.append(loggingEventTypes[selection]) params['eventTypes'] = types # Value selection = guh.get_selection("Do you want to filter for certain log \"Values\"? ", boolTypes) if boolTypes[selection] == "yes": values = [] finished = False value = raw_input("Please enter value which should be filtered out: ") values.append(value) while not finished: selection = guh.get_selection("Do you want to add an other \"Value\"? ", boolTypes) if boolTypes[selection] == "no": finished = True break value = raw_input("Please enter value which should be filtered out: ") values.append(value) params['values'] = values # Times selection = guh.get_selection("Do you want to add a \"TimeFilter\"? ", boolTypes) if boolTypes[selection] == "yes": timeFilters = [] finished = False timeFilters.append(create_time_filter()) while not finished: selection = guh.get_selection("Do you want to add an other \"TimeFilter\"? ", boolTypes) if boolTypes[selection] == "no": finished = True break timeFilters.append(create_time_filter()) params['timeFilters'] = timeFilters guh.print_json_format(params) guh.debug_stop() return params