Written by Douglas McPherson
Solutions Consultant at Juniper
This is part 5 of 6 of On-Box Storage.
Previous Article: On-Box Storage: Option 3 - Utility MIB as a Data Store
Next Article: On-Box Storage: Choosing a Solution
This applies to SLAX version 1.0 and higher.
Suppose that your script needs to keep a local history of some counter or gauge over time – possibly with the intent of “peeking” into it for some local analysis, or maybe eventually exporting it off-box so that it can be imported into another application. This is precisely the function that JUNOS accounting files provide.
JUNOS accounting files allow you to save (and read) data on-box using a CSV (comma-separated value) format. The JUNOS accounting file format includes the data that you put there plus special “layout” lines which describe the fields for your records. Each accounting file record begins with 2 fields: the layout name (which identifies your record layout) and a timestamp. Any fields after that are the fields that you list in your “layout” record, separated by commas. With this approach, a single JUNOS accounting file can contain multiple data layouts. For example, while all the records in a given accounting file may contain “interface” data, the records in the file may co-mingle interface “counter” layout records with “rate” layout records for the same interfaces.
JUNOS accounting files are defined in the JUNOS configuration in the accounting-options stanza. There you can specify the file name as well as the parameters that JUNOS applies to provide functions like maximum file size, how many versions to maintain and off-site export of the archives.
JUNOS accounting file creation, update and reading is fully supported via JUNOS XML APIs. This means you can programmatically create, read and write whatever data you need, directly from your own JUNOS automation – with the caveat that the file was first defined in the JUNOS configuration accounting-options.