IN THIS PAGE
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:
Junos OS Release 11.2
M7i Multiservice Edge router
This configuration example has been tested using the software release listed and is assumed to work on all later releases.
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
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 the fields that need to be recorded
Configuring when to record the fields
Configuring the instances that need accounting
Saving the recorded data
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:
- 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
- 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; } }
Configuring When to Record Fields
To capture the fields at regular intervals:
- Configure the time interval for the ifstats interface profile.[edit accounting-options]user@host# set interface-profile ifstats interval 5
- 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; } }
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:
- 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
- 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; } }
Saving the Recorded Data
To configure the router to save the recorded data to an accounting-data log file:
- Configure the accounting-data log file name.[edit accounting-options]user@host# edit file ifstats.log
- Configure the size of the accounting-data log file.[edit accounting-options file ifstats.log]user@host# set size 262144
- 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; } }