Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Configuring Accounting-Data Log Files

 

An accounting profile specifies what statistics to collect and write to a log file. To configure an accounting-data log file, include the file statement at the [edit accounting-options] hierarchy level:

where filename is the name of the file in which to write accounting data.

If the filename contains spaces, enclose it in quotation marks (" "). The filename cannot contain a forward slash (/). The file is created in the /var/log directory and can contain data from multiple profiles.

All accounting-data log files include header and trailer sections that start with a # in the first column. The header contains the file creation time, the hostname, and the columns that appear in the file. The trailer contains the time that the file was closed.

Whenever any configured value changes that affects the columns in a file, the file creates a new profile layout record that contains a new list of columns.

You must configure the file size; all other properties are optional.

Configuring How Long Backup Files Are Retained

You can configure how many days the files are retained in the local directory before they are deleted.

Note

Files saved to the /var/log/pfedBackup directory are always compressed to conserve local storage, regardless of whether the compress statement is configured.

To configure retention for backup files:

  • Specify the number of days.

Note

Files are retained for 1 day if you do not configure this option.

This value, whether configured or default, applies to all configured files at the [edit accounting-options file] hierarchy level.

Configuring the Maximum Size of the File

To configure the maximum size of the file:

  • Specify the size.

The size statement is the maximum size of the log file, in bytes, kilobytes (KB), megabytes (MB), or gigabytes (GB). The minimum value for bytes is 256 KB. You must configure bytes; the remaining attributes are optional.

Configuring Archive Sites for the Files

After a file reaches its maximum size or the transfer-interval time is exceeded, the file is closed, renamed, and, if you configured an archive site, transferred to a remote host.

To configure the sites where files are archived:

  • Specify one or more site names.

where site-name is any valid FTP URL. For more information about specifying valid FTP URLs, see the Junos OS Administration Library. You can specify more than one URL, in any order. When a file is archived, the router or switch attempts to transfer the file to the first URL in the list, trying the next site in the list only if the transfer does not succeed. The log file is stored at the archive site with a filename of the format router-name_log-filename_timestamp. When you configure file archival by using archive-states statement, the transfer file utility uses the default routing instance to connect to the destination server. If the default routing instance is unable to connect to the destination server, the transfer file utility does not work.

Starting in Junos OS 18.4R1, when you configure file archival by using the archive-sites statement, the transfer file utility does not work if you have enabled the management instance.

Configuring Local Backup for Accounting Files

You can configure the router to save a copy of the accounting file locally when the normal transfer of the files to the archive site fails. The file is saved to the /var/log/pfedBackup directory of the relevant Routing Engine. You must specify whether only the files from the master Routing Engine are saved or files are saved from both the master Routing Engine and the backup (client) Routing Engine.

Note

Files saved to the /var/log/pfedBackup directory are always compressed to conserve local storage, regardless of whether the compress statement is configured.

To configure local backup in the event of failure:

  • Specify local backup and which files are saved.

Disabling this feature deletes the backed-up accounting files from the directory.

Note

When you do not configure this option, the file is saved on failure into the local directory specified as the last site in the list of archive sites.

Configuring Files to Be Compressed

By default, accounting files are transferred in an uncompressed format. To conserve resources during transmission and on the archive site, you can configure compression for the files.

Note

Files saved to the /var/log/pfedBackup directory are always compressed to conserve local storage, regardless of whether the compress statement is configured.

To configure the router to compress accounting files when they are transferred:

  • Specify compression.

Configuring the Maximum Number of Files

To configure the maximum number of files:

  • Specify the number.

When a log file reaches its maximum size, it is renamed filename.0, then filename.1, and so on, until the maximum number of log files is reached. Then the oldest log file is overwritten. The minimum value for number is 3 and the default value is 10.

Configuring the Storage Location of the File

On J Series Services Routers, the files are stored by default on the compact flash drive. Alternatively, you can configure the files to be stored in the mfs/var/log directory (on DRAM) instead of the cf/var/log directory (on the compact flash drive).

To configure the storage location on DRAM:

  • Specify nonpersistent storage.

This feature is useful for minimizing read/write traffic on the router’s compact flash drive.

Note

If log files for accounting data are stored on DRAM, these files are lost when you reboot the router. We recommend that you back up these files periodically.

Configuring Files to Be Saved After a Change in Mastership

You can configure the router to save the accounting files from the new backup Routing Engine to the new master Routing Engine when a change in mastership occurs. The files are stored in the /var/log/pfedBackup directory on the router. The master Routing Engine includes these accounting files with its own current accounting files when it transfers the files from the backup directory to the archive site at the next transfer interval. Configure this option when the new backup Routing Engine is not able to connect to the archive site; for example, when the site is not connected by means of an out-of-band interface or the path to the site is routed through a line card.

To configure the backup Routing Engine files to be saved when mastership changes:

  • Specify the backup.

Note

The backup Routing Engine’s files on the master Routing Engine are sent at each interval even though the files remain the same. If this is more activity than you want, consider using the backup-on-failure master-and-slave statement instead.

Configuring the Start Time for File Transfer

To configure the start time for transferring files:

  • Specify the time.

For example, 10:00 a.m. on January 30, 2007 is represented as 2007-01-30.10:00.

Configuring the Transfer Interval of the File

To configure the interval at which files are transferred:

  • Specify the interval.

The range for transfer-interval is 5 through 2880 minutes. The default is 30 minutes.

Tip

Junos OS saves the existing log file and creates a new file at the configured transfer intervals irrespective of whether:

  • The file has reached the maximum size.

  • An archive site is configured.

When you have a relatively small transfer interval configured and if no archive site is configured, data can be lost as Junos OS overwrites the log files when the maximum number of log files is reached. To ensure that the log information is saved for a reasonably long time:

  • Configure an archive site to archive the log files every time a new log file is created.

  • Configure the maximum value (2880 minutes) for transfer-interval so that new files are created less frequently; that is, only when the file exceeds the maximum size limit or once in 2 days.

Release History Table
Release
Description
Starting in Junos OS 18.4R1, when you configure file archival by using the archive-sites statement, the transfer file utility does not work if you have enabled the management instance.