# Copyright (c) 2014 Flowerfire, Inc. All Rights Reserved. intermapper_chart = { plugin_version = "1.0" # 2014-04-03 - 1.0 - GMF - Initial implementation info.1.manufacturer = "Help/Systems" info.1.device = "InterMapper Chart" info.1.version.1 = "" # The name of the log format log.format.format_label = "InterMapper Chart Log Format" log.miscellaneous.log_data_type = "generic" log.miscellaneous.log_format_type = "network_device" # The log is in this format if any of the first ten lines match this regular expression #Chart Title: Abc 50DTA log.format.autodetect_regular_expression = "^Chart Title: " log.format.parse_only_with_filters = false log.format.field_separator = " " log.format.date_format = "mm/dd" # This handles #Fields lines, and creates log and database fields from them #Date Time Availability for OXXO-AP-50DTA Availability for OXXO-R-50DTA log.filter_preprocessor = ` if (matches_regular_expression(current_log_line(), '^(Date Time.*)$')) then ( string fields = $1; string fieldname; v.logfieldindex = 1; string numerical_fields = "profiles." . internal.profile_name . ".database.numerical_fields"; # This subroutine creates a database field subroutine(create_database_field(string fieldname, int top, int bottom), ( #echo("create_database_field: " . fieldname); # debug debug_message("create_database_field(" . fieldname . ")\n"); string databasefieldpath = "profiles." . internal.profile_name . ".database.fields." . fieldname; (databasefieldpath . "") = ""; node databasefield = databasefieldpath; if (top ne 0) then set_subnode_value(databasefield, "suppress_top", top); if (bottom ne 0) then set_subnode_value(databasefield, "suppress_bottom", bottom); databasefield; )); # This subroutine creates an averaging database field subroutine(create_averaging_database_field(string fieldname, string fieldlabel, int top, int bottom), ( string databasefieldpath = "profiles." . internal.profile_name . ".database.fields." . fieldname; (databasefieldpath . "") = ""; node databasefield = databasefieldpath; @databasefieldpath{"label"} = fieldlabel; @databasefieldpath{"type"} = "float"; @databasefieldpath{"aggregation_method"} = "average"; @databasefieldpath{"average_denominator_field"} = "events"; databasefield; )); subroutine(create_log_field(string fieldname, string type, bool withindex), ( debug_message("create_log_field(" . fieldname . "; type=" . type . ")\n"); string logfieldpath = "profiles." . internal.profile_name . ".log.fields." . fieldname; (logfieldpath . "") = ""; node logfield = logfieldpath; if (withindex) then ( set_subnode_value(logfield, "index", v.logfieldindex); v.logfieldindex++; ); set_subnode_value(logfield, "subindex", 0); if (type ne '') then set_subnode_value(logfield, "type", type); logfield; )); # Extract the fields on at a time while (matches_regular_expression(fields, '^([^ ]+)[ ](.*)$') or matches_regular_expression(fields, '^([^ ]+)$')) ( string unconverted_fieldname = $1; fields = $2; # Clean up the field name fieldname = ''; for (int i = 0; i < length(unconverted_fieldname); i++) ( string c = lowercase(substr(unconverted_fieldname, i, 1)); if (!matches_regular_expression(c, '^[a-z0-9]$')) then c = '_'; fieldname .= c; ); while (matches_regular_expression(fieldname, '^(.*)_$')) fieldname = $1; # Get the log field type string log_field_type = 'flat'; # Create the log field create_log_field(fieldname, log_field_type, true); # If we're creating a profile, create the database fields too. if (node_exists("volatile.creating_profile")) then ( if (false) then ( ) # Handle date by creating date_time and derived database fields else if (fieldname eq "date") then ( create_log_field('date', '', false); create_database_field('date_time', 0, 0); create_database_field('day_of_week', 0, 0); create_database_field('hour_of_day', 0, 0); ); # if date else if (fieldname eq "time") then ( create_log_field('time', '', false); # create_database_field(fieldname, 0, 0); ); # if time # All fields except date/time are averaging float fields else create_averaging_database_field(fieldname, unconverted_fieldname, 0, 0); ); # if creating profile ); # while another field # Don't parse the #Fields line as a data line 'reject'; ); # if #Fields # Don't parse any other # lines as data lines else if (starts_with(current_log_line(), '#')) then ( 'reject'; ); ` # Log fields log.fields = { # date = "" # time = "" # events = "" } # log.fields # Database fields database.fields = { # date_time = "" # hour_of_day = "" # day_of_week = "" } # database.fields log.parsing_filters.set_events = `events = 1` database.numerical_fields = { events = { default = true requires_log_field = false entries_field = true } # events } # database.numerical_fields create_profile_wizard_options = { # How the reports should be grouped in the report menu report_groups = { date_time_group = "" } # report_groups } # create_profile_wizard_options } # intermapper_chart