# Copyright (c) 2010 Flowerfire, Inc. All Rights Reserved. unix_syslog = { plugin_version = "1.2" # 2006-05-11 : 1.1 : ... : added saving and restoring of last processed line. # 2009-04-24 : 1.2 : gas : removed create_profile_wizard_options, v8 now handles this all # The name of the log format log.format.format_label = "Unix Syslog" log.miscellaneous.log_data_type = "syslog" log.miscellaneous.log_format_type = "syslog_server" # The log is in this format if any of the first ten lines match this regular expression log.format.autodetect_regular_expression = "^ *<*[0-9X]*>*[A-Za-z][A-Za-z][A-Za-z] [0-9 ]?[0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\.*[0-9]* [^ ]* " # All log field parsing will be done using the parsing filters log.format.parse_only_with_filters = "true" # The format of dates and times in this log log.format.date_format = "auto" log.format.time_format = "auto" # Log fields log.fields = { date = "" time = "" logging_device = "" log_level = "" syslog_message = "" } # log.fields # At initialization time, get the last line from the previous build, in case we need it for "repeated" lines log.filter_initialization_syslog = ` string last_log_line_pathname = volatile.database_directory . "main" . internal.directory_divider . "last_log_line.txt"; string last_log_line; if (file_exists(last_log_line_pathname)) then ( last_log_line = read_file(last_log_line_pathname); ); ` # At finialization time, save the last line of this build log.filter_finalization_syslog = ` write_file(last_log_line_pathname, last_log_line); ` # Log Parsing Filters log.parsing_filters = { year_from_filename = { label = "" comment = "" value = " if (matches_regular_expression(current_log_pathname(), '((20|19)[0-9][0-9])\\\\.log')) then log.processing.default_log_date_year = $1; " disabled = false } # year_from_filename # Parse out the syslog fields syslog_1 = { label = "syslog_1" comment = "" value = ` v.syslog_message = ''; if (matches_regular_expression(current_log_line(), '^ *<*([0-9X]*)>*([A-Za-z][A-Za-z][A-Za-z] [0-9 ]?[0-9]) ([0-9][0-9]:[0-9][0-9]:[0-9][0-9])(.*)')) then ( set_collected_field('', 'log_level', $1); set_collected_field('', 'date', normalize_date($2, 'mmm dd')); set_collected_field('', 'time', $3); v.syslog_message = $4; # Look for a hostname if (matches_regular_expression(v.syslog_message, '^ ([^[ ]+) (.*)$')) then ( set_collected_field('', 'logging_device', $1); v.syslog_message = $2; ); # If there's no hostname, look for an IPv6 address else if (matches_regular_expression(v.syslog_message, '^ \\\\[([0-9]+\\\\.[0-9]+\\\\.[0-9]+\\\\.[0-9]+\\\\.[0-9]+\\\\.[0-9]+)\\\\] (.*)$')) then ( set_collected_field('', 'logging_device', $1); v.syslog_message = $2; ); # If this is a 'last message repeated' line, take the previous line and insert it into the log data stream that many times. if (matches_regular_expression(v.syslog_message, '^last message repeated ([0-9]+) times')) then ( for (int i = 0; i < $1; i++) ( set_subnode_value('volatile.log_line_insertions', i, last_log_line); ) ); # if last message repeated # If it's a normal line, extract it normally else ( while (starts_with(v.syslog_message, ' ')) v.syslog_message = substr(v.syslog_message, 1); while (matches_regular_expression(v.syslog_message, '^(.*)(\\\\^M| )$')) v.syslog_message = $1; if (matches_regular_expression(current_log_pathname(), '([0-1][0-9]-[0-3][0-9]-[21][09][0-9][0-9])')) then set_collected_field('', 'date', $1); # Remember the log line, in case we get a "last message repeated" line next last_log_line = current_log_line(); ); # if non-repeated line ); # it matches normal layout ` } # syslog_1 } # log.parsing_filters # Database fields database.fields = { date_time = "" day_of_week = "" hour_of_day = "" logging_device = "" } # database.fields } # unix_syslog