# # Cumulative Session Bytes # # This snapon is used to compute the session bytes from Cumulative data. For each disconnect event, it subtracts the bytes from the preceding connect event, # to get the session bytes. # cumulative_session_bytes = { label = "$lang_admin.snapons.cumulative_session_bytes.label" comment = "$lang_admin.snapons.cumulative_session_bytes.comment" config_snapon_category = "" parameters = { date_time_field = { parameter_value = "date_time" validation_type = "string" form_element_label = "$lang_admin.snapons.cumulative_session_bytes.parameters.date_time_field.form_element_label" form_element_type = "select" select_options_source = "database_fields" description = "" } # date_time_field cumulative_field = { parameter_value = "cs_bytes" validation_type = "string" form_element_label = "$lang_admin.snapons.cumulative_session_bytes.parameters.cumulative_field.form_element_label" form_element_type = "select" select_options_source = "database_fields" description = "" } # cumulative_field # This is the field which has a different value in the log data, for each session session_id_field = { parameter_value = "session_id" validation_type = "string" form_element_label = "$lang_admin.snapons.cumulative_session_bytes.parameters.session_id.form_element_label" form_element_type = "select" select_options_source = "database_fields" description = "" } # session_id_field # This is the field whose value is "disconnect" for the end-of-session lines, or "connect" for the start-of-session lines x_event_field = { parameter_value = "x_event" validation_type = "string" form_element_label = "$lang_admin.snapons.cumulative_session_bytes.parameters.x_event.form_element_label" form_element_type = "select" select_options_source = "database_fields" description = "" } # x_event_field cumulative_session_bytes_name = { parameter_value = "$lang_admin.snapons.cumulative_session_bytes.parameters.cumulative_session_bytes_name.parameter_value" final_node_name = "" validation_type = "field_label" validate_field_label_for = { database_fields = true report_fields = true } form_element_label = "$lang_admin.snapons.cumulative_session_bytes.parameters.cumulative_session_bytes_name.form_element_label" form_element_type = "text" form_element_width = "380" description = "" } # cumulative_session_bytes_name } # parameters parameters_form = { group_1 = { description = "$lang_admin.snapons.cumulative_session_bytes.parameters_form.group_1.description" parameters = { date_time_field = true cumulative_field = true session_id_field = true x_event_field = true cumulative_session_bytes_name = true } # parameters } # group 1 } # parameters_form attach_operations = { # When attaching: Add the cumulative field sum database field add_database_field = { type = "add_database_fields" fields = { "{= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}" = { label = "{= @parameters{'cumulative_session_bytes_name'}{'parameter_value'} =}" type = "int" derivation_method = "database_filter" aggregation_method = "sum" category = "" index = "true" suppress_top = "0" suppress_bottom = "2" integer_bits = "64" } # cumulative_session_bytes_name } # fields } # add_database_field # When attaching: add the database filter to calculate the field add_database_filter = { type = "add_database_filters" filters = { "{= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}" = { conditions = { # Sort chronologically sort = { type = "sort" fields = { date_time = { column_name = "{= @parameters{'date_time_field'}{'parameter_value'} =}" } } # fields } # sort } # conditions # The follow expression is the code which implements the filter action expression = ` {= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =} = 0; if ({= @parameters{'x_event_field'}{'parameter_value'} =} eq 'disconnect') then ( set_collected_field({= @parameters{'session_id_field'}{'parameter_value'} =}, '{= @parameters{'cumulative_field'}{'parameter_value'} =}', 0); ); # If this is a stop event, compute the cloudfront_session_bytes value by subtracting the sc_bytes for this line from the sc_bytes for the connect line. # If this is a stop event, compute the {= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =} value by subtracting the {= @parameters{'cumulative_field'}{'parameter_value'} =} for this line from the {= @parameters{'cumulative_field'}{'parameter_value'} =} for the connect line. else if ({= @parameters{'x_event_field'}{'parameter_value'} =} eq 'stop') then {= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =} = {= @parameters{'cumulative_field'}{'parameter_value'} =} - get_collected_field({= @parameters{'session_id_field'}{'parameter_value'} =}, '{= @parameters{'cumulative_field'}{'parameter_value'} =}'); # If this is play event, remember the {= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =} value for this session. else if ({= @parameters{'x_event_field'}{'parameter_value'} =} eq 'play') then set_collected_field({= @parameters{'session_id_field'}{'parameter_value'} =}, '{= @parameters{'cumulative_field'}{'parameter_value'} =}', {= @parameters{'cumulative_field'}{'parameter_value'} =}); #echo("{= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}: " . {= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}); ` } # cumulative_session_bytes_name } # filters } # add_sessions_database_filter # When attaching: Add the report field add_report_field = { type = "add_report_fields" fields = { "{= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}" = { label = "{= @parameters{'cumulative_session_bytes_name'}{'parameter_value'} =}" column_label = "" column_info = "" database_field = "{= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}" display_format_type = "bandwidth" show_remainder_value = true show_average_value = true show_min_value = true show_max_value = true show_total_value = true percent_calculation = "sum" } # cumulative_session_bytes_name } # fields } # add_report_field # When attaching: Add the report field to all xref groups add_xref_field = { type = "add_xref_fields" xref_group = "*" fields = { "{= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}" = "" } # fields } # add_xref_field # When attaching: Add the column to all report elements add_report_column = { type = "add_report_element_columns" report = "*" report_element = "*" columns = { "{= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}" = { report_field = "{= @parameters{'cumulative_session_bytes_name'}{'final_node_name'} =}" show_column = true show_percent_column = false show_bar_column = false show_graph = false } # cumulative_session_bytes_name } # columns } # add_sessions_report_columns } # attach_operations } # cumulative_session_bytes