Manual Pages

Table of Contents


na_filestats - collect file usage statistics


filestats [-g] [-u] [async] [ ages <ages> ] [ expr <expression> ] [ timetype {a,m,c,cr} ] [ sizes <sizes> ] snapshot <snapshot_name> [ style <style> ] [ volume <vol_ume_name> ] [ file <output_file> ]


The filestats utility provides a summary of file usage within a volume. It must be used on a snapshot, and the only required argument is the snapshot name. The volume name defaults to "vol0" if not specified. If the volume you are examining is named otherwise, specify the name explicitly.

The output of this command will contain a breakdown of the total number of files and their total size. You can control the set of ages and sizes that get used for this breakdown, with the "ages" and "sizes" arguments. The output also contains a breakdown of file usage by user-id and group-id.

The first line of the summary contains:

The total number of inodes scanned (this includes free and used inodes).

The total number of inodes included in the totals because they are in use (and because they satisfy the "expr" expression, if that option is used).

The total number of bytes in the counted files.

The total number of kilobytes consumed by the blocks of the counted files.


The following options are supported.

async Run the scan independently of the console, best used with the file option. Care should be used to minimize the number of asynchronous scans running simultaneously. More than one can be a big drain on system performance.

A per-group breakdown will be generated, containing separate tables of ages and sizes for each group id.

A per-user breakdown will be generated, containing separate tables of ages and sizes for each user id.

ages ages
Specifies the breakdown of ages, as a set of commaseparated time values. The values are in seconds, but as a convenience you can add an H or D suffix to a number to get hours and days. For example, "900,4H,7D" would produce a breakdown with 4 categories - files accessed in the last 15 minutes, files accessed in the last four hours, files accessed in the last week, and all other files.

expr expression
(Warning, use of this option can be inefficient, and result in very long-running execution times.) This lets you specify a boolean expression that will be evaluated for each inode encountered, and if the expression is true, then the inode will be selected and included in the various breakdowns of file usage. The expression can contain "variables", which are merely the name of an inode attribute enclosed in curly braces. For example, {size} is evaluated as the size of the current inode. The valid inode attributes that you can use in expressions are:

The tree id (for qtrees).

The file type (numeric, currently).


Additional flags.

Count of hard links.

User id (numeric) of file owner.

Group id (numeric) of file owner.

Size in bytes.

Size in blocks.

Generation number.

Time of last read or write (in seconds).

Time of last write (in seconds).

Time of last size/status change (in seconds).

Time file was created (in seconds).

Age of last read or write (Now atime).

Age of last write (Now - mtime).

Age of last size/status change (Now ctime).

Age of file creation (Now - crtime).

timetype timetype
This lets you specify the type of time that will be used in the "age" comparison. Valid values for timetype are

Access time

Modification time

Change time (last size/status change)

Creation time

sizes sizes
Specifies the breakdown of sizes, as a comma-separated set of size values. The values are in bytes, but as a convenience you can add a K, M, or G suffix to a number to get kilobytes, megabytes, and gigabytes. For example, "500K,2M,1G" would produce a breakdown with 4 categories - files less than 500K, files less than 2 megabytes, files less than 1 gigabyte, and all other files.

To produce a breakdown that includes all unique file sizes,
specify "*" for the sizes value.

style style
Controls the style of output - the possible value for style are "readable" (the default), "table" (colon-separated values suitable for processing by programs), and "html".

file output_file
Instead of printing the results on the console, print the results in output_file. The output_file will be created in the /etc/log directory.


1. Produce default file usage breakdowns for snapshot hourly.1 of volume vol0.

filestats volume vol0 snapshot hourly.1

2. Produce file usage breakdowns by monthly age values:

filestats volume vol0 snapshot hourly.1 ages "30D,60D,90D,120D,150D,180D"

3. Produce file usage breakdowns for inodes whose size is less than 100000 bytes and whose access time is less than a day old:

filestats volume vol0 snapshot hourly.1 expr "{size}<100000&&{atimeage}<86400)"


On large volumes, this command may take a few minutes to execute. During that time, CPU usage will be high, often 100%. The impact of that CPU usage should be low, because the command is implemented in Java which has low priority. However, disk access to the inode file will have an effect on the throughput of file serving.

Currently, the expression-evaluating code does not do any optimizations, so although you can use arithmetic expressions, it is most efficient if you do not. Of course, it's most efficient if you don't use the expr option at all.

Table of Contents