Using the Recorded Data

After you have set up an accounting profile, you can use the recorded data for monitoring and troubleshooting purposes.

Understanding and Viewing the Data

This section covers the following topics:

Understanding the Accounting-Data Log File Format

In the accounting-data log file, the data is saved in a modified comma separated value (CSV) format. In this format, the CSV lines are combined with lines that define the layout of the fields used by the CSV data. Each CSV line begins with two standard fields, a layout name, and a timestamp. The file also contains a format definition line that maps the layout name to the fields that appear in the lines tagged with that layout name. This format enables multiple layouts of data inside a single file, and also allows the definition of the layout to change over time without requiring a new file.

For example, consider the following accounting-data log file of an interface profile that saves input bytes:

    #profile-layout ifstats,epoch-timestamp,interface-name,input-bytes
    ifstats,1266020093,fe-0/2/3.0,1592386
    ifstats,1266020123,fe-0/2/3.0,1762869

This layout helps you modify the CSV data into structured XML data, using the layout names and field names for both encoding and filtering. For example, the previous accounting-data log file can be represented in XML as follows:

<interface-accounting-record> <profile-layout>ifstats</profile-layout> <epoch-timestamp>1266020093</epoch-timestamp> <interface-name>fe-0/2/3.0</interface-name> <input-bytes>1592386</input-bytes></interface-accounting-record>

Multiple accounting profiles can be configured to record data in the same accounting-data log file. For example, you can have interface statistics and CPU statistics recorded in a single log file so that you can transfer these statistics together. Configuring multiple accounting profiles to update the same accounting-data log file has an impact on the format of the log file. This is because all the formats are defined and referenced in the same log file. The contents of a sample accounting-data log file that records the data of two accounting profiles are shown in the following sample output:

  #fmt1 n1a,n1b,n1c
  #fmt2 n2a,n2b,n2c
  fmt1,v1a,v1b,v1c
  fmt2,v2a,v2b,v2c
  fmt1,v3a,v3b,v3c
  fmt2,v4a,v4b,v4c

Therefore, this not only provides simplicity in the form of CSV output, but also provides sufficient information to produce XML content.

Related Documentation

Commands for Viewing Accounting Profile Information

Two commands can be used to view accounting profile information.

The show accounting profile profile-name command displays the information regarding the profile. Sample output of a show accounting profile profile-name command follows:

user@host> show accounting profile ifstats 
Profile ifstats
Sampling interval: 1 minute(s),  Profile Usage Count: 16
File ifstats: maximum size 2097152, maximum number 10, bytes written 20454
Transfer Interval: 30 minute(s),  Next Scheduled Transfer: 2010-02-16-14:44:24
Column Labels:
  profile-layout
  epoch-timestamp
  interface-name
  input-bytes
 
Interface Name              Next Scheduled Collection
fe-0/0/0.0                  2010-02-16-14:34:24
fe-0/0/1.0                  2010-02-16-14:34:27
fe-0/0/2.0                  2010-02-16-14:34:30
fe-0/0/3.0                  2010-02-16-14:34:33

The show accounting records profile-name command displays the records that are stored in the accounting-data log file of the profile. Sample output of a show accounting records profile-name command follows:

user@host> show accounting records ifstats
Timestamp: 1266329666, Interface Name: fe-0/0/1.0 (SNMP Index 137)
              3644676   Input Bytes
Timestamp: 1266329669, Interface Name: fe-0/0/2.0 (SNMP Index 138)
              3644012   Input Bytes
Timestamp: 1266329672, Interface Name: fe-0/0/3.0 (SNMP Index 139)
              3952848   Input Bytes

Related Documentation

Remote Procedure Calls for Viewing Accounting Profile Information

You can access the <get-accounting-profile-information> and <get-accounting-record-information> remote procedure calls (RPCs) using XML APIs to fetch the profile information. The <get-accounting-profile-information> RPC provides the same information that the show accounting profile profile-name command provides. Similarly, the <get-accounting-record-information> RPC provides the same information that the show accounting records profile-name command provides. The since argument to this RPC provides accounting statistics since the specified time.

Script Examples

Like the jnxUtility MIB, you can develop scripts to use the recorded accounting profiles information. The following sample Stylesheet Language Alternative Syntax (SLAX) code illustrates how to add an entry to an accounting-data log file:

        var $add = <add-accounting-file-record> {
            <file> $file;
            <layout> $layout;
            <fields> "target,loss,min,max,ave,std";
            <data> $target _ "," _
                    $res/packet-loss _ "," _
                    $res/rtt-minimum _ "," _
                    $res/rtt-maximum _ "," _
                    $res/rtt-average _ "," _
                    $res/rtt-stddev;
        }
        var $done = jcs:invoke($add);

In the preceding code block, $file is the name of the accounting-data log file that is configured at the [edit accounting-options file] hierarchy level. Additionally, $layout is the name assigned to the format of the accounting-data log file. Sample output for this code block follows:

#layout target,loss,min,max,ave,std
layout,10.1.2.3,5,48,540,218,25

In the preceding sample output, the string layout indicates that $layout is assigned the value layout.

The following sample SLAX code illustrates how to read data from an accounting-data log file:

        var $rpc = <get-accounting-file-record-information> {
            <file> $file;
            <since> -86400;
        }
        var $out = jcs:invoke($rpc);

Similarly, you can develop complex scripts to archive or compress profile data, to provide a historical view of how the data changes over time, or to meet any of your custom requirements. For example:

You can develop several such scripts that suit your requirements.