Example: Configuring an Accounting Profile for Statistics Collection

This example shows how to configure an accounting profile for statistics collection.

Requirements

Accounting profiles are supported on M Series Multiservice Edge Routers, MX Series 3D Universal Edge Routers, T Series Core Routers, SRX Series Services Gateways, and EX Series Ethernet Switches with Junos OS Release 7.4 and later. This example uses the following hardware and software components:

Overview

The procedures in this example describe four tasks for creating a sample ifstats interface profile. The interface profile ifstats specifies that statistics are collected every 5 minutes, and the statistics are written to the file /var/log/ifstats.log.

Configuration

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

The accounting profile configuration consists of:

Configuring Fields to Be Recorded

The fields to record are configured by choosing a profile type, specifying a name for the profile, and then listing the field names to be recorded. For example, to configure the ifstats interface profile:

  1. Configure the desired fields for the ifstats interface profile at the [edit accounting-options interface-profile ifstats fields] hierarchy level.
    [edit accounting-options interface-profile ifstats fields]user@host# set input-bytes output-bytes input-errors output-errors unsupported-protocol rpf-check-bytes
  2. Verify the configuration by using the show command at the [edit accounting-options] hierarchy level.
    [edit accounting-options]
    user@host# show 
    interface-profile ifstats {
        fields {
            input-bytes;
            output-bytes;
            input-errors;
            output-errors;
            unsupported-protocol;
            rpf-check-bytes;
        }
    }

Step-by-Step Procedure

Configuring When to Record Fields

To capture the fields at regular intervals:

  1. Configure the time interval for the ifstats interface profile.
    [edit accounting-options]user@host# set interface-profile ifstats interval 5
  2. Verify the configuration by using the show command at the [edit accounting-options] hierarchy level.
    [edit accounting-options]
    user@host# show 
    interface-profile ifstats {
        interval 5;
        fields {
            input-bytes;
            output-bytes;
            input-errors;
            output-errors;
            unsupported-protocol;
            rpf-check-bytes;
        }
    }

Step-by-Step Procedure

Configuring Instances That Need Accounting

To configure the interfaces on which the accounting needs to be performed, apply the interface profile to a physical interface or a logical interface by including the accounting-profile statement at either the [edit interfaces interface-name] or the [edit interfaces interface-name unit logical-unit-number] hierarchy level. For example, perform the following steps to apply the ifstats accounting profile to the fe-0/2/3 interface:

  1. Apply the ifstats accounting profile to the fe-0/2/3 interface.
    [edit interfaces]user@host# set fe-0/2/3 unit 0 accounting-profile ifstats
  2. Verify the configuration by using the show command at the [edit interfaces] hierarchy level.
    [edit interfaces]
    user@host# show 
    fe-0/2/3 {                              
        unit 0 {                            
            accounting-profile ifstats;     
        }                                   
    }

Step-by-Step Procedure

Saving the Recorded Data

To configure the router to save the recorded data to an accounting-data log file:

  1. Configure the accounting-data log file name.
    [edit accounting-options]user@host# edit file ifstats.log
  2. Configure the size of the accounting-data log file.
    [edit accounting-options file ifstats.log]user@host# set size 262144
  3. Verify the configuration by using the show command at the [edit accounting-options] hierarchy level.
    [edit accounting-options]
    user@host# show 
    file ifstats.log {
        size 256k;
    }
    interface-profile ifstats {
       interval 5;
        fields {
            input-bytes;
            output-bytes;
            input-errors;
            output-errors;
            unsupported-protocol;
            rpf-check-bytes;
        }
    }

Related Documentation