def check_monitors(config_obj): send_success = False for monitor in config_obj['monitor']: #find send_to object log_destination_config = {} for connection in config_obj['settings']['connections']: if connection['name'] == monitor["send_to"]: log_destination_config = connection break # Proccess the various supported log types if monitor["type"] == "apache access combined": log_lines = log_tools.read_line_delimited_file(monitor) # Parse Apache access combined log_list = apache_tools.read_apache_logfile(log_lines, 0) line_count = 0 for log_entry in log_list: send_success = proccess_event(monitor, log_destination_config, log_entry) line_count = line_count + 1 elif monitor["type"] == "delimited file": try: log_lines = log_tools.read_line_delimited_file(monitor) log_list = log_tools.parse_delimited_file(log_lines, monitor) send_success = sql_connector.send_data_to_sql( log_list, log_destination_config) except Exception as e: print("Error reading delimited file: %s" % (str(e))) if send_success == True: config_save(config_obj)
def test_apache(): script_dir = os.path.dirname(__file__) log_file = "test logs/Apache-WordPress.log" file_path = os.path.join(script_dir, log_file) log_list = apache_tools.read_apache_logfile(file_path) for l in log_list: r = l["resource"] vs = apache_tools.read_variables(r) print (str(vs))
def test_apache(): script_dir = os.path.dirname(__file__) log_file = "test logs/Apache-WordPress.log" file_path = os.path.join(script_dir, log_file) log_list = apache_tools.read_apache_logfile(file_path) for l in log_list: r = l["resource"] vs = apache_tools.read_variables(r) print(str(vs))
def check_monitors(config_obj): for monitor in config_obj.log_monitors: if monitor["type"] == "apache access combined": log_lines = log_tools.read_single_line_log_file(monitor["location"]) # Check to see if log was rotated if len(log_lines) < monitor["last_line_read"]: monitor["last_line_read"] = 0 print ("Log Rotated: %s" % str(monitor["location"])) # Parse Apache access combined log_list = apache_tools.read_apache_logfile(log_lines, monitor["last_line_read"]) line_count = 0 for log_entry in log_list: post_success = proccess_event(monitor["host_id"], monitor, log_entry) line_count = line_count + 1 config_obj.write_config()